Bläddra i källkod

新加切屏接口,并调整系统通知命名规范

lideyin 4 år sedan
förälder
incheckning
2f58b486c3

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

@@ -90,7 +90,6 @@ public class ExamControlController extends ControllerSupport {
     public void startAnswer(@RequestParam @ApiParam(value = "考试记录id") Long examRecordDataId) {
         User user = getAccessUser();
         String sequenceLockKey = Constants.EXAM_CONTROL_LOCK_PREFIX + user.getUserId();
-        StartExamInfo startExamInfo;
         // 开始考试上锁,分布式锁,系统在请求结束后会,自动释放锁,无需手动解锁
         SequenceLockHelper.getLock(sequenceLockKey);
         Check.isNull(examRecordDataId, "examRecordDataId不能为空");
@@ -439,4 +438,19 @@ public class ExamControlController extends ControllerSupport {
     public String getQrCode(@RequestBody GetQrCodeReq req) {
         return examControlService.getQrCode(req, getAccessUser());
     }
+
+    /**
+     * 记录切换屏幕
+     */
+    @ApiOperation(value = "记录切换屏幕次数")
+    @GetMapping("/switchScreen")
+    public void switchScreen(@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不能为空");
+
+        examControlService.switchScreen(examRecordDataId);
+    }
 }

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

@@ -91,4 +91,11 @@ public interface ExamControlService {
      * @return
      */
     String getQrCode(GetQrCodeReq req, User user);
+
+    /**
+     * 记录切换屏幕次数
+     *
+     * @param examRecordDataId
+     */
+    void switchScreen(Long examRecordDataId);
 }

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

@@ -380,7 +380,7 @@ public class ExamControlServiceImpl implements ExamControlService {
         }
 
         ExamSettingsCacheBean examSettingsCacheBean = ExamCacheTransferHelper.getCachedExam(examStudent.getExamId(),
-                examStudent.getStudentId(),examStudent.getExamStageId());
+                examStudent.getStudentId(), examStudent.getExamStageId());
 
         StudentCacheBean studentCacheBean = CacheHelper.getStudent(examStudent.getStudentId());
 
@@ -913,6 +913,26 @@ public class ExamControlServiceImpl implements ExamControlService {
         return qrStr;
     }
 
+    /**
+     * 记录切换屏幕次数
+     *
+     * @param examRecordDataId
+     */
+    @Override
+    public void switchScreen(Long examRecordDataId) {
+        ExamRecordDataEntity examRecordDataEntity =
+                GlobalHelper.getEntity(examRecordDataRepo, examRecordDataId, ExamRecordDataEntity.class);
+        if (null == examRecordDataEntity) {
+            throw new StatusException("100001", "找不到相关考试记录");
+        }
+
+        //更新考试记录缓存
+        ExamRecordData examRecordData = examRecordDataService.getExamRecordDataCache(examRecordDataId);
+        int switchScreenCount = null == examRecordData.getSwitchScreenCount() ? 0 : examRecordData.getSwitchScreenCount();
+        examRecordData.setSwitchScreenCount(++switchScreenCount);
+        examRecordDataService.saveExamRecordDataCache(examRecordDataId, examRecordData);
+    }
+
     /**
      * @param bucketName //不能为空
      * @param expiration //不能为空
@@ -1004,7 +1024,7 @@ public class ExamControlServiceImpl implements ExamControlService {
     private ExamSettingsCacheBean checkExam(Long examId, Long studentId, Long examStageId) {
 
         // 学习中心特殊考试配置(是否禁考,开考时间可以特殊设置)
-        ExamSettingsCacheBean examBean = ExamCacheTransferHelper.getCachedExam(examId, studentId,examStageId);
+        ExamSettingsCacheBean examBean = ExamCacheTransferHelper.getCachedExam(examId, studentId, examStageId);
 
         // 如果启用了了特殊设置,并且无特殊设置时结束考试 配置 设置为true..且实际未设置特殊设置则不允许考试
         ExamPropertyCacheBean limitedIfNoSpecialSettings = ExamCacheTransferHelper.getDefaultCachedExamProperty(examId,