添加statistics tag
This commit is contained in:
+15
-14
@@ -3,6 +3,7 @@ from core.database import get_db
|
||||
from models.employment import Employment
|
||||
from models.student import Student
|
||||
from models.score import Score
|
||||
from schemas.statistics import *
|
||||
from dao.statistics import *
|
||||
from schemas.common import SuccessResponse
|
||||
from sqlalchemy.orm import Session
|
||||
@@ -11,34 +12,34 @@ from sqlalchemy.orm import Session
|
||||
statistics_router=APIRouter(tags=['统计接口'])
|
||||
|
||||
|
||||
@statistics_router.get("/students/age-over-30",response_model=SuccessResponse)
|
||||
def api_age_over_thirty(db:Session=Depends(get_db)):
|
||||
@statistics_router.post("/students/age-over-30",response_model=SuccessResponse)
|
||||
def api_age_over_thirty(input_age:GenderCount,db:Session=Depends(get_db)):
|
||||
try:
|
||||
age_over_thirty_list=age_over_thirty(Student,db)
|
||||
age_over_thirty_list=age_over_thirty(Student,input_age.input_class,db)
|
||||
return SuccessResponse(status_code=200,msg=age_over_thirty_list)
|
||||
except NoExist as e:
|
||||
raise HTTPException(status_code=404,detail=str(e))
|
||||
# 这边功能函数返回的是一个字典
|
||||
@statistics_router.get("/classes/gender-count",response_model=SuccessResponse)
|
||||
def api_gender_count(db:Session=Depends(get_db)):
|
||||
def api_gender_count(input_class:int|None= None,db:Session=Depends(get_db)):
|
||||
try:
|
||||
result = gender_count(Student,db)
|
||||
result = gender_count(Student,db,input_class)
|
||||
return SuccessResponse(status_code=200,msg=result)
|
||||
except NoExist as e:
|
||||
raise HTTPException(status_code=404,detail=str(e))
|
||||
|
||||
@statistics_router.get("/scores/all-above-80",response_model=SuccessResponse)
|
||||
def all_above_eighty(db:Session=Depends(get_db)):
|
||||
@statistics_router.post("/scores/all-above-80",response_model=SuccessResponse)
|
||||
def all_above_eighty(page:int,score:StudentScore,db:Session=Depends(get_db)):
|
||||
try:
|
||||
result = score_over_eighty(Score,Student,db)
|
||||
result = score_over_eighty(score.score,page,Score,Student,db)
|
||||
return SuccessResponse(status_code=200,msg=result)
|
||||
except NoExist as e:
|
||||
raise HTTPException(status_code=404,detail=str(e))
|
||||
|
||||
@statistics_router.get("/scores/fail-more-than-two",response_model=SuccessResponse)
|
||||
def fail_two(db:Session=Depends(get_db)):
|
||||
def fail_two(num:int,offset_set:int,db:Session=Depends(get_db)):
|
||||
try:
|
||||
result = twice_error(Score,Student,db)
|
||||
result = twice_error(num,offset_set,Score,Student,db)
|
||||
return SuccessResponse(status_code=200,msg=result)
|
||||
except NoExist as e:
|
||||
raise HTTPException(status_code=404,detail=str(e))
|
||||
@@ -53,17 +54,17 @@ def class_average(db:Session=Depends(get_db)):
|
||||
|
||||
|
||||
@statistics_router.get("/employments/top5-salary",response_model=SuccessResponse)
|
||||
def top_salary(db:Session=Depends(get_db)):
|
||||
def top_salary(limit_set:int,db:Session=Depends(get_db)):
|
||||
try:
|
||||
result=max_salary(Student,Employment,db)
|
||||
result=max_salary(limit_set,Student,Employment,db)
|
||||
return SuccessResponse(status_code=200,msg=result)
|
||||
except NoExist as e:
|
||||
raise HTTPException(status_code=404,detail=str(e))
|
||||
|
||||
@statistics_router.get("/employments/student-duration",response_model=SuccessResponse)
|
||||
def employ_time(db:Session=Depends(get_db)):
|
||||
def employ_time(limit_set,db:Session=Depends(get_db)):
|
||||
try:
|
||||
result = student_market(Employment,db)
|
||||
result = student_market(limit_set,Employment,db)
|
||||
return SuccessResponse(status_code=200,msg=result)
|
||||
except NoExist as e:
|
||||
raise HTTPException(status_code=404,detail=str(e))
|
||||
|
||||
Reference in New Issue
Block a user