This commit is contained in:
he
2026-09-21 21:40:48 +08:00
parent 85c3cc6508
commit c391bf2ebd
3 changed files with 15 additions and 16 deletions
+6 -6
View File
@@ -6,11 +6,11 @@ from schema.grade_schema import *
gradeAPI = APIRouter(tags=['学生考核成绩'])
@gradeAPI.get("/grade/{stu_id}",summary="根据学生id查询成绩")
@gradeAPI.get("/grade/{stu_id}",response_model=list[GradeResponse],summary="根据学生id查询成绩")
def get_grade(stu_id: int,db=Depends(get_db)):
try:
res=get_grade_dao(stu_id,db)
return {'code': 200,'msg':'查询成功','data':res}
return res
except Exception as e:
raise HTTPException(status_code=500,detail=f'数据库查询异常:{str(e)}')
@@ -23,13 +23,13 @@ def post_grade(o:GradeRequest=Form(),db=Depends(get_db)):
return o
@gradeAPI.put('/{score_id}',summary='成绩修改')
def put_grade(score_id: int,o:GradeUpdate,db=Depends(get_db)):
d = o.model_update(exclude_unset=True)
def put_grade(score_id: int,o:GradeRequest=Form(),db=Depends(get_db)):
d = o.model_dump(exclude_unset=True)
r = update_grade_dao(score_id=score_id
,update_data=d
,db=db)
if not r:
raise HTTPException(status_code=500,detail='没有更新')
if not d:
raise HTTPException(status_code=500,detail='请传入需要修改的字段')
return {'code':200,'totals':r,'detail':'更新成功'}
@gradeAPI.delete('/{score_id}',summary='删除成绩')