|
@@ -3,6 +3,7 @@ package com.qxgmat.controller.api;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.nuliji.tools.*;
|
|
|
+import com.nuliji.tools.exception.AuthException;
|
|
|
import com.nuliji.tools.exception.ParameterException;
|
|
|
import com.qxgmat.data.constants.enums.QuestionType;
|
|
|
import com.qxgmat.data.constants.enums.ServiceKey;
|
|
@@ -503,13 +504,17 @@ public class QuestionController {
|
|
|
@ApiOperation(value = "获取题目详情", notes = "根据题目序号获取题目", httpMethod = "GET")
|
|
|
public Response<UserQuestionBaseDto> base(
|
|
|
@RequestParam(required = true) Integer userReportId,
|
|
|
- @RequestParam(required = true) Integer no
|
|
|
+ @RequestParam(required = true) Integer no,
|
|
|
+ @RequestParam(required = false) String stage
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ if (user == null) {
|
|
|
+ throw new AuthException("请先登录");
|
|
|
+ }
|
|
|
if (no == null || no == 0){
|
|
|
no = 1;
|
|
|
}
|
|
|
- UserQuestion userQuestion = userQuestionService.getByReportAndNo(user.getId(), userReportId, no);
|
|
|
+ UserQuestion userQuestion = userQuestionService.getByReportAndNo(user.getId(), userReportId, no, stage);
|
|
|
UserQuestionBaseDto dto = Transform.convert(userQuestion, UserQuestionBaseDto.class);
|
|
|
|
|
|
return ResponseHelp.success(dto);
|
|
@@ -606,6 +611,9 @@ public class QuestionController {
|
|
|
@RequestParam(required = true) Integer paperId
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ if (user == null) {
|
|
|
+ throw new AuthException("请先登录");
|
|
|
+ }
|
|
|
UserPaper paper = questionFlowService.paper(user.getId(), PaperOrigin.EXERCISE, paperId);
|
|
|
PaperBaseDto paperDto = Transform.convert(paper, PaperBaseDto.class);
|
|
|
|
|
@@ -618,6 +626,9 @@ public class QuestionController {
|
|
|
@RequestParam(required = true) Integer paperId
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ if (user == null) {
|
|
|
+ throw new AuthException("请先登录");
|
|
|
+ }
|
|
|
UserPaper paper = questionFlowService.paper(user.getId(), PaperOrigin.EXAMINATION, paperId);
|
|
|
PaperBaseDto paperDto = Transform.convert(paper, PaperBaseDto.class);
|
|
|
|
|
@@ -630,6 +641,9 @@ public class QuestionController {
|
|
|
@RequestParam(required = true) Integer userReportId
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ if (user == null) {
|
|
|
+ throw new AuthException("请先登录");
|
|
|
+ }
|
|
|
UserReportRelation report = questionFlowService.baseReport(user.getId(), userReportId);
|
|
|
|
|
|
UserReportBaseDto userReportDto = Transform.convert(report, UserReportBaseDto.class);
|
|
@@ -642,6 +656,9 @@ public class QuestionController {
|
|
|
@RequestParam(required = true) Integer userReportId
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ if (user == null) {
|
|
|
+ throw new AuthException("请先登录");
|
|
|
+ }
|
|
|
UserReportRelation report = questionFlowService.baseReport(user.getId(), userReportId);
|
|
|
|
|
|
UserReportDetailDto userReportDto = Transform.convert(report, UserReportDetailDto.class);
|
|
@@ -659,6 +676,9 @@ public class QuestionController {
|
|
|
@RequestParam(required = true) Integer userReportId
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ if (user == null) {
|
|
|
+ throw new AuthException("请先登录");
|
|
|
+ }
|
|
|
List<UserQuestion> userQuestionList = questionFlowService.listByReport(user.getId(), userReportId);
|
|
|
List<UserQuestionExtendDto> userQuestionDtos = Transform.convert(userQuestionList, UserQuestionExtendDto.class);
|
|
|
|
|
@@ -681,6 +701,9 @@ public class QuestionController {
|
|
|
@ApiOperation(value = "开始: 模考", notes = "提交考试设置", httpMethod = "POST")
|
|
|
public Response<UserReportBaseDto> startExamination(@RequestBody @Validated ExaminationStartDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ if (user == null) {
|
|
|
+ throw new AuthException("请先登录");
|
|
|
+ }
|
|
|
// 判断是否是cat模考,并且有模考权限
|
|
|
ExaminationPaper examinationPaper = examinationPaperService.get(dto.getPaperId());
|
|
|
if(examinationService.isCat(examinationPaper)){
|
|
@@ -701,6 +724,9 @@ public class QuestionController {
|
|
|
@ApiOperation(value = "开始: 练习", notes = "提交考试设置", httpMethod = "POST")
|
|
|
public Response<UserReportBaseDto> startExercise(@RequestBody @Validated ExerciseStartDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ if (user == null) {
|
|
|
+ throw new AuthException("请先登录");
|
|
|
+ }
|
|
|
JSONObject setting = new JSONObject();
|
|
|
setting.put("disorder", dto.getDisorder());
|
|
|
UserReport report = questionFlowService.start(user.getId(), PaperOrigin.EXERCISE, dto.getPaperId(), setting);
|
|
@@ -712,6 +738,9 @@ public class QuestionController {
|
|
|
@ApiOperation(value = "开始: 预习作业", notes = "提交考试设置", httpMethod = "POST")
|
|
|
public Response<UserReportBaseDto> startPreview(@RequestBody @Validated PreviewStartDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ if (user == null) {
|
|
|
+ throw new AuthException("请先登录");
|
|
|
+ }
|
|
|
JSONObject setting = new JSONObject();
|
|
|
setting.put("disorder", dto.getDisorder());
|
|
|
UserReportRelation report = questionFlowService.start(user.getId(), PaperOrigin.PREVIEW, dto.getPaperId(), setting);
|
|
@@ -727,6 +756,9 @@ public class QuestionController {
|
|
|
@RequestParam(required = true) Integer paperId
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ if (user == null) {
|
|
|
+ throw new AuthException("请先登录");
|
|
|
+ }
|
|
|
UserPaper paper = questionFlowService.paper(user.getId(), PaperOrigin.TEXTBOOK, paperId);
|
|
|
|
|
|
PaperBaseDto paperDto = Transform.convert(paper, PaperBaseDto.class);
|
|
@@ -738,6 +770,9 @@ public class QuestionController {
|
|
|
@ApiOperation(value = "开始: 机经", notes = "提交考试设置", httpMethod = "POST")
|
|
|
public Response<UserReportBaseDto> startTextbook(@RequestBody @Validated TextbookStartDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ if (user == null) {
|
|
|
+ throw new AuthException("请先登录");
|
|
|
+ }
|
|
|
JSONObject setting = new JSONObject();
|
|
|
setting.put("disorder", dto.getDisorder());
|
|
|
UserReportRelation report = questionFlowService.start(user.getId(), PaperOrigin.TEXTBOOK, dto.getPaperId(), setting);
|
|
@@ -753,6 +788,9 @@ public class QuestionController {
|
|
|
@RequestParam(required = true) Integer paperId
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ if (user == null) {
|
|
|
+ throw new AuthException("请先登录");
|
|
|
+ }
|
|
|
UserPaper paper = questionFlowService.paper(user.getId(), PaperOrigin.SENTENCE, paperId);
|
|
|
|
|
|
PaperBaseDto paperDto = Transform.convert(paper, PaperBaseDto.class);
|
|
@@ -764,6 +802,9 @@ public class QuestionController {
|
|
|
@ApiOperation(value = "开始: 长难句", notes = "提交考试设置", httpMethod = "POST")
|
|
|
public Response<UserReportBaseDto> startSentence(@RequestBody @Validated SentenceStartDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ if (user == null) {
|
|
|
+ throw new AuthException("请先登录");
|
|
|
+ }
|
|
|
JSONObject setting = new JSONObject();
|
|
|
UserReportRelation report = questionFlowService.start(user.getId(), PaperOrigin.SENTENCE, dto.getPaperId(), setting);
|
|
|
|
|
@@ -778,6 +819,9 @@ public class QuestionController {
|
|
|
@RequestParam(required = true) Integer paperId
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ if (user == null) {
|
|
|
+ throw new AuthException("请先登录");
|
|
|
+ }
|
|
|
UserPaper paper = userPaperService.get(paperId);
|
|
|
if (!paper.getPaperOrigin().equals(PaperOrigin.ERROR.key)){
|
|
|
throw new ParameterException("试卷不存在");
|
|
@@ -794,6 +838,9 @@ public class QuestionController {
|
|
|
@ApiOperation(value = "开始: 错题组卷", notes = "提交考试设置", httpMethod = "POST")
|
|
|
public Response<UserReportBaseDto> startError(@RequestBody @Validated PreviewStartDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ if (user == null) {
|
|
|
+ throw new AuthException("请先登录");
|
|
|
+ }
|
|
|
JSONObject setting = new JSONObject();
|
|
|
setting.put("disorder", dto.getDisorder());
|
|
|
UserReportRelation report = questionFlowService.start(user.getId(), PaperOrigin.ERROR, dto.getPaperId(), setting);
|
|
@@ -809,6 +856,9 @@ public class QuestionController {
|
|
|
@RequestParam(required = true) Integer paperId
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ if (user == null) {
|
|
|
+ throw new AuthException("请先登录");
|
|
|
+ }
|
|
|
UserPaper paper = userPaperService.get(paperId);
|
|
|
if (!paper.getPaperOrigin().equals(PaperOrigin.COLLECT.key)){
|
|
|
throw new ParameterException("试卷不存在");
|
|
@@ -825,6 +875,9 @@ public class QuestionController {
|
|
|
@ApiOperation(value = "开始: 收藏组卷", notes = "提交考试设置", httpMethod = "POST")
|
|
|
public Response<UserReportBaseDto> startCollect(@RequestBody @Validated PreviewStartDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ if (user == null) {
|
|
|
+ throw new AuthException("请先登录");
|
|
|
+ }
|
|
|
JSONObject setting = new JSONObject();
|
|
|
setting.put("disorder", dto.getDisorder());
|
|
|
UserReportRelation report = questionFlowService.start(user.getId(), PaperOrigin.COLLECT, dto.getPaperId(), setting);
|
|
@@ -838,6 +891,9 @@ public class QuestionController {
|
|
|
@ApiOperation(value = "继续做题", notes = "获取报告信息", httpMethod = "POST")
|
|
|
public Response<UserReportBaseDto> continueReport(@RequestBody @Validated ReportContinueDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ if (user == null) {
|
|
|
+ throw new AuthException("请先登录");
|
|
|
+ }
|
|
|
UserReportRelation report = questionFlowService.continueReport(user.getId(), dto.getUserReportId());
|
|
|
|
|
|
UserReportBaseDto userReportBaseDto = Transform.convert(report, UserReportBaseDto.class);
|
|
@@ -849,6 +905,9 @@ public class QuestionController {
|
|
|
@ApiOperation(value = "获取下一题", notes = "获取下一题", httpMethod = "POST")
|
|
|
public Response<UserQuestionBaseDto> next(@RequestBody @Validated ReportNextDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ if (user == null) {
|
|
|
+ throw new AuthException("请先登录");
|
|
|
+ }
|
|
|
UserQuestion userQuestion = questionFlowService.next(user.getId(), dto.getUserReportId());
|
|
|
if (userQuestion == null) {
|
|
|
throw new ParameterException("finish");
|
|
@@ -874,6 +933,9 @@ public class QuestionController {
|
|
|
@ApiOperation(value = "提交题目答案", notes = "提交题目", httpMethod = "POST")
|
|
|
public Response<Boolean> submit(@RequestBody @Validated QuestionSubmitDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ if (user == null) {
|
|
|
+ throw new AuthException("请先登录");
|
|
|
+ }
|
|
|
UserQuestion userQuestion = userQuestionService.get(dto.getUserQuestionId());
|
|
|
if (userQuestion == null){
|
|
|
throw new ParameterException("做题不存在");
|
|
@@ -889,6 +951,9 @@ public class QuestionController {
|
|
|
@ApiOperation(value = "完成考试", notes = "完成考试", httpMethod = "POST")
|
|
|
public Response<Boolean> finish(@RequestBody @Validated ReportFinishDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ if (user == null) {
|
|
|
+ throw new AuthException("请先登录");
|
|
|
+ }
|
|
|
|
|
|
Boolean result = questionFlowService.finish(user.getId(), dto.getUserReportId());
|
|
|
return ResponseHelp.success(result);
|
|
@@ -898,6 +963,10 @@ public class QuestionController {
|
|
|
@ApiOperation(value = "本阶段完成", notes = "结束当前阶段: 达到阶段时间时调用,然后继续调用next", httpMethod = "POST")
|
|
|
public Response<Boolean> stage(@RequestBody @Validated ReportStageDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ if (user == null) {
|
|
|
+ throw new AuthException("请先登录");
|
|
|
+ }
|
|
|
+
|
|
|
Boolean result = questionFlowService.stage(user.getId(), dto.getUserReportId());
|
|
|
return ResponseHelp.success(result);
|
|
|
}
|
|
@@ -906,6 +975,9 @@ public class QuestionController {
|
|
|
@ApiOperation(value = "重置考试", notes = "重置考试", httpMethod = "POST")
|
|
|
public Response<Boolean> restart(@RequestBody @Validated PaperRestartDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ if (user == null) {
|
|
|
+ throw new AuthException("请先登录");
|
|
|
+ }
|
|
|
|
|
|
questionFlowService.restart(dto.getUserPaperId(), user.getId());
|
|
|
return ResponseHelp.success(true);
|
|
@@ -915,6 +987,9 @@ public class QuestionController {
|
|
|
@ApiOperation(value = "重置整套模拟卷", notes = "重置考试", httpMethod = "POST")
|
|
|
public Response<Boolean> resetCat() {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ if (user == null) {
|
|
|
+ throw new AuthException("请先登录");
|
|
|
+ }
|
|
|
|
|
|
UserService userService = userServiceService.getServiceBase(user.getId(), ServiceKey.QX_CAT);
|
|
|
if (userService == null){
|