Преглед изворни кода

考生端异常信息完善

wangliang пре 4 година
родитељ
комит
b4ffbc38f2

+ 52 - 52
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamServiceImpl.java

@@ -201,7 +201,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
                 }
             }
             if (!allow) {
-                throw new BusinessException("考生IP不被允许");
+                throw new BusinessException(ExceptionResultEnum.EXAM_STATUS_NOT_ALLOW_IP);
             }
         }
     }
@@ -216,11 +216,11 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         TBSession tbSession = (TBSession) ServletUtil.getRequestSession();
         ExamStudentCacheBean es = teExamStudentService.getExamStudentCacheBean(examStudentId);
         if (es == null) {
-            throw new BusinessException("未找到考生");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_STUDENT);
         }
 
         if (!studentId.equals(es.getStudentId())) {
-            throw new BusinessException("考生Id和当前登录用户不一致");
+            throw new BusinessException(ExceptionResultEnum.EXAM_ID_NOT_EQUALY);
         }
         //停用
         if (es.getEnable().intValue() == 0) {
@@ -255,40 +255,40 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
             }
         }
         if (examCache.getExamCount().intValue() <= es.getAlreadyExamCount().intValue()) {
-            throw new BusinessException("没有剩余考试次数");
+            throw new BusinessException(ExceptionResultEnum.EXAM_LEFT_COUNT_IS_ZERO);
         }
         Long activityId = es.getExamActivityId();
         ExamActivityCacheBean ac = teExamActivityService.getExamActivityCacheBean(activityId);
         if (ac == null) {
-            throw new BusinessException("未找到场次");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_ACTIVITY);
         }
         Date now = new Date();
         if (ExamModeEnum.ANYTIME.equals(examCache.getMode())) {
             Long start = ac.getStartTime() - (ac.getPrepareSeconds() * 1000);
             Long end = ac.getFinishTime();
             if (now.getTime() < start) {
-                throw new BusinessException("没有到允许开考的时间");
+                throw new BusinessException(ExceptionResultEnum.NOT_ALLOW_MAX_START_TIME);
             }
             if (now.getTime() > end) {
-                throw new BusinessException("允许开考的时间已结束");
+                throw new BusinessException(ExceptionResultEnum.MAX_START_TIME_FINISHED);
             }
         } else {
             Long start = ac.getStartTime() - (ac.getPrepareSeconds() * 1000);
             Long end = ac.getStartTime() + (ac.getOpeningSeconds() * 1000);
             if (now.getTime() < start) {
-                throw new BusinessException("没有到允许开考的时间");
+                throw new BusinessException(ExceptionResultEnum.NOT_ALLOW_MAX_START_TIME);
             }
             if (now.getTime() > end) {
-                throw new BusinessException("允许开考的时间已结束");
+                throw new BusinessException(ExceptionResultEnum.MAX_START_TIME_FINISHED);
             }
         }
 
         ExamCourseCacheBean ec = teExamCourseService.getExamCourseCacheBean(es.getExamId(), es.getCourseCode());
         if (ec == null) {
-            throw new BusinessException("未找到考试科目");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_COURSE);
         }
         if (ec.getPaperIds() == null) {
-            throw new BusinessException("考试科目未绑定试卷");
+            throw new BusinessException(ExceptionResultEnum.EXAM_COURSE_OR_EXAM_PAPER_NOT_BIND);
         }
 //        if (ec.getHasAnswer() == null || ec.getHasAnswer().intValue() == 0) {
 //            throw new BusinessException("考试科目答案未补全");
@@ -297,7 +297,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         Long paperId = ec.getPaperIds().get(getPaperByWeight(ec.getPaperWeight()));
         ExamPaperCacheBean ep = teExamPaperService.getExamPaperCacheBean(paperId);
         if (ep == null) {
-            throw new BusinessException("未找到试卷:" + paperId);
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_PAPER + ":" + paperId);
         }
 //        if (StringUtils.isBlank(ep.getAnswerPath())) {
 //            throw new BusinessException("试卷答案未上传:" + paperId);
@@ -377,16 +377,16 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
 
         // 校验当前登录用户和参数一致性
         if (ExamRecordCacheUtil.getId(recordId) == null) {
-            throw new BusinessException("未找到考试记录");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD);
         }
         Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
         ExamStudentCacheBean es = (ExamStudentCacheBean) redisUtil
                 .get(RedisKeyHelper.examStudentCacheKey(examStudentId));
         if (es == null) {
-            throw new BusinessException("未找到考生");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_STUDENT);
         }
         if (!studentId.equals(es.getStudentId())) {
-            throw new BusinessException("考试记录的学生Id和当前登录用户不一致");
+            throw new BusinessException(ExceptionResultEnum.EXAM_ID_NOT_EQUALY);
         }
         //停用
         if (es.getEnable().intValue() == 0) {
@@ -396,41 +396,41 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         Long activityId = es.getExamActivityId();
         ExamActivityCacheBean ac = teExamActivityService.getExamActivityCacheBean(activityId);
         if (ac == null) {
-            throw new BusinessException("未找到场次");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_ACTIVITY);
         }
         ExamRecordStatusEnum sta = ExamRecordCacheUtil.getStatus(recordId);
         if (ExamRecordStatusEnum.FINISHED.equals(sta) || ExamRecordStatusEnum.PERSISTED.equals(sta)) {
-            throw new BusinessException("该考试已结束");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_STUDENT);
         }
         Date now = new Date();
         if (ExamModeEnum.ANYTIME.equals(exam.getMode())) {
             Long start = ac.getStartTime();
             Long end = ac.getFinishTime();
             if (now.getTime() < start) {
-                throw new BusinessException("没有到允许开考的时间");
+                throw new BusinessException(ExceptionResultEnum.NOT_ALLOW_MAX_START_TIME);
             }
             if (!ExamRecordStatusEnum.RESUME_PREPARE.equals(sta)) {//非断点进入的
                 if (now.getTime() > end) {
-                    throw new BusinessException("允许开考的时间已结束");
+                    throw new BusinessException(ExceptionResultEnum.MAX_START_TIME_FINISHED);
                 }
             }
         } else {
             Long start = ac.getStartTime();
             Long end = ac.getStartTime() + (ac.getOpeningSeconds() * 1000);
             if (now.getTime() < start) {
-                throw new BusinessException("没有到允许开考的时间");
+                throw new BusinessException(ExceptionResultEnum.NOT_ALLOW_MAX_START_TIME);
             }
             if (ExamRecordStatusEnum.RESUME_PREPARE.equals(sta)) {//断点进入的
                 //集中不启用统一收卷,考试快结束时,断点,再登录时, 时间已经超过考试截止时间,断点时,此时应该能登录继续作答
                 Integer forceFinish = ExamRecordCacheUtil.getForceFinish(recordId);
                 if (forceFinish != null && forceFinish.intValue() == 1) {
                     if (now.getTime() > end) {
-                        throw new BusinessException("允许开考的时间已结束");
+                        throw new BusinessException(ExceptionResultEnum.MAX_START_TIME_FINISHED);
                     }
                 }
             } else {
                 if (now.getTime() > end) {
-                    throw new BusinessException("允许开考的时间已结束");
+                    throw new BusinessException(ExceptionResultEnum.MAX_START_TIME_FINISHED);
                 }
             }
         }
@@ -439,28 +439,28 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         Long paperId = ExamRecordCacheUtil.getPaperId(recordId);
         ExamPaperCacheBean ep = teExamPaperService.getExamPaperCacheBean(paperId);
         if (ep == null) {
-            throw new BusinessException("未找到试卷");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_PAPER);
         }
 
         WebsocketStatusEnum websocketStatusEnum = ExamRecordCacheUtil.getClientWebsocketStatus(recordId);
         if (Objects.nonNull(websocketStatusEnum) && Objects.equals(WebsocketStatusEnum.OFF_LINE, websocketStatusEnum)) {
-            throw new BusinessException("客户端网络离线");
+            throw new BusinessException(ExceptionResultEnum.CLIENT_NET_OFFLINE);
         }
         MonitorStatusSourceEnum clientCameraStatus = ExamRecordCacheUtil.getMonitorStatus(recordId, MonitorVideoSourceEnum.CLIENT_CAMERA.name());
         if (Objects.nonNull(clientCameraStatus) && Objects.equals(MonitorStatusSourceEnum.STOP, clientCameraStatus)) {
-            throw new BusinessException("客户端摄像头离线");
+            throw new BusinessException(ExceptionResultEnum.CLIENT_CAMERA_OFFLINE);
         }
         MonitorStatusSourceEnum clientScreenStatus = ExamRecordCacheUtil.getMonitorStatus(recordId, MonitorVideoSourceEnum.CLIENT_SCREEN.name());
         if (Objects.nonNull(clientScreenStatus) && Objects.equals(MonitorStatusSourceEnum.STOP, clientScreenStatus)) {
-            throw new BusinessException("客户端屏幕离线");
+            throw new BusinessException(ExceptionResultEnum.CLIENT_SCREEN_OFFLINE);
         }
         MonitorStatusSourceEnum mobileFirstStatus = ExamRecordCacheUtil.getMonitorStatus(recordId, MonitorVideoSourceEnum.MOBILE_FIRST.name());
         if (Objects.nonNull(mobileFirstStatus) && Objects.equals(MonitorStatusSourceEnum.STOP, mobileFirstStatus)) {
-            throw new BusinessException("移动端第一机位离线");
+            throw new BusinessException(ExceptionResultEnum.MOBILE_FIRST_OFFLINE);
         }
         MonitorStatusSourceEnum mobileSecondStatus = ExamRecordCacheUtil.getMonitorStatus(recordId, MonitorVideoSourceEnum.MOBILE_SECOND.name());
         if (Objects.nonNull(mobileSecondStatus) && Objects.equals(MonitorStatusSourceEnum.STOP, mobileSecondStatus)) {
-            throw new BusinessException("移动端第二机位离线");
+            throw new BusinessException(ExceptionResultEnum.MOBILE_SECOND_OFFLINE);
         }
 
         ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
@@ -532,20 +532,20 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
 
         // 校验当前登录用户和参数一致性
         if (ExamRecordCacheUtil.getId(recordId) == null) {
-            throw new BusinessException("未找到考试记录");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD);
         }
         Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
         ExamStudentCacheBean es = (ExamStudentCacheBean) redisUtil
                 .get(RedisKeyHelper.examStudentCacheKey(examStudentId));
         if (es == null) {
-            throw new BusinessException("未找到考生");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_STUDENT);
         }
         if (!studentId.equals(es.getStudentId())) {
-            throw new BusinessException("考试记录的学生Id和当前登录用户不一致");
+            throw new BusinessException(ExceptionResultEnum.EXAM_ID_NOT_EQUALY);
         }
         ExamRecordStatusEnum sta = ExamRecordCacheUtil.getStatus(recordId);
         if (ExamRecordStatusEnum.FINISHED.equals(sta) || ExamRecordStatusEnum.PERSISTED.equals(sta)) {
-            throw new BusinessException("该考试已结束");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_STUDENT);
         }
         ExamStudentPaperStructCacheBean struct = new ExamStudentPaperStructCacheBean();
         struct.setContent(content);
@@ -567,20 +567,20 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
 
         // 校验当前登录用户和参数一致性
         if (ExamRecordCacheUtil.getId(recordId) == null) {
-            throw new BusinessException("未找到考试记录");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD);
         }
         Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
         ExamStudentCacheBean es = (ExamStudentCacheBean) redisUtil
                 .get(RedisKeyHelper.examStudentCacheKey(examStudentId));
         if (es == null) {
-            throw new BusinessException("未找到考生");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_STUDENT);
         }
         if (!studentId.equals(es.getStudentId())) {
-            throw new BusinessException("考试记录的学生Id和当前登录用户不一致");
+            throw new BusinessException(ExceptionResultEnum.EXAM_ID_NOT_EQUALY);
         }
         ExamRecordStatusEnum sta = ExamRecordCacheUtil.getStatus(recordId);
         if (ExamRecordStatusEnum.FINISHED.equals(sta) || ExamRecordStatusEnum.PERSISTED.equals(sta)) {
-            throw new BusinessException("该考试已结束");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_STUDENT);
         }
         ExamStudentAnswerCacheBean answerCache = (ExamStudentAnswerCacheBean) redisUtil.get(
                 RedisKeyHelper.examAnswerKey(recordId),
@@ -659,20 +659,20 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
 
         // 校验当前登录用户和参数一致性
         if (ExamRecordCacheUtil.getId(recordId) == null) {
-            throw new BusinessException("未找到考试记录");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD);
         }
         Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
         ExamStudentCacheBean es = (ExamStudentCacheBean) redisUtil
                 .get(RedisKeyHelper.examStudentCacheKey(examStudentId));
         if (es == null) {
-            throw new BusinessException("未找到考生");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_STUDENT);
         }
         if (!studentId.equals(es.getStudentId())) {
-            throw new BusinessException("考试记录的学生Id和当前登录用户不一致");
+            throw new BusinessException(ExceptionResultEnum.EXAM_ID_NOT_EQUALY);
         }
         ExamRecordStatusEnum sta = ExamRecordCacheUtil.getStatus(recordId);
         if (ExamRecordStatusEnum.FINISHED.equals(sta) || ExamRecordStatusEnum.PERSISTED.equals(sta)) {
-            throw new BusinessException("该考试已结束");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_STUDENT);
         }
         // 音频剩余播放次数缓存
         redisUtil.set(RedisKeyHelper.audioLeftPlayCountKey(recordId), key, count);
@@ -690,20 +690,20 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
 
         // 校验当前登录用户和参数一致性
         if (ExamRecordCacheUtil.getId(recordId) == null) {
-            throw new BusinessException("未找到考试记录");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD);
         }
         Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
         ExamStudentCacheBean es = (ExamStudentCacheBean) redisUtil
                 .get(RedisKeyHelper.examStudentCacheKey(examStudentId));
         if (es == null) {
-            throw new BusinessException("未找到考生");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_STUDENT);
         }
         if (!studentId.equals(es.getStudentId())) {
-            throw new BusinessException("考试记录的学生Id和当前登录用户不一致");
+            throw new BusinessException(ExceptionResultEnum.EXAM_ID_NOT_EQUALY);
         }
         ExamRecordStatusEnum sta = ExamRecordCacheUtil.getStatus(recordId);
         if (ExamRecordStatusEnum.FINISHED.equals(sta) || ExamRecordStatusEnum.PERSISTED.equals(sta)) {
-            throw new BusinessException("该考试已结束");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_STUDENT);
         }
 
         String filePath = "upload" + File.separator + sdf.format(new Date()) + File.separator + uuid() + "." + suffix;
@@ -745,16 +745,16 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         TBSession tbSession = (TBSession) ServletUtil.getRequestSession();
         // 校验当前登录用户和参数一致性
         if (ExamRecordCacheUtil.getId(recordId) == null) {
-            throw new BusinessException("未找到考试记录");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD);
         }
         Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
         ExamStudentCacheBean es = (ExamStudentCacheBean) redisUtil
                 .get(RedisKeyHelper.examStudentCacheKey(examStudentId));
         if (es == null) {
-            throw new BusinessException("未找到考生");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_STUDENT);
         }
         if (!studentId.equals(es.getStudentId())) {
-            throw new BusinessException("考试记录的学生Id和当前登录用户不一致");
+            throw new BusinessException(ExceptionResultEnum.EXAM_ID_NOT_EQUALY);
         }
         //停用
         if (es.getEnable().intValue() == 0) {
@@ -768,11 +768,11 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         Long paperId = ExamRecordCacheUtil.getPaperId(recordId);
         ExamPaperCacheBean ep = teExamPaperService.getExamPaperCacheBean(paperId);
         if (ep == null) {
-            throw new BusinessException("未找到试卷");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_PAPER);
         }
         ExamRecordStatusEnum sta = ExamRecordCacheUtil.getStatus(recordId);
         if (ExamRecordStatusEnum.FINISHED.equals(sta) || ExamRecordStatusEnum.PERSISTED.equals(sta)) {
-            throw new BusinessException("该考试已结束");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_STUDENT);
         }
         ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
         Integer durationSeconds = Objects.isNull(ExamRecordCacheUtil.getDurationSeconds(recordId)) ? 0 : ExamRecordCacheUtil.getDurationSeconds(recordId);
@@ -905,10 +905,10 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         ExamStudentCacheBean es = (ExamStudentCacheBean) redisUtil
                 .get(RedisKeyHelper.examStudentCacheKey(examStudentId));
         if (es == null) {
-            throw new BusinessException("未找到考生");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_STUDENT);
         }
         if (!studentId.equals(es.getStudentId())) {
-            throw new BusinessException("考试记录的学生Id和当前登录用户不一致");
+            throw new BusinessException(ExceptionResultEnum.EXAM_ID_NOT_EQUALY);
         }
 
         ExamCacheBean exam = getExamCacheBeanNative(es.getExamId());
@@ -1055,7 +1055,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         if (ExamRecordCacheUtil.getId(recordId) == null) {
             er = toeExamRecordService.getById(recordId);
             if (er == null) {
-                throw new BusinessException("未找到考试记录");
+                throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD);
             }
             ret.setDurationSeconds(er.getDurationSeconds());
             ret.setFinishTime(er.getFinishTime());

+ 10 - 9
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEMobileServiceImpl.java

@@ -22,6 +22,7 @@ import com.qmth.themis.business.util.RedisUtil;
 import com.qmth.themis.business.util.ServletUtil;
 import com.qmth.themis.business.util.SessionUtil;
 import com.qmth.themis.business.util.TencentYunUtil;
+import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.enums.Platform;
 import com.qmth.themis.common.enums.Source;
 import com.qmth.themis.common.exception.BusinessException;
@@ -62,16 +63,16 @@ public class TEMobileServiceImpl implements TEMobileService {
             ret = answerUploadAuthorization(mode, code);
         }
         if (ExamRecordCacheUtil.getId(ret.getRecordId()) == null) {
-            throw new BusinessException("考试记录不存在");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD);
         }
         ExamStudentCacheBean es = examStudentService
                 .getExamStudentCacheBean(ExamRecordCacheUtil.getExamStudentId(ret.getRecordId()));
         if (es == null) {
-            throw new BusinessException("未找到考生");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_STUDENT);
         }
         ExamRecordStatusEnum sta = ExamRecordCacheUtil.getStatus(ret.getRecordId());
         if (ExamRecordStatusEnum.FINISHED.equals(sta) || ExamRecordStatusEnum.PERSISTED.equals(sta)) {
-            throw new BusinessException("该考试已结束");
+            throw new BusinessException(ExceptionResultEnum.EXAM_ALREADY_FINISHED);
         }
         Platform platform = Platform.valueOf(ServletUtil.getRequestPlatform());
         String deviceId = ServletUtil.getRequestDeviceId();
@@ -108,7 +109,7 @@ public class TEMobileServiceImpl implements TEMobileService {
         Source monitorVideoSource = MobileAuthCacheUtil.getMonitorVideoSource(mode, code);
         Boolean monitorAudioEnable = MobileAuthCacheUtil.getMonitorAudioEnable(mode, code);
         if (MobileAuthCacheUtil.getMode(mode, code) == null) {
-            throw new BusinessException("二维码已过期");
+            throw new BusinessException(ExceptionResultEnum.QR_CODE_EXPIRE);
         }
         MobileAuthorizationMonitorBean ret = new MobileAuthorizationMonitorBean();
         ret.setRecordId(recordId);
@@ -144,7 +145,7 @@ public class TEMobileServiceImpl implements TEMobileService {
         Integer subNumber = MobileAuthCacheUtil.getSubNumber(mode, code);
         Integer subIndex = MobileAuthCacheUtil.getSubIndex(mode, code);
         if (MobileAuthCacheUtil.getMode(mode, code) == null) {
-            throw new BusinessException("二维码已过期");
+            throw new BusinessException(ExceptionResultEnum.QR_CODE_EXPIRE);
         }
         ExamStudentCacheBean es = examStudentService
                 .getExamStudentCacheBean(ExamRecordCacheUtil.getExamStudentId(recordId));
@@ -172,20 +173,20 @@ public class TEMobileServiceImpl implements TEMobileService {
                                                       String answer) {
         // 校验当前登录用户和参数一致性
         if (ExamRecordCacheUtil.getId(recordId) == null) {
-            throw new BusinessException("未找到考试记录");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD);
         }
         Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
         ExamStudentCacheBean es = (ExamStudentCacheBean) redisUtil
                 .get(RedisKeyHelper.examStudentCacheKey(examStudentId));
         if (es == null) {
-            throw new BusinessException("未找到考生");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_STUDENT);
         }
         if (!studentId.equals(es.getStudentId())) {
-            throw new BusinessException("考试记录的学生Id和当前登录用户不一致");
+            throw new BusinessException(ExceptionResultEnum.EXAM_ID_NOT_EQUALY);
         }
         ExamRecordStatusEnum sta = ExamRecordCacheUtil.getStatus(recordId);
         if (ExamRecordStatusEnum.FINISHED.equals(sta) || ExamRecordStatusEnum.PERSISTED.equals(sta)) {
-            throw new BusinessException("该考试已结束");
+            throw new BusinessException(ExceptionResultEnum.EXAM_ALREADY_FINISHED);
         }
         ExamStudentAnswerCacheBean answerCache = (ExamStudentAnswerCacheBean) redisUtil.get(
                 RedisKeyHelper.examAnswerKey(recordId),

+ 45 - 0
themis-common/src/main/java/com/qmth/themis/common/enums/ExceptionResultEnum.java

@@ -8,6 +8,51 @@ package com.qmth.themis.common.enums;
  * @Date: 2019/10/11
  */
 public enum ExceptionResultEnum {
+    /**
+     * 考生端错误
+     */
+    NOT_FOUND_EXAM_RECORD(500,500020,"未找到考试记录"),
+
+    NOT_FOUND_EXAM_STUDENT(500,500021,"未找到考生"),
+
+    EXAM_ALREADY_FINISHED(500,500022,"该考试已结束"),
+
+    EXAM_ID_NOT_EQUALY(500,500023,"考试记录的学生Id和当前登录用户不一致"),
+
+    QR_CODE_EXPIRE(500,500024,"二维码已过期"),
+
+    ORG_ID_OR_EXAM_ID_NOT_CHOOSE(500,500025,"机构id或考试id必须有一个"),
+
+    STUDENT_NOT_ALLOW_LOGIN(500,500026,"该学生正在考试,不能登录"),
+
+    EXAM_STATUS_NOT_NULL(500,500027,"考试状态不能为空"),
+
+    EXAM_STATUS_NOT_ALLOW_IP(500,500028,"考生IP不被允许"),
+
+    EXAM_LEFT_COUNT_IS_ZERO(500,500029,"没有剩余考试次数"),
+
+    NOT_FOUND_EXAM_ACTIVITY(500,500030,"未找到考试场次"),
+
+    NOT_ALLOW_MAX_START_TIME(500,500031,"没有到允许开考的时间"),
+
+    MAX_START_TIME_FINISHED(500,500032,"允许开考的时间已结束"),
+
+    NOT_FOUND_EXAM_COURSE(500,500033,"未找到考试科目"),
+
+    EXAM_COURSE_OR_EXAM_PAPER_NOT_BIND(500,500034,"考试科目未绑定试卷"),
+
+    NOT_FOUND_EXAM_PAPER(500,500035,"未找到试卷"),
+
+    CLIENT_NET_OFFLINE(500,500036,"客户端网络离线"),
+
+    CLIENT_CAMERA_OFFLINE(500,500037,"客户端摄像头离线"),
+
+    CLIENT_SCREEN_OFFLINE(500,500038,"客户端屏幕离线"),
+
+    MOBILE_FIRST_OFFLINE(500,500039,"移动端第一机位离线"),
+
+    MOBILE_SECOND_OFFLINE(500,500040,"移动端第二机位离线"),
+
     /**
      * 系统预置
      */

+ 3 - 2
themis-exam/src/main/java/com/qmth/themis/exam/api/TEMobileController.java

@@ -8,6 +8,7 @@ import java.util.concurrent.ConcurrentHashMap;
 
 import javax.annotation.Resource;
 
+import com.qmth.themis.common.enums.ExceptionResultEnum;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -85,14 +86,14 @@ public class TEMobileController {
         }
         Long esId = ExamRecordCacheUtil.getExamStudentId(param.getRecordId());
         if (ExamRecordCacheUtil.getId(param.getRecordId()) == null) {
-            throw new BusinessException("考试记录不存在");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD);
         }
         ExamRecordStatusEnum sta = ExamRecordCacheUtil.getStatus(param.getRecordId());
 //        if (ExamRecordStatusEnum.FIRST_PREPARE.equals(sta)) {
 //            throw new BusinessException("该考试未开始答题");
 //        }
         if (ExamRecordStatusEnum.FINISHED.equals(sta) || ExamRecordStatusEnum.PERSISTED.equals(sta)) {
-            throw new BusinessException("该考试已结束");
+            throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_STUDENT);
         }
         ConcurrentHashMap<Long, WebSocketOeServer> webSocketMap = WebSocketOeServer.getWebSocketMap();
         WebSocketOeServer webSocketOeServer = webSocketMap.get(param.getRecordId());

+ 3 - 3
themis-exam/src/main/java/com/qmth/themis/exam/api/TEStudentController.java

@@ -122,7 +122,7 @@ public class TEStudentController {
             examId = Long.parseLong(String.valueOf(mapParameter.get("examId")));
         }
         if (Objects.isNull(orgId) && Objects.isNull(examId)) {
-            throw new BusinessException("机构id或考试id必须有一个");
+            throw new BusinessException(ExceptionResultEnum.ORG_ID_OR_EXAM_ID_NOT_CHOOSE);
         }
         String identity = String.valueOf(mapParameter.get("identity"));
         String password = String.valueOf(mapParameter.get("password"));
@@ -148,7 +148,7 @@ public class TEStudentController {
         if (unFinishedRecordId != null) {
             WebsocketStatusEnum sta = ExamRecordCacheUtil.getClientWebsocketStatus(unFinishedRecordId);
             if (WebsocketStatusEnum.ON_LINE.equals(sta)) {
-                throw new BusinessException("该学生正在考试,不能登录");
+                throw new BusinessException(ExceptionResultEnum.STUDENT_NOT_ALLOW_LOGIN);
             }
         }
         return userLoginCommon(user, examId, orgId);
@@ -218,7 +218,7 @@ public class TEStudentController {
             //获取考试记录缓存
             ExamRecordStatusEnum status = ExamRecordCacheUtil.getStatus(recordId);
             if (Objects.isNull(status)) {
-                throw new BusinessException("考试状态不能为空");
+                throw new BusinessException(ExceptionResultEnum.EXAM_STATUS_NOT_NULL);
             }
             Long ecExamId = ExamRecordCacheUtil.getExamId(recordId);
             Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);