deason пре 3 година
родитељ
комит
a6caedbf4e

+ 1 - 7
examcloud-core-oe-student-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/student/api/controller/ExamControlController.java

@@ -90,13 +90,7 @@ public class ExamControlController extends ControllerSupport {
     @PostMapping("/startAnswer")
     public StartAnswerInfo startAnswer(@RequestParam @ApiParam(value = "考试记录id") Long examRecordDataId) {
         User user = getAccessUser();
-        String sequenceLockKey = Constants.EXAM_CONTROL_LOCK_PREFIX + user.getUserId();
-        // 开始考试上锁,分布式锁,系统在请求结束后会,自动释放锁,无需手动解锁
-        SequenceLockHelper.getLock(sequenceLockKey);
-        Check.isNull(examRecordDataId, "examRecordDataId不能为空");
-
-        return examControlService.startAnswer(examRecordDataId);
-
+        return examControlService.startAnswer(examRecordDataId, user.getUserId());
     }
 
     /**

+ 1 - 6
examcloud-core-oe-student-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/student/api/controller/client/ExamProcessController.java

@@ -61,12 +61,7 @@ public class ExamProcessController extends ControllerSupport {
     @PostMapping("/startAnswer")
     public StartAnswerInfo startAnswer(@RequestParam @ApiParam(value = "考试记录ID") Long examRecordDataId) {
         User user = getAccessUser();
-        String sequenceLockKey = Constants.EXAM_CONTROL_LOCK_PREFIX + user.getUserId();
-        // 开始考试上锁,分布式锁,系统在请求结束后会,自动释放锁,无需手动解锁
-        SequenceLockHelper.getLock(sequenceLockKey);
-        Check.isNull(examRecordDataId, "examRecordDataId不能为空");
-
-        return examControlService.startAnswer(examRecordDataId);
+        return examControlService.startAnswer(examRecordDataId, user.getUserId());
     }
 
     @ApiOperation(value = "断点续考:检查正在进行中的考试")

+ 1 - 1
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/ExamControlService.java

@@ -28,7 +28,7 @@ public interface ExamControlService {
      *
      * @param examRecordDataId
      */
-    StartAnswerInfo startAnswer(Long examRecordDataId);
+    StartAnswerInfo startAnswer(Long examRecordDataId, Long userId);
 
     /**
      * 交卷

+ 9 - 4
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/ExamControlServiceImpl.java

@@ -311,13 +311,18 @@ public class ExamControlServiceImpl implements ExamControlService {
                 new ExamProcessRecordReport(examRecordData.getId(), ExamProcess.START, examRecordData.getEnterExamTime())
         );
 
-        StartExamInfo startExamInfo = buildStartExamInfo(examRecordData.getId(), examingSession, examBean, courseBean);
-        return startExamInfo;
-
+        return buildStartExamInfo(examRecordData.getId(), examingSession, examBean, courseBean);
     }
 
     @Override
-    public StartAnswerInfo startAnswer(Long examRecordDataId) {
+    public StartAnswerInfo startAnswer(Long examRecordDataId, Long userId) {
+        Check.isNull(examRecordDataId, "examRecordDataId不能为空");
+        Check.isNull(userId, "userId不能为空");
+
+        String sequenceLockKey = Constants.EXAM_CONTROL_LOCK_PREFIX + userId;
+        // 开始考试上锁,分布式锁,系统在请求结束后会,自动释放锁,无需手动解锁
+        SequenceLockHelper.getLock(sequenceLockKey);
+
         Date now = new Date();
 
         ExamRecordData examRecordData = examRecordDataService.getExamRecordDataCache(examRecordDataId);