|
@@ -1,7 +1,19 @@
|
|
|
package com.qmth.themis.exam.api;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.qmth.themis.business.bean.exam.*;
|
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
|
import com.qmth.themis.business.dto.response.TEExamDto;
|
|
|
import com.qmth.themis.business.dto.response.TEExamResultDto;
|
|
@@ -19,18 +31,12 @@ import com.qmth.themis.mq.dto.MqDto;
|
|
|
import com.qmth.themis.mq.enums.MqTagEnum;
|
|
|
import com.qmth.themis.mq.enums.MqTopicEnum;
|
|
|
import com.qmth.themis.mq.service.MqDtoService;
|
|
|
-import io.swagger.annotations.*;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
-import javax.annotation.Resource;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.ApiParam;
|
|
|
+import io.swagger.annotations.ApiResponse;
|
|
|
+import io.swagger.annotations.ApiResponses;
|
|
|
|
|
|
@Api(tags = "考试Controller")
|
|
|
@RestController
|
|
@@ -79,7 +85,7 @@ public class TEExamController {
|
|
|
@ApiOperation(value = "开始候考")
|
|
|
@RequestMapping(value = "/prepare", method = RequestMethod.POST)
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "试卷信息")})
|
|
|
- public ExamPrepareBean prepare(@ApiParam(value = "考生ID", required = true) @RequestParam Long examStudentId) {
|
|
|
+ public Result prepare(@ApiParam(value = "考生ID", required = true) @RequestParam Long examStudentId) {
|
|
|
TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
|
|
|
String lockKey = SystemConstant.REDIS_LOCK_STUDENT_PREFIX + teStudent.getId();
|
|
|
Boolean lock = redisUtil.lock(lockKey, SystemConstant.REDIS_CACHE_TIME_OUT);
|
|
@@ -87,7 +93,7 @@ public class TEExamController {
|
|
|
throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
|
|
|
}
|
|
|
try {
|
|
|
- return teExamService.prepare(teStudent.getId(), examStudentId);
|
|
|
+ return ResultUtil.ok(teExamService.prepare(teStudent.getId(), examStudentId));
|
|
|
} finally {
|
|
|
redisUtil.releaseLock(lockKey);
|
|
|
}
|
|
@@ -96,7 +102,7 @@ public class TEExamController {
|
|
|
@ApiOperation(value = "开始考试")
|
|
|
@RequestMapping(value = "/start", method = RequestMethod.POST)
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "试卷信息")})
|
|
|
- public ExamStartBean start(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId,
|
|
|
+ public Result start(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId,
|
|
|
@ApiParam(value = "断点续考原因", required = false) @RequestParam String reason) {
|
|
|
TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
|
|
|
String lockKey = SystemConstant.REDIS_LOCK_STUDENT_PREFIX + teStudent.getId();
|
|
@@ -105,7 +111,7 @@ public class TEExamController {
|
|
|
throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
|
|
|
}
|
|
|
try {
|
|
|
- return teExamService.start(teStudent.getId(), recordId);
|
|
|
+ return ResultUtil.ok(teExamService.start(teStudent.getId(), recordId));
|
|
|
} finally {
|
|
|
redisUtil.releaseLock(lockKey);
|
|
|
}
|
|
@@ -114,7 +120,7 @@ public class TEExamController {
|
|
|
@ApiOperation(value = "上传个人试卷结构")
|
|
|
@RequestMapping(value = "/student_paper_struct/upload", method = RequestMethod.POST)
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "试卷信息")})
|
|
|
- public Long studentPaperStruct(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId,
|
|
|
+ public Result studentPaperStruct(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId,
|
|
|
@ApiParam(value = "试卷结构json字符串", required = true) @RequestParam String content) {
|
|
|
TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
|
|
|
String lockKey = SystemConstant.REDIS_LOCK_STUDENT_PREFIX + teStudent.getId();
|
|
@@ -123,7 +129,7 @@ public class TEExamController {
|
|
|
throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
|
|
|
}
|
|
|
try {
|
|
|
- return teExamService.studentPaperStruct(teStudent.getId(), recordId, content);
|
|
|
+ return ResultUtil.ok(teExamService.studentPaperStruct(teStudent.getId(), recordId, content));
|
|
|
} finally {
|
|
|
redisUtil.releaseLock(lockKey);
|
|
|
}
|
|
@@ -132,7 +138,7 @@ public class TEExamController {
|
|
|
@ApiOperation(value = "提交作答结果")
|
|
|
@RequestMapping(value = "/answer/submit", method = RequestMethod.POST)
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "试卷信息")})
|
|
|
- public Long answerSubmit(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId,
|
|
|
+ public Result answerSubmit(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId,
|
|
|
@ApiParam(value = "大题号", required = true) @RequestParam Integer mainNumber,
|
|
|
@ApiParam(value = "小题号", required = true) @RequestParam Integer subNumber,
|
|
|
@ApiParam(value = "套题子题序号", required = false) @RequestParam Integer subIndex,
|
|
@@ -149,7 +155,7 @@ public class TEExamController {
|
|
|
Long ret = teExamService.answerSubmit(teStudent.getId(), recordId, mainNumber, subNumber, subIndex, answer, version, durationSeconds);
|
|
|
//发消息计算客观分
|
|
|
calculateObjectiveScore(recordId, mainNumber, subNumber, subIndex);
|
|
|
- return ret;
|
|
|
+ return ResultUtil.ok(ret);
|
|
|
} finally {
|
|
|
redisUtil.releaseLock(lockKey);
|
|
|
}
|
|
@@ -158,7 +164,7 @@ public class TEExamController {
|
|
|
@ApiOperation(value = "更新音频剩余播放次数")
|
|
|
@RequestMapping(value = "/audio_left_play_count/submit", method = RequestMethod.POST)
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "试卷信息")})
|
|
|
- public Integer audioLeftPlayCountSubmit(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId,
|
|
|
+ public Result audioLeftPlayCountSubmit(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId,
|
|
|
@ApiParam(value = "音频标识", required = true) @RequestParam String key,
|
|
|
@ApiParam(value = "剩余播放次数", required = true) @RequestParam Integer count) {
|
|
|
TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
|
|
@@ -168,7 +174,7 @@ public class TEExamController {
|
|
|
throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
|
|
|
}
|
|
|
try {
|
|
|
- return teExamService.audioLeftPlayCountSubmit(teStudent.getId(), recordId, key, count);
|
|
|
+ return ResultUtil.ok(teExamService.audioLeftPlayCountSubmit(teStudent.getId(), recordId, key, count));
|
|
|
} finally {
|
|
|
redisUtil.releaseLock(lockKey);
|
|
|
}
|
|
@@ -177,7 +183,7 @@ public class TEExamController {
|
|
|
@ApiOperation(value = "文件上传")
|
|
|
@RequestMapping(value = "/file/upload", method = RequestMethod.POST)
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "试卷信息")})
|
|
|
- public ExamFileUploadBean fileUpload(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId,
|
|
|
+ public Result fileUpload(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId,
|
|
|
@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file,
|
|
|
@ApiParam(value = "后缀名", required = true) @RequestParam String suffix,
|
|
|
@ApiParam(value = "md5", required = true) @RequestParam String md5) {
|
|
@@ -188,7 +194,7 @@ public class TEExamController {
|
|
|
throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
|
|
|
}
|
|
|
try {
|
|
|
- return teExamService.fileUpload(teStudent.getId(), recordId, file, suffix, md5);
|
|
|
+ return ResultUtil.ok(teExamService.fileUpload(teStudent.getId(), recordId, file, suffix, md5));
|
|
|
} finally {
|
|
|
redisUtil.releaseLock(lockKey);
|
|
|
}
|
|
@@ -197,7 +203,7 @@ public class TEExamController {
|
|
|
@ApiOperation(value = "断点恢复")
|
|
|
@RequestMapping(value = "/resume", method = RequestMethod.POST)
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "试卷信息")})
|
|
|
- public ExamResumeBean resume(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId) {
|
|
|
+ public Result resume(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId) {
|
|
|
TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
|
|
|
String lockKey = SystemConstant.REDIS_LOCK_STUDENT_PREFIX + teStudent.getId();
|
|
|
Boolean lock = redisUtil.lock(lockKey, SystemConstant.REDIS_CACHE_TIME_OUT);
|
|
@@ -205,7 +211,7 @@ public class TEExamController {
|
|
|
throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
|
|
|
}
|
|
|
try {
|
|
|
- return teExamService.resume(teStudent.getId(), recordId);
|
|
|
+ return ResultUtil.ok(teExamService.resume(teStudent.getId(), recordId));
|
|
|
} finally {
|
|
|
redisUtil.releaseLock(lockKey);
|
|
|
}
|
|
@@ -214,7 +220,7 @@ public class TEExamController {
|
|
|
@ApiOperation(value = "结束考试")
|
|
|
@RequestMapping(value = "/finish", method = RequestMethod.POST)
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "试卷信息")})
|
|
|
- public ExamFinishBean finish(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId,
|
|
|
+ public Result finish(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId,
|
|
|
@ApiParam(value = "结束类型", required = true) @RequestParam String type,
|
|
|
@ApiParam(value = "总用时秒数", required = true) @RequestParam Integer durationSeconds) {
|
|
|
TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
|
|
@@ -224,7 +230,7 @@ public class TEExamController {
|
|
|
throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
|
|
|
}
|
|
|
try {
|
|
|
- return teExamService.finish(teStudent.getId(), recordId, type, durationSeconds);
|
|
|
+ return ResultUtil.ok(teExamService.finish(teStudent.getId(), recordId, type, durationSeconds));
|
|
|
} finally {
|
|
|
redisUtil.releaseLock(lockKey);
|
|
|
}
|
|
@@ -244,7 +250,7 @@ public class TEExamController {
|
|
|
@ApiOperation(value = "查询交卷结果")
|
|
|
@RequestMapping(value = "/result", method = RequestMethod.POST)
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "试卷信息")})
|
|
|
- public ExamResultBean result(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId) {
|
|
|
+ public Result result(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId) {
|
|
|
TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
|
|
|
String lockKey = SystemConstant.REDIS_LOCK_STUDENT_PREFIX + teStudent.getId();
|
|
|
Boolean lock = redisUtil.lock(lockKey, SystemConstant.REDIS_CACHE_TIME_OUT);
|
|
@@ -252,7 +258,7 @@ public class TEExamController {
|
|
|
throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
|
|
|
}
|
|
|
try {
|
|
|
- return teExamService.result(teStudent.getId(), recordId);
|
|
|
+ return ResultUtil.ok(teExamService.result(teStudent.getId(), recordId));
|
|
|
} finally {
|
|
|
redisUtil.releaseLock(lockKey);
|
|
|
}
|