统计
This commit is contained in:
@@ -37,7 +37,7 @@ def update_scores(score:ScoreRequest,sid:int,cid:int,num:int,t_subject:int,db=De
|
||||
@score_api.delete('/Score',summary='成绩删除',description=f'查询条件为学号,班级号,考试科目,然后进行删除')
|
||||
def delete_scores(sid:int,cid:int,t_subject:int,db=Depends(get_db)):
|
||||
aaa = delete_scores_dao(sid,cid,t_subject,db)
|
||||
if aaa==1:
|
||||
if aaa==-1:
|
||||
raise HTTPException(status_code=500,detail='删除失败')
|
||||
if aaa==0:
|
||||
raise HTTPException(status_code=404,detail='记录不存在')
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from scores.database import get_db
|
||||
from scores.dao.statistic_dao import get_top_students_dao,get_failing_students_dao,get_class_avg_dao
|
||||
|
||||
statistic_api = APIRouter()
|
||||
|
||||
@statistic_api.get('/statistic', summary='查询每次考试都在80分以上的学生')
|
||||
def get_top_students(db=Depends(get_db)):
|
||||
q = get_top_students_dao(db)
|
||||
if not q:
|
||||
return []
|
||||
return q
|
||||
|
||||
@statistic_api.get('/Score/failing', summary='查询两次以上不及格的学生')
|
||||
def get_failing_students(db=Depends(get_db)):
|
||||
result = get_failing_students_dao(db)
|
||||
if not result:
|
||||
return []
|
||||
return result
|
||||
|
||||
@statistic_api.get('/Score/class-avg', summary='统计每次考试每个班级的平均分')
|
||||
def get_class_avg(db=Depends(get_db)):
|
||||
result = get_class_avg_dao(db)
|
||||
if not result:
|
||||
return []
|
||||
return result
|
||||
Reference in New Issue
Block a user