|
@@ -4,6 +4,7 @@ package com.qxgmat.controller.api;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.github.pagehelper.Page;
|
|
|
import com.nuliji.tools.*;
|
|
|
+import com.nuliji.tools.exception.ParameterException;
|
|
|
import com.qxgmat.data.constants.enums.logic.ExerciseLogic;
|
|
|
import com.qxgmat.data.constants.enums.module.PaperModule;
|
|
|
import com.qxgmat.data.constants.enums.module.PayModule;
|
|
@@ -18,10 +19,7 @@ import com.qxgmat.dto.extend.UserHomeworkPreviewExtendDto;
|
|
|
import com.qxgmat.dto.request.*;
|
|
|
import com.qxgmat.dto.response.*;
|
|
|
import com.qxgmat.help.ShiroHelp;
|
|
|
-import com.qxgmat.service.ExercisePaperService;
|
|
|
-import com.qxgmat.service.HomeworkPreviewService;
|
|
|
-import com.qxgmat.service.UserCollectQuestionService;
|
|
|
-import com.qxgmat.service.UserQuestionService;
|
|
|
+import com.qxgmat.service.*;
|
|
|
import com.qxgmat.service.extend.QuestionFlowService;
|
|
|
import com.qxgmat.service.inline.*;
|
|
|
import io.swagger.annotations.Api;
|
|
@@ -69,6 +67,12 @@ public class QuestionController {
|
|
|
private UserPayService userPayService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private UserReportService userReportService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserPaperService userPaperService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private QuestionFlowService questionFlowService;
|
|
|
|
|
|
@RequestMapping(value = "/class/process", method = RequestMethod.GET)
|
|
@@ -144,7 +148,7 @@ public class QuestionController {
|
|
|
return ResponseHelp.success(exercisePaperService.groupPlace());
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/exercise/paper", method = RequestMethod.GET)
|
|
|
+ @RequestMapping(value = "/exercise/list", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "练习组卷列表", httpMethod = "GET")
|
|
|
public Response<PageMessage<UserExercisePaperExtendDto>> listExercisePaper(
|
|
|
@RequestParam(required = false, defaultValue = "1") int page,
|
|
@@ -186,7 +190,7 @@ public class QuestionController {
|
|
|
return ResponseHelp.success(p, page, size, p.getTotal());
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/examination/paper", method = RequestMethod.GET)
|
|
|
+ @RequestMapping(value = "/examination/list", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "模考组卷列表", httpMethod = "GET")
|
|
|
public Response<PageMessage<ExercisePaper>> examinationPaperList(
|
|
|
@RequestParam(required = false, defaultValue = "1") int page,
|
|
@@ -199,56 +203,168 @@ public class QuestionController {
|
|
|
return ResponseHelp.success(p, page, size, p.getTotal());
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/detail", method = RequestMethod.GET)
|
|
|
+ @RequestMapping(value = "/question/detail", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "获取题目详情", notes = "获取题目详情", httpMethod = "GET")
|
|
|
public Response<UserQuestionDetailDto> detail(
|
|
|
- @RequestParam(required = false) String userQuestionId
|
|
|
+ @RequestParam(required = true, name="id") Integer userQuestionId
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+ // todo 获取数据
|
|
|
+
|
|
|
return ResponseHelp.success(null);
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping(value = "/exercise/paper", method = RequestMethod.GET)
|
|
|
+ @ApiOperation(value = "获取练习卷", notes = "获取练习卷", httpMethod = "GET")
|
|
|
+ public Response<PaperBaseDto> detailExercise(
|
|
|
+ @RequestParam(required = true, name="id") Integer paperId
|
|
|
+ ) {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+ ExercisePaper paper = exercisePaperService.get(paperId);
|
|
|
+ PaperBaseDto paperDto = Transform.convert(paper, PaperBaseDto.class);
|
|
|
+
|
|
|
+ return ResponseHelp.success(paperDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/report/base", method = RequestMethod.GET)
|
|
|
+ @ApiOperation(value = "获取练习记录", notes = "获取练习卷", httpMethod = "GET")
|
|
|
+ public Response<UserReportBaseDto> baseReport(
|
|
|
+ @RequestParam(required = true, name="id") Integer userReportId
|
|
|
+ ) {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+ UserReportRelation report = questionFlowService.baseReport(user.getId(), userReportId);
|
|
|
+
|
|
|
+ UserReportBaseDto userReportDto = Transform.convert(report, UserReportBaseDto.class);
|
|
|
+
|
|
|
+ return ResponseHelp.success(userReportDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/report/detail", method = RequestMethod.GET)
|
|
|
+ @ApiOperation(value = "获取练习详细记录", notes = "获取练习卷", httpMethod = "GET")
|
|
|
+ public Response<UserReportDetailDto> detailReport(
|
|
|
+ @RequestParam(required = true, name="id") Integer userReportId
|
|
|
+ ) {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+ UserReportRelation report = questionFlowService.baseReport(user.getId(), userReportId);
|
|
|
+
|
|
|
+ UserReportDetailDto userReportDto = Transform.convert(report, UserReportDetailDto.class);
|
|
|
+
|
|
|
+ return ResponseHelp.success(userReportDto);
|
|
|
+ }
|
|
|
+
|
|
|
@RequestMapping(value = "/exercise/start", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "开始: 练习", notes = "提交考试设置", httpMethod = "POST")
|
|
|
- public Response<UserReportDto> startExercise(@RequestBody @Validated ExerciseStartDto dto) {
|
|
|
+ public Response<UserReportBaseDto> startExercise(@RequestBody @Validated ExerciseStartDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
JSONObject setting = new JSONObject();
|
|
|
setting.put("disorder", dto.getDisorder());
|
|
|
UserReport report = questionFlowService.start(user.getId(), PaperModule.HOMEWORK_PREVIEW, dto.getPaperId(), setting);
|
|
|
|
|
|
- return ResponseHelp.success(Transform.convert(report, UserReportDto.class));
|
|
|
+ return ResponseHelp.success(Transform.convert(report, UserReportBaseDto.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/preview/paper", method = RequestMethod.GET)
|
|
|
+ @ApiOperation(value = "获取预习作业", notes = "获取预习作业", httpMethod = "GET")
|
|
|
+ public Response<PaperBaseDto> detailPreview(
|
|
|
+ @RequestParam(required = true, name="id") Integer paperId
|
|
|
+ ) {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+ HomeworkPreview preview = homeworkPreviewService.get(paperId);
|
|
|
+ PaperBaseDto paperDto = Transform.convert(preview, PaperBaseDto.class);
|
|
|
+
|
|
|
+ return ResponseHelp.success(paperDto);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/preview/start", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "开始: 预习作业", notes = "提交考试设置", httpMethod = "POST")
|
|
|
- public Response<UserReportDto> startPreview(@RequestBody @Validated PreviewStartDto dto) {
|
|
|
+ public Response<UserReportBaseDto> startPreview(@RequestBody @Validated PreviewStartDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
JSONObject setting = new JSONObject();
|
|
|
setting.put("disorder", dto.getDisorder());
|
|
|
UserReportRelation report = questionFlowService.start(user.getId(), PaperModule.HOMEWORK_PREVIEW, dto.getPaperId(), setting);
|
|
|
|
|
|
- UserReportDto userReportDto = Transform.convert(report, UserReportDto.class);
|
|
|
+ UserReportBaseDto userReportBaseDto = Transform.convert(report, UserReportBaseDto.class);
|
|
|
|
|
|
- return ResponseHelp.success(userReportDto);
|
|
|
+ return ResponseHelp.success(userReportBaseDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/error/paper", method = RequestMethod.GET)
|
|
|
+ @ApiOperation(value = "获取错题组卷", notes = "获取错题组卷", httpMethod = "GET")
|
|
|
+ public Response<PaperBaseDto> detailError(
|
|
|
+ @RequestParam(required = true, name="id") Integer paperId
|
|
|
+ ) {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+ UserPaper paper = userPaperService.get(paperId);
|
|
|
+ if (!paper.getModule().equals(PaperModule.ERROR.key)){
|
|
|
+ throw new ParameterException("试卷不存在");
|
|
|
+ }
|
|
|
+ if (!paper.getUserId().equals(user.getId())){
|
|
|
+ throw new ParameterException("试卷不存在");
|
|
|
+ }
|
|
|
+ PaperBaseDto paperDto = Transform.convert(paper, PaperBaseDto.class);
|
|
|
+
|
|
|
+ return ResponseHelp.success(paperDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/error/start", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "开始: 错题组卷", notes = "提交考试设置", httpMethod = "POST")
|
|
|
+ public Response<UserReportBaseDto> startError(@RequestBody @Validated PreviewStartDto dto) {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+ JSONObject setting = new JSONObject();
|
|
|
+ setting.put("disorder", dto.getDisorder());
|
|
|
+ UserReportRelation report = questionFlowService.start(user.getId(), PaperModule.ERROR, dto.getPaperId(), setting);
|
|
|
+
|
|
|
+ UserReportBaseDto userReportBaseDto = Transform.convert(report, UserReportBaseDto.class);
|
|
|
+
|
|
|
+ return ResponseHelp.success(userReportBaseDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/collect/paper", method = RequestMethod.GET)
|
|
|
+ @ApiOperation(value = "获取收藏组卷", notes = "获取收藏组卷", httpMethod = "GET")
|
|
|
+ public Response<PaperBaseDto> detailCollect(
|
|
|
+ @RequestParam(required = true, name="id") Integer paperId
|
|
|
+ ) {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+ UserPaper paper = userPaperService.get(paperId);
|
|
|
+ if (!paper.getModule().equals(PaperModule.COLLECT.key)){
|
|
|
+ throw new ParameterException("试卷不存在");
|
|
|
+ }
|
|
|
+ if (!paper.getUserId().equals(user.getId())){
|
|
|
+ throw new ParameterException("试卷不存在");
|
|
|
+ }
|
|
|
+ PaperBaseDto paperDto = Transform.convert(paper, PaperBaseDto.class);
|
|
|
+
|
|
|
+ return ResponseHelp.success(paperDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/collect/start", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "开始: 收藏组卷", notes = "提交考试设置", httpMethod = "POST")
|
|
|
+ public Response<UserReportBaseDto> startCollect(@RequestBody @Validated PreviewStartDto dto) {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+ JSONObject setting = new JSONObject();
|
|
|
+ setting.put("disorder", dto.getDisorder());
|
|
|
+ UserReportRelation report = questionFlowService.start(user.getId(), PaperModule.COLLECT, dto.getPaperId(), setting);
|
|
|
+
|
|
|
+ UserReportBaseDto userReportBaseDto = Transform.convert(report, UserReportBaseDto.class);
|
|
|
+
|
|
|
+ return ResponseHelp.success(userReportBaseDto);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/continue", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "继续做题", notes = "获取报告信息", httpMethod = "POST")
|
|
|
- public Response<UserReportDto> continueReport(@RequestBody @Validated ReportContinueDto dto) {
|
|
|
+ public Response<UserReportBaseDto> continueReport(@RequestBody @Validated ReportContinueDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
UserReportRelation report = questionFlowService.continueReport(user.getId(), dto.getUserReportId());
|
|
|
|
|
|
- UserReportDto userReportDto = Transform.convert(report, UserReportDto.class);
|
|
|
+ UserReportBaseDto userReportBaseDto = Transform.convert(report, UserReportBaseDto.class);
|
|
|
|
|
|
- return ResponseHelp.success(userReportDto);
|
|
|
+ return ResponseHelp.success(userReportBaseDto);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/next", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "获取下一题", notes = "获取下一题", httpMethod = "POST")
|
|
|
public Response<UserQuestionBaseDto> next(@RequestBody @Validated ReportNextDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
- // 根据对应paper获取,以及设定的setting获取下一题
|
|
|
-
|
|
|
UserQuestion userQuestion = questionFlowService.next(user.getId(), dto.getUserReportId());
|
|
|
UserQuestionBaseDto baseDto = Transform.convert(userQuestion, UserQuestionBaseDto.class);
|
|
|
|
|
@@ -264,7 +380,6 @@ public class QuestionController {
|
|
|
// 绑定collect
|
|
|
baseDto.setCollect(userCollectQuestionService.getByUserAndQuestion(user.getId(), userQuestion.getQuestionId()) != null);
|
|
|
|
|
|
-
|
|
|
return ResponseHelp.success(baseDto);
|
|
|
}
|
|
|
|
|
@@ -291,7 +406,6 @@ public class QuestionController {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
|
|
|
questionFlowService.restart(dto.getUserPaperId(), user.getId());
|
|
|
-
|
|
|
return ResponseHelp.success(true);
|
|
|
}
|
|
|
}
|