张昕浩 #56
+5
-4
@@ -12,14 +12,13 @@ def create_score(req: ScoreCreate, db: Session = Depends(get_db)):
|
||||
# 业务校验:联合唯一
|
||||
if exist_student_exam_dao(req.student_id, req.exam_seq, db):
|
||||
raise HTTPException(status_code=400, detail="该学生本次考试成绩已存在,不能重复录入")
|
||||
|
||||
ok = post_score_dao(req.model_dump(), db)
|
||||
if not ok:
|
||||
raise HTTPException(status_code=400, detail="新增成绩失败,请检查学生id是否存在")
|
||||
return {"msg": "新增成功"}
|
||||
|
||||
|
||||
@scores_router.get("", response_model=ScorePageResp, summary="查询成绩接口")
|
||||
@scores_router.get("", response_model=ScorePageResp, summary="个人成绩查询接口")
|
||||
def list_score(
|
||||
score_id: int|None=None,
|
||||
student_id: int |None=None,
|
||||
@@ -32,7 +31,9 @@ def list_score(
|
||||
return {"total": total, "data": data_list}
|
||||
|
||||
|
||||
@scores_router.put("/{score_id}", summary="更新成绩接口")
|
||||
|
||||
|
||||
@scores_router.put("{score_id}", summary="更新成绩接口")
|
||||
def modify_score(score_id: int, req: ScoreUpdate, db: Session = Depends(get_db)):
|
||||
update_dict = req.model_dump(exclude_unset=True)
|
||||
if not update_dict:
|
||||
@@ -43,7 +44,7 @@ def modify_score(score_id: int, req: ScoreUpdate, db: Session = Depends(get_db))
|
||||
return {"msg": "修改成功"}
|
||||
|
||||
|
||||
@scores_router.delete("/{score_id}", summary="删除成绩接口")
|
||||
@scores_router.delete("{score_id}", summary="删除成绩接口")
|
||||
def remove_score(score_id: int, db: Session = Depends(get_db)):
|
||||
ok = delete_score_dao(score_id, db)
|
||||
if not ok:
|
||||
|
||||
Reference in New Issue
Block a user