|
@@ -3,26 +3,31 @@ package com.qxgmat.controller.api;
|
|
|
|
|
|
import com.github.pagehelper.Page;
|
|
|
import com.nuliji.tools.*;
|
|
|
-import com.qxgmat.data.dao.entity.ExercisePaper;
|
|
|
-import com.qxgmat.data.dao.entity.User;
|
|
|
-import com.qxgmat.data.dao.entity.UserClass;
|
|
|
+import com.qxgmat.data.constants.enums.logic.ExerciseLogic;
|
|
|
+import com.qxgmat.data.constants.enums.module.PayModule;
|
|
|
+import com.qxgmat.data.dao.entity.*;
|
|
|
+import com.qxgmat.data.relation.entity.UserExercisePaperRelation;
|
|
|
import com.qxgmat.data.relation.entity.UserHomeworkPreviewRelation;
|
|
|
+import com.qxgmat.dto.extend.UserExercisePaperExtendDto;
|
|
|
import com.qxgmat.dto.extend.UserHomeworkPreviewExtendDto;
|
|
|
+import com.qxgmat.dto.request.*;
|
|
|
import com.qxgmat.dto.response.UserClassDetailDto;
|
|
|
+import com.qxgmat.dto.response.UserExerciseGroupDto;
|
|
|
+import com.qxgmat.dto.response.UserQuestionDetailDto;
|
|
|
import com.qxgmat.help.ShiroHelp;
|
|
|
+import com.qxgmat.service.ExercisePaperService;
|
|
|
import com.qxgmat.service.HomeworkPreviewService;
|
|
|
import com.qxgmat.service.UserPaperService;
|
|
|
import com.qxgmat.service.inline.*;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-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.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
import java.util.Collection;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -50,19 +55,38 @@ public class QuestionController {
|
|
|
private HomeworkPreviewService homeworkPreviewService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private ExercisePaperService exercisePaperService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private UserClassService userClassService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private UserPayService userPayService;
|
|
|
+
|
|
|
@RequestMapping(value = "/class/process", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "获取课程进度", notes = "获取所有课程及状态进度", httpMethod = "GET")
|
|
|
public Response<List<UserClassDetailDto>> classProcess() {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
List<UserClass> userClassList = userClassService.getByUser(user.getId());
|
|
|
+ List<UserClassDetailDto> dtos = Transform.convert(userClassList, UserClassDetailDto.class);
|
|
|
|
|
|
// 获取每个科目的最后3次作业
|
|
|
Map<Object, Collection<UserHomeworkPreviewRelation>> previewMap = homeworkPreviewService.groupByCategory(user.getId(), 3);
|
|
|
+ Transform.combine(dtos, previewMap, UserClassDetailDto.class, "category", "previews", UserHomeworkPreviewExtendDto.class);
|
|
|
+
|
|
|
+ // 获取课程状态
|
|
|
+ List<UserPay> pays = userPayService.listUnUse(user.getId(), PayModule.CLASS);
|
|
|
+ Collection ids = Transform.getIds(userClassList, UserClass.class, "category");
|
|
|
+ for(UserPay pay : pays){
|
|
|
+ Integer category = Integer.valueOf(pay.getModuleExtend());
|
|
|
+ if (!ids.contains(category)){
|
|
|
+ UserClassDetailDto dto = new UserClassDetailDto();
|
|
|
+ dto.setCategory(category);
|
|
|
+ dto.setPayed(true);
|
|
|
+ dtos.add(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- List<UserClassDetailDto> dtos = Transform.convert(userClassList, UserClassDetailDto.class);
|
|
|
- Transform.combine(dtos, previewMap, UserClassDetailDto.class, "moduleId", "previews", UserHomeworkPreviewExtendDto.class);
|
|
|
return ResponseHelp.success(dtos);
|
|
|
}
|
|
|
|
|
@@ -80,29 +104,63 @@ public class QuestionController {
|
|
|
|
|
|
List<UserHomeworkPreviewExtendDto> pr = Transform.convert(p, UserHomeworkPreviewExtendDto.class);
|
|
|
|
|
|
+ // 获取试卷统计信息
|
|
|
+ Map map = Transform.getMap(p, UserHomeworkPreviewRelation.class, "id", "preview");
|
|
|
+ Map<Integer, Integer[]> questionNoIdsMap = new HashMap<>();
|
|
|
+ for(Object value : map.keySet()){
|
|
|
+ Integer key = (Integer) value;
|
|
|
+ HomeworkPreview preview = (HomeworkPreview) map.get(key);
|
|
|
+ questionNoIdsMap.put(key, preview.getQuestionNoIds());
|
|
|
+ }
|
|
|
+ Map statMap = questionNoService.statPaperMap(questionNoIdsMap);
|
|
|
+ Transform.combine(pr, statMap, UserHomeworkPreviewExtendDto.class, "id", "stat");
|
|
|
+
|
|
|
return ResponseHelp.success(pr, page, size, p.getTotal());
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/exercise/process", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "练习进度", httpMethod = "GET")
|
|
|
- public Response<PageMessage<ExercisePaper>> exerciseProcess(
|
|
|
- @RequestParam(required = false, defaultValue = "1") int page,
|
|
|
- @RequestParam(required = false, defaultValue = "100") int size,
|
|
|
+ public Response<List<UserExerciseGroupDto>> exerciseProcess(
|
|
|
+ @RequestParam(required = true) Integer structId, // 第三层,查询第4层,以及第三层汇总
|
|
|
HttpSession session) {
|
|
|
- Page<ExercisePaper> p=null;
|
|
|
+ Page<UserExerciseGroupDto> p=null;
|
|
|
|
|
|
- return ResponseHelp.success(p, page, size, p.getTotal());
|
|
|
+ return ResponseHelp.success(p);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/exercise/place", method = RequestMethod.GET)
|
|
|
+ @ApiOperation(value = "练习组卷考点分组条件", httpMethod = "GET")
|
|
|
+ public Response<List<String>> exercisePlace(HttpSession session) {
|
|
|
+ return ResponseHelp.success(exercisePaperService.groupPlace());
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/exercise/paper", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "练习组卷列表", httpMethod = "GET")
|
|
|
- public Response<PageMessage<ExercisePaper>> listExercisePaper(
|
|
|
+ public Response<PageMessage<UserExercisePaperExtendDto>> listExercisePaper(
|
|
|
@RequestParam(required = false, defaultValue = "1") int page,
|
|
|
@RequestParam(required = false, defaultValue = "100") int size,
|
|
|
+ @RequestParam(required = true) Integer structId,
|
|
|
+ @RequestParam(required = true) String logic,
|
|
|
+ @RequestParam(required = false, name = "logic_extend") String logicExtend,
|
|
|
+ @RequestParam(required = false) Integer times,
|
|
|
HttpSession session) {
|
|
|
- Page<ExercisePaper> p = null;
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+ PageResult<UserExercisePaperRelation> p = exercisePaperService.list(page, size, structId, user.getId(), ExerciseLogic.ValueOf(logic), logicExtend, times);
|
|
|
|
|
|
- return ResponseHelp.success(p, page, size, p.getTotal());
|
|
|
+ List<UserExercisePaperExtendDto> pr = Transform.convert(p, UserExercisePaperExtendDto.class);
|
|
|
+
|
|
|
+ // 获取试卷统计信息
|
|
|
+ Map map = Transform.getMap(p, UserExercisePaperRelation.class, "id", "paper");
|
|
|
+ Map<Integer, Integer[]> questionNoIdsMap = new HashMap<>();
|
|
|
+ for(Object value : map.keySet()){
|
|
|
+ Integer key = (Integer) value;
|
|
|
+ ExercisePaper paper = (ExercisePaper) map.get(key);
|
|
|
+ questionNoIdsMap.put(key, paper.getQuestionNoIds());
|
|
|
+ }
|
|
|
+ Map statMap = questionNoService.statPaperMap(questionNoIdsMap);
|
|
|
+ Transform.combine(pr, statMap, UserHomeworkPreviewExtendDto.class, "id", "stat");
|
|
|
+
|
|
|
+ return ResponseHelp.success(pr, page, size, p.getTotal());
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/examination/process", method = RequestMethod.GET)
|
|
@@ -129,45 +187,46 @@ public class QuestionController {
|
|
|
|
|
|
@RequestMapping(value = "/detail", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "获取题目详情", notes = "获取题目详情", httpMethod = "GET")
|
|
|
- public Response<User> detail(
|
|
|
- @RequestParam(required = false) String questionNoId
|
|
|
+ public Response<UserQuestionDetailDto> detail(
|
|
|
+ @RequestParam(required = false) String userQuestionId
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
return ResponseHelp.success(null);
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/start", method = RequestMethod.POST)
|
|
|
- @ApiOperation(value = "开始考试", notes = "提交考试设置", httpMethod = "POST")
|
|
|
- public Response<User> start(
|
|
|
- @RequestParam(required = false) String paperId
|
|
|
- ) {
|
|
|
+ @RequestMapping(value = "/exercise/start", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "开始: 练习", notes = "提交考试设置", httpMethod = "POST")
|
|
|
+ public Response<Boolean> start(@RequestBody @Validated ExerciseStartDto dto) {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+
|
|
|
+ return ResponseHelp.success(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/preview/start", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "开始: 预习作业", notes = "提交考试设置", httpMethod = "POST")
|
|
|
+ public Response<User> start(@RequestBody @Validated PreviewStartDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
return ResponseHelp.success(null);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/next", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "获取下一题", notes = "获取下一题", httpMethod = "POST")
|
|
|
- public Response<User> next(
|
|
|
- @RequestParam(required = false) String reportId
|
|
|
- ) {
|
|
|
+ public Response<User> next(@RequestBody @Validated QuestionNextDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
return ResponseHelp.success(null);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/submit", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "提交题目答案", notes = "提交题目", httpMethod = "POST")
|
|
|
- public Response<User> submit(
|
|
|
- @RequestParam(required = false) String questionNoId
|
|
|
- ) {
|
|
|
+ public Response<User> submit(@RequestBody @Validated QuestionSubmitDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
+
|
|
|
return ResponseHelp.success(null);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/finish", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "完成考试", notes = "完成考试", httpMethod = "POST")
|
|
|
- public Response<User> finish(
|
|
|
- @RequestParam(required = false) String paperId
|
|
|
- ) {
|
|
|
+ public Response<User> finish(@RequestBody @Validated QuestionFinishDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
return ResponseHelp.success(null);
|
|
|
}
|