Browse Source

结束监考接口修改

wangliang 2 years ago
parent
commit
5e658ee205

+ 7 - 9
themis-admin/src/main/java/com/qmth/themis/admin/api/TIeInvigilateController.java

@@ -621,18 +621,16 @@ public class TIeInvigilateController {
     @ApiOperation(value = "结束监考接口")
     @RequestMapping(value = "/exam/finish", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
-    public Result examFinish(@ApiParam(value = "考试id", required = true) @RequestParam Long examId) {
-        if (Objects.isNull(examId) || Objects.equals(examId, "")) {
-            throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
-        }
+    public Result examFinish(@ApiParam(value = "考试id", required = true) @RequestParam Long examId,
+                             @ApiParam(value = "监考状态", required = true) @RequestParam InvigilateMonitorStatusEnum status) {
+        Optional.ofNullable(examId).orElseThrow(() -> new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL));
+        Optional.ofNullable(status).orElseThrow(() -> new BusinessException("监考状态不能为空"));
+
         ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examId);
-        if (System.currentTimeMillis() < examCacheBean.getEndTime()) {
+        if (status == InvigilateMonitorStatusEnum.FINISHED && System.currentTimeMillis() < examCacheBean.getEndTime()) {
             throw new BusinessException("未到考试批次结束时间");
         }
-        if (examCacheBean.getMonitorStatus() == InvigilateMonitorStatusEnum.FINISHED) {
-            throw new BusinessException("考试批次已结束");
-        }
-        teExamService.updateInvigilateMonitorStatus(InvigilateMonitorStatusEnum.FINISHED, examId);
+        teExamService.updateInvigilateMonitorStatus(status, examId);
         teExamService.deleteExamCacheBean(examId);
         return ResultUtil.ok(true);
     }