nb
This commit is contained in:
@@ -19,6 +19,13 @@ def get_grade(stu_id: int,db=Depends(get_db)):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise HTTPException(status_code=500,detail=f'数据库查询异常:{str(e)}')
|
raise HTTPException(status_code=500,detail=f'数据库查询异常:{str(e)}')
|
||||||
|
|
||||||
|
@gradeAPI.delete('/{stu_id}',summary='删除成绩')
|
||||||
|
def delete_grade(stu_id:int,db=Depends(get_db)):
|
||||||
|
r = delete_grade_dao(stu_id=stu_id,db=db)
|
||||||
|
if not r:
|
||||||
|
raise HTTPException(status_code=404,detail='删除失败')
|
||||||
|
return {'code':200,'totals':r,'detail':'删除成功'}
|
||||||
|
|
||||||
@gradeAPI.post('/grade',summary='添加学生成绩')
|
@gradeAPI.post('/grade',summary='添加学生成绩')
|
||||||
def post_grade(o:GradeRequest,db=Depends(get_db)):
|
def post_grade(o:GradeRequest,db=Depends(get_db)):
|
||||||
d=o.model_dump()
|
d=o.model_dump()
|
||||||
@@ -72,9 +79,3 @@ def put_grade(
|
|||||||
|
|
||||||
return {"code": 200, "totals": rows, "detail": "更新成功"}
|
return {"code": 200, "totals": rows, "detail": "更新成功"}
|
||||||
|
|
||||||
@gradeAPI.delete('/{score_id}',summary='删除成绩')
|
|
||||||
def delete_grade(score_id:int,db=Depends(get_db)):
|
|
||||||
r = delete_grade_dao(stu_id=score_id,db=db)
|
|
||||||
if not r:
|
|
||||||
raise HTTPException(status_code=404,detail='删除失败')
|
|
||||||
return {'code':200,'totals':r,'detail':'删除成功'}
|
|
||||||
@@ -24,9 +24,14 @@ def get_grade_dao( stu_id:int , db):
|
|||||||
,Student_Model.stu_name
|
,Student_Model.stu_name
|
||||||
,WlScore.exam_order
|
,WlScore.exam_order
|
||||||
,WlScore.score
|
,WlScore.score
|
||||||
|
,ClassManagement.class_name
|
||||||
)
|
)
|
||||||
.join( Student_Model,WlScore.stu_id == Student_Model.stu_id)
|
.join( Student_Model,WlScore.stu_id == Student_Model.stu_id)
|
||||||
.filter(WlScore.stu_id == stu_id,WlScore.delete_status == 0,Student_Model.delete_status == 0)
|
.join(ClassManagement,Student_Model.class_id==ClassManagement.class_id)
|
||||||
|
.filter( WlScore.stu_id == stu_id
|
||||||
|
,WlScore.delete_status == 0
|
||||||
|
,Student_Model.delete_status == 0
|
||||||
|
,ClassManagement.delete_status == 0)
|
||||||
.all())
|
.all())
|
||||||
if r1:
|
if r1:
|
||||||
data_list = []
|
data_list = []
|
||||||
@@ -36,7 +41,8 @@ def get_grade_dao( stu_id:int , db):
|
|||||||
"stu_id": row.stu_id,
|
"stu_id": row.stu_id,
|
||||||
"stu_name": row.stu_name,
|
"stu_name": row.stu_name,
|
||||||
"exam_order": row.exam_order,
|
"exam_order": row.exam_order,
|
||||||
"score": row.score
|
"score": row.score,
|
||||||
|
"class_name": row.class_name,
|
||||||
})
|
})
|
||||||
return data_list
|
return data_list
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user