更新统计模块查询入参。
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# statcalc_api所有统计分析模块的api路由、接口
|
||||
|
||||
from fastapi import APIRouter , Depends , HTTPException
|
||||
from fastapi import APIRouter , Depends , HTTPException , Query
|
||||
from StatCalc.dao.statcalc_dao import *
|
||||
from StatCalc.schema.statcalc_request import *
|
||||
from databases import *
|
||||
@@ -9,13 +9,13 @@ statcalc_api = APIRouter()
|
||||
|
||||
@statcalc_api.get("/statcalc/age"
|
||||
,summary='人员信息查询'
|
||||
,description=f'查询所有超过30岁的学员的信息。'
|
||||
,description=f'查询所有大于等于输入年龄的学员的信息。'
|
||||
)
|
||||
def get_students(db=Depends(get_db)):
|
||||
result = get_age_30( db=db )
|
||||
if result:
|
||||
return result
|
||||
raise HTTPException(status_code=404, detail="没有找到符合条件的学生")
|
||||
def get_students( age:int = 0 ,db=Depends(get_db)):
|
||||
result = get_age_30( age=age , db=db )
|
||||
if result is None or len(result) == 0:
|
||||
raise HTTPException(status_code=404, detail="没有找到符合条件的学生")
|
||||
return result
|
||||
|
||||
@statcalc_api.get("/statcalc/students"
|
||||
,summary='人数统计'
|
||||
@@ -33,25 +33,29 @@ def get_students(headcount:get_student_dao
|
||||
,summary='优秀成绩学生信息查询'
|
||||
,description=f'查询所有科目考试成绩都在80分以上的学生。'
|
||||
)
|
||||
def get_excellent(db=Depends(get_db)):
|
||||
result = get_excellent_students( db=db )
|
||||
def get_excellent(sco:int = Query(80,ge=0, le=100,description="优秀成绩设定")
|
||||
, db=Depends(get_db)
|
||||
):
|
||||
result = get_excellent_students(sco=sco, db=db )
|
||||
if result:
|
||||
return result
|
||||
raise HTTPException(status_code=404, detail="没有找到符合条件的学生")
|
||||
|
||||
@statcalc_api.get("/statcalc/fail"
|
||||
,summary='不及格成绩查询'
|
||||
,description=f'查询有两次以上不及格的学生的姓名,班级和不及格成绩。'
|
||||
,description=f'查询有两次以上低于输入分数的学生的姓名,班级和不及格成绩。'
|
||||
)
|
||||
def get_students( db=Depends(get_db) ):
|
||||
result = get_score_80( db=db )
|
||||
def get_students(sco:int = Query(60,ge=0, le=100,description="不及格成绩设定")
|
||||
, db=Depends(get_db) ):
|
||||
result = get_score_60( sco=sco ,db=db )
|
||||
if result:
|
||||
return result
|
||||
raise HTTPException(status_code=404, detail="没有找到符合条件的学生")
|
||||
|
||||
@statcalc_api.get('/statcalc/average', summary='统计每次考试每个班级的平均分')
|
||||
def get_class_avg(db=Depends(get_db)):
|
||||
result = get_class_avg_dao(db)
|
||||
def get_class_avg( class_id:int = Query(1,ge=1, le=3,description="查询班级")
|
||||
, db=Depends(get_db)):
|
||||
result = get_class_avg_dao( class_id , db)
|
||||
if not result:
|
||||
return []
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user