fix: ExamService.start_exam返回ID避免懒加载
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
修改start_exam返回exam.id而不是整个Exam对象, 彻底避免SQLAlchemy异步会话的懒加载问题
This commit is contained in:
@@ -66,7 +66,7 @@ async def start_exam(
|
||||
user_id = current_user.id
|
||||
username = current_user.username
|
||||
|
||||
exam = await ExamService.start_exam(
|
||||
exam_id = await ExamService.start_exam(
|
||||
db=db,
|
||||
user_id=user_id,
|
||||
course_id=request.course_id,
|
||||
@@ -96,7 +96,7 @@ async def start_exam(
|
||||
)
|
||||
)
|
||||
|
||||
return ResponseModel(code=200, data=StartExamResponse(exam_id=exam.id), message="考试开始")
|
||||
return ResponseModel(code=200, data=StartExamResponse(exam_id=exam_id), message="考试开始")
|
||||
|
||||
|
||||
@router.post("/submit", response_model=ResponseModel[SubmitExamResponse])
|
||||
|
||||
Reference in New Issue
Block a user