|
@@ -7,13 +7,13 @@ 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.PaperOrigin;
|
|
|
+import com.qxgmat.data.constants.enums.module.QuestionModule;
|
|
|
+import com.qxgmat.data.constants.enums.module.StructModule;
|
|
|
import com.qxgmat.data.dao.entity.*;
|
|
|
-import com.qxgmat.data.relation.entity.UserExercisePaperRelation;
|
|
|
+import com.qxgmat.data.inline.UserQuestionStat;
|
|
|
+import com.qxgmat.data.relation.entity.QuestionNoRelation;
|
|
|
import com.qxgmat.data.relation.entity.UserReportRelation;
|
|
|
-import com.qxgmat.dto.extend.QuestionExtendDto;
|
|
|
-import com.qxgmat.dto.extend.QuestionNoExtendDto;
|
|
|
-import com.qxgmat.dto.extend.UserExercisePaperExtendDto;
|
|
|
-import com.qxgmat.dto.extend.UserPreviewPaperExtendDto;
|
|
|
+import com.qxgmat.dto.extend.*;
|
|
|
import com.qxgmat.dto.request.*;
|
|
|
import com.qxgmat.dto.response.*;
|
|
|
import com.qxgmat.help.ShiroHelp;
|
|
@@ -25,15 +25,13 @@ import com.qxgmat.service.extend.QuestionFlowService;
|
|
|
import com.qxgmat.service.inline.*;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
-import net.bytebuddy.asm.Advice;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("/api/question")
|
|
@@ -50,6 +48,9 @@ public class QuestionController {
|
|
|
private ExercisePaperService exercisePaperService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private ExerciseStructService exerciseStructService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private ExerciseService exerciseService;
|
|
|
|
|
|
@Autowired
|
|
@@ -65,6 +66,13 @@ public class QuestionController {
|
|
|
private QuestionService questionService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private SentenceQuestionService sentenceQuestionService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TextbookQuestionService textbookQuestionService;
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private SentencePaperService sentencePaperService;
|
|
|
|
|
|
@Autowired
|
|
@@ -77,6 +85,12 @@ public class QuestionController {
|
|
|
private UserCollectQuestionService userCollectQuestionService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private UserNoteQuestionService userNoteQuestionService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserAskQuestionService userAskQuestionService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private UserClassService userClassService;
|
|
|
|
|
|
@Autowired
|
|
@@ -97,9 +111,127 @@ public class QuestionController {
|
|
|
public Response<List<UserExerciseGroupDto>> exerciseProgress(
|
|
|
@RequestParam(required = true) Integer structId,
|
|
|
HttpSession session) {
|
|
|
- Page<UserExerciseGroupDto> p=null;
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
|
|
|
-
|
|
|
+ List<ExerciseStruct> three = exerciseStructService.children(structId, 0);
|
|
|
+ List<UserExerciseGroupDto> p = new ArrayList<>(three.size());
|
|
|
+ for(ExerciseStruct struct : three){
|
|
|
+ UserExerciseGroupDto dto = Transform.convert(struct, UserExerciseGroupDto.class);
|
|
|
+
|
|
|
+ List<QuestionNo> list = questionNoService.listByStruct(StructModule.EXERCISE, struct.getId());
|
|
|
+ dto.setStat(questionNoService.statPaper(list));
|
|
|
+ dto.setQuestionNumber(list.size());
|
|
|
+ Map<Object, UserQuestionStat> userQuestionStatMap = null;
|
|
|
+ if(user != null){
|
|
|
+ Collection questionNoIds = Transform.getIds(list, QuestionNo.class, "id");
|
|
|
+ List<UserQuestion> userQuestionList = userQuestionService.listByQuestionNo(user.getId(), questionNoIds);
|
|
|
+ userQuestionStatMap = userQuestionService.statQuestionNoMap(userQuestionList);
|
|
|
+
|
|
|
+ dto.setUserStat(userQuestionService.statQuestion(userQuestionList));
|
|
|
+
|
|
|
+ if (list.size() > userQuestionStatMap.size()){
|
|
|
+ dto.setUserNumber(userQuestionStatMap.size());
|
|
|
+ dto.setMinTimes(0);
|
|
|
+ }else{
|
|
|
+ int minTimes = 0;
|
|
|
+
|
|
|
+ for(UserQuestionStat stat : userQuestionStatMap.values()){
|
|
|
+ if(stat.getUserNumber() < minTimes || minTimes == 0) minTimes = stat.getUserNumber();
|
|
|
+ }
|
|
|
+ int userNumber = 0;
|
|
|
+ for(UserQuestionStat stat : userQuestionStatMap.values()){
|
|
|
+ if(stat.getUserNumber() > minTimes) userNumber += 1;
|
|
|
+ }
|
|
|
+ dto.setUserNumber(userNumber);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ List<ExerciseStruct> children = exerciseStructService.children(struct.getId(), 0);
|
|
|
+ if (children == null || children.size() == 0){
|
|
|
+
|
|
|
+ List<ExercisePaper> paperList = exercisePaperService.listByLogic(struct.getId(), 0, ExerciseLogic.NO, null);
|
|
|
+ List<UserExerciseGroupExtendDto> childrenDtos = new ArrayList<>(paperList.size());
|
|
|
+
|
|
|
+ for(ExercisePaper child : paperList){
|
|
|
+ UserExerciseGroupExtendDto extendDto = new UserExerciseGroupExtendDto();
|
|
|
+ extendDto.setId(child.getId());
|
|
|
+ extendDto.setTitle(child.getNo().toString());
|
|
|
+ extendDto.setQuestionNumber(child.getQuestionNumber());
|
|
|
+ if(user != null){
|
|
|
+ int minTimes = 0;
|
|
|
+ int userQuestionNumber = 0;
|
|
|
+ boolean flag = true;
|
|
|
+ for(int questionNoId : child.getQuestionNoIds()){
|
|
|
+ UserQuestionStat stat = userQuestionStatMap.get(questionNoId);
|
|
|
+ if (stat == null) {
|
|
|
+ flag = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (stat.getUserNumber() < minTimes || minTimes == 0) minTimes = stat.getUserNumber();
|
|
|
+ }
|
|
|
+ if (!flag) minTimes = 0;
|
|
|
+ for(int questionNoId : child.getQuestionNoIds()){
|
|
|
+ UserQuestionStat stat = userQuestionStatMap.get(questionNoId);
|
|
|
+ if (stat != null && stat.getUserNumber() > minTimes) userQuestionNumber += 1;
|
|
|
+ }
|
|
|
+ extendDto.setUserNumber(userQuestionNumber);
|
|
|
+ extendDto.setMinTimes(minTimes);
|
|
|
+ }
|
|
|
+ extendDto.setType("paper");
|
|
|
+ childrenDtos.add(extendDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ Collection ids = Transform.getIds(p, ExercisePaper.class, "id");
|
|
|
+ List<UserPaper> userPaperList = userPaperService.listWithOrigin(user.getId(), PaperOrigin.EXERCISE, ids);
|
|
|
+
|
|
|
+ Map userPaperMap = Transform.getMap(userPaperList, UserPaper.class, "originId", "id");
|
|
|
+ Transform.combine(childrenDtos, userPaperMap, UserSentencePaperDto.class, "id", "userPaperId");
|
|
|
+
|
|
|
+
|
|
|
+ Collection paperIds = Transform.getIds(paperList, ExercisePaper.class, "id");
|
|
|
+ List<UserReport> reportList = userReportService.listWithLater(paperIds);
|
|
|
+ Transform.combine(childrenDtos, reportList, UserSentencePaperDto.class, "userPaperId", "report", UserReport.class, "paperId", UserReportExtendDto.class);
|
|
|
+
|
|
|
+ dto.setChildren(childrenDtos);
|
|
|
+ }else{
|
|
|
+
|
|
|
+ List<UserExerciseGroupExtendDto> childrenDtos = new ArrayList<>(children.size());
|
|
|
+ for(ExerciseStruct child : children){
|
|
|
+ UserExerciseGroupExtendDto extendDto = new UserExerciseGroupExtendDto();
|
|
|
+ extendDto.setId(child.getId());
|
|
|
+ extendDto.setTitleEn(child.getTitleEn());
|
|
|
+ extendDto.setTitleZh(child.getTitleZh());
|
|
|
+ List<QuestionNo> childQuestionList = list.stream().filter((q)-> Collections.singletonList(q.getModuleStruct()).contains(child.getId().intValue())).collect(Collectors.toList());
|
|
|
+ extendDto.setQuestionNumber(childQuestionList.size());
|
|
|
+ if (user != null){
|
|
|
+ int minTimes = 0;
|
|
|
+ int userQuestionNumber = 0;
|
|
|
+ boolean flag = true;
|
|
|
+ for(QuestionNo questionNo : childQuestionList){
|
|
|
+ UserQuestionStat stat = userQuestionStatMap.get(questionNo.getId());
|
|
|
+ if (stat == null) {
|
|
|
+ flag = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (stat.getUserNumber() < minTimes || minTimes == 0) minTimes = stat.getUserNumber();
|
|
|
+ }
|
|
|
+ if (!flag) minTimes = 0;
|
|
|
+ for(QuestionNo questionNo : childQuestionList){
|
|
|
+ UserQuestionStat stat = userQuestionStatMap.get(questionNo.getId());
|
|
|
+ if (stat != null && stat.getUserNumber() > minTimes) userQuestionNumber += 1;
|
|
|
+ }
|
|
|
+ extendDto.setUserNumber(userQuestionNumber);
|
|
|
+ extendDto.setMinTimes(minTimes);
|
|
|
+ }
|
|
|
+ extendDto.setType("struct");
|
|
|
+ childrenDtos.add(extendDto);
|
|
|
+ }
|
|
|
+ dto.setChildren(childrenDtos);
|
|
|
+ }
|
|
|
+ p.add(dto);
|
|
|
+ }
|
|
|
|
|
|
return ResponseHelp.success(p);
|
|
|
}
|
|
@@ -114,7 +246,7 @@ public class QuestionController {
|
|
|
|
|
|
@RequestMapping(value = "/exercise/list", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "练习组卷列表", httpMethod = "GET")
|
|
|
- public Response<PageMessage<UserExercisePaperExtendDto>> listExercisePaper(
|
|
|
+ public Response<PageMessage<UserExercisePaperDto>> listExercisePaper(
|
|
|
@RequestParam(required = false, defaultValue = "1") int page,
|
|
|
@RequestParam(required = false, defaultValue = "100") int size,
|
|
|
@RequestParam(required = true) Integer structId,
|
|
@@ -123,24 +255,37 @@ public class QuestionController {
|
|
|
@RequestParam(required = false) Integer times,
|
|
|
HttpSession session) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
- PageResult<UserExercisePaperRelation> p = exerciseService.list(page, size, structId, user.getId(), ExerciseLogic.ValueOf(logic), logicExtend, times);
|
|
|
+ PageResult<ExercisePaper> p = exerciseService.list(page, size, structId, user != null ? user.getId():null, ExerciseLogic.ValueOf(logic), logicExtend, times);
|
|
|
|
|
|
- List<UserExercisePaperExtendDto> pr = Transform.convert(p, UserExercisePaperExtendDto.class);
|
|
|
+ List<UserExercisePaperDto> pr = Transform.convert(p, UserExercisePaperDto.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());
|
|
|
+ for(ExercisePaper paper : p){
|
|
|
+ questionNoIdsMap.put(paper.getId(), paper.getQuestionNoIds());
|
|
|
}
|
|
|
Map statMap = questionNoService.statPaperMap(questionNoIdsMap);
|
|
|
- Transform.combine(pr, statMap, UserPreviewPaperExtendDto.class, "id", "stat");
|
|
|
+ Transform.combine(pr, statMap, UserExercisePaperDto.class, "id", "stat");
|
|
|
+
|
|
|
+ if (user != null){
|
|
|
+
|
|
|
+ Collection ids = Transform.getIds(p, ExercisePaper.class, "id");
|
|
|
+ List<UserPaper> paperList = userPaperService.listWithOrigin(user.getId(), PaperOrigin.EXERCISE, ids);
|
|
|
+ Transform.combine(pr, paperList, UserExercisePaperDto.class, "id", "paper", UserPaper.class, "originId", UserPaperBaseExtendDto.class);
|
|
|
+
|
|
|
+ Map userPaperMap = Transform.getMap(paperList, UserPaper.class, "originId", "id");
|
|
|
+ Transform.combine(pr, userPaperMap, UserExercisePaperDto.class, "id", "paperId");
|
|
|
+
|
|
|
+
|
|
|
+ Collection paperIds = Transform.getIds(paperList, UserPaper.class, "id");
|
|
|
+ List<UserReport> reportList = userReportService.listWithLater(paperIds);
|
|
|
+ Transform.combine(pr, reportList, UserExercisePaperDto.class, "id", "report", UserReport.class, "paperId", UserReportExtendDto.class);
|
|
|
+ }
|
|
|
|
|
|
return ResponseHelp.success(pr, page, size, p.getTotal());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@RequestMapping(value = "/examination/progress", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "模考进度", httpMethod = "GET")
|
|
|
public Response<PageMessage<ExercisePaper>> examinationProgress(
|
|
@@ -156,44 +301,110 @@ public class QuestionController {
|
|
|
|
|
|
@RequestMapping(value = "/examination/list", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "模考组卷列表", httpMethod = "GET")
|
|
|
- public Response<PageMessage<ExercisePaper>> examinationPaperList(
|
|
|
+ public Response<PageMessage<UserExaminationPaperDto>> examinationPaperList(
|
|
|
@RequestParam(required = false, defaultValue = "1") int page,
|
|
|
@RequestParam(required = false, defaultValue = "100") int size,
|
|
|
+ @RequestParam(required = true) Integer structId,
|
|
|
+ @RequestParam(required = false) Integer times,
|
|
|
HttpSession session) {
|
|
|
- Page<ExercisePaper> p = null;
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+ PageResult<ExaminationPaper> p = examinationService.list(page, size, structId, user != null ? user.getId():null, times);
|
|
|
+
|
|
|
+ List<UserExaminationPaperDto> pr = Transform.convert(p, UserExaminationPaperDto.class);
|
|
|
+
|
|
|
+ if (user != null){
|
|
|
+
|
|
|
+ Collection ids = Transform.getIds(p, ExaminationPaper.class, "id");
|
|
|
+ List<UserPaper> paperList = userPaperService.listWithOrigin(user.getId(), PaperOrigin.EXAMINATION, ids);
|
|
|
+ Transform.combine(pr, paperList, UserExaminationPaperDto.class, "id", "paper", UserPaper.class, "originId", UserPaperBaseExtendDto.class);
|
|
|
+
|
|
|
+ Map userPaperMap = Transform.getMap(paperList, UserPaper.class, "originId", "id");
|
|
|
+ Transform.combine(pr, userPaperMap, UserExaminationPaperDto.class, "id", "paperId");
|
|
|
+
|
|
|
+
|
|
|
+ Collection paperIds = Transform.getIds(paperList, UserPaper.class, "id");
|
|
|
+ List<UserReport> reportList = userReportService.listWithLater(paperIds);
|
|
|
+ Transform.combine(pr, reportList, UserExaminationPaperDto.class, "id", "report", UserReport.class, "paperId", UserReportExtendDto.class);
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
+ return ResponseHelp.success(pr, page, size, p.getTotal());
|
|
|
+ }
|
|
|
|
|
|
- return ResponseHelp.success(p, page, size, p.getTotal());
|
|
|
+ @RequestMapping(value = "/base", method = RequestMethod.GET)
|
|
|
+ @ApiOperation(value = "获取题目详情", notes = "根据题目序号获取题目", httpMethod = "GET")
|
|
|
+ public Response<UserQuestionBaseDto> base(
|
|
|
+ @RequestParam(required = true) Integer userReportId,
|
|
|
+ @RequestParam(required = true) Integer no
|
|
|
+ ) {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+ if (no == null || no == 0){
|
|
|
+ no = 1;
|
|
|
+ }
|
|
|
+ UserQuestion userQuestion = userQuestionService.getByReportAndNo(user.getId(), userReportId, no);
|
|
|
+ UserQuestionBaseDto dto = Transform.convert(userQuestion, UserQuestionBaseDto.class);
|
|
|
+
|
|
|
+ return ResponseHelp.success(dto);
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/question/detail", method = RequestMethod.GET)
|
|
|
+ @RequestMapping(value = "/detail", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "获取题目详情", notes = "获取题目详情", httpMethod = "GET")
|
|
|
public Response<UserQuestionDetailDto> detail(
|
|
|
- @RequestParam(required = true) Integer userQuestionId,
|
|
|
- @RequestParam(required = true) Integer userReportId,
|
|
|
- @RequestParam(required = true) Integer no
|
|
|
+ @RequestParam(required = true) Integer userQuestionId
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
- if (userQuestionId != null && userQuestionId > 0){
|
|
|
+ UserQuestion userQuestion = userQuestionService.get(userQuestionId);
|
|
|
|
|
|
- }else if(userReportId != null && userReportId > 0){
|
|
|
- if (no == null || no == 0){
|
|
|
- no = 1;
|
|
|
- }
|
|
|
-
|
|
|
+ UserQuestionDetailDto dto = Transform.convert(userQuestion, UserQuestionDetailDto.class);
|
|
|
+
|
|
|
+ UserReport userReport = userReportService.get(userQuestion.getReportId());
|
|
|
+ dto.setReport(Transform.convert(userReport, UserReportExtendDto.class));
|
|
|
+
|
|
|
+ UserPaper userPaper = userPaperService.get(userReport.getPaperId());
|
|
|
+ dto.setPaper(Transform.convert(userPaper, UserPaperBaseExtendDto.class));
|
|
|
+
|
|
|
+ Question question = questionService.get(userQuestion.getQuestionId());
|
|
|
+ dto.setQuestion(Transform.convert(question, QuestionDetailExtendDto.class));
|
|
|
+
|
|
|
+ UserCollectQuestion collect = userCollectQuestionService.getByUserAndQuestion(user.getId(), userQuestion.getQuestionId());
|
|
|
+ dto.setCollect(collect != null);
|
|
|
+
|
|
|
+ UserNoteQuestion userNoteQuestion = userNoteQuestionService.getByUserAndQuestion(user.getId(), userQuestion.getQuestionId());
|
|
|
+ dto.setNote(Transform.convert(userNoteQuestion, UserNoteQuestionExtendDto.class));
|
|
|
+
|
|
|
+ List<UserAskQuestion> userAskQuestionList = userAskQuestionService.listByQuestion(userQuestion.getQuestionId(), true);
|
|
|
+ dto.setAsks(Transform.convert(userAskQuestionList, UserAskQuestionExtendDto.class));
|
|
|
+
|
|
|
+ if (question.getAssociationContent() != null){
|
|
|
+ List<QuestionNoRelation> associations = questionNoService.listWithRelationByIds(question.getAssociationContent());
|
|
|
+ Collection questions = Transform.getIds(associations, QuestionNoRelation.class, "question");
|
|
|
+ dto.setAssociations(Transform.convert(questions, QuestionBaseExtendDto.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ switch (QuestionModule.ValueOf(userQuestion.getQuestionModule())){
|
|
|
+ case BASE:
|
|
|
+ List<QuestionNo> questionNoList = questionNoService.listByQuestion(userQuestion.getQuestionId());
|
|
|
+ dto.setQuestionNos(Transform.convert(questionNoList, QuestionNoExtendDto.class));
|
|
|
+ break;
|
|
|
+ case SENTENCE:
|
|
|
+ SentenceQuestion sentenceQuestion = sentenceQuestionService.get(userQuestion.getQuestionNoId());
|
|
|
+ dto.setQuestionNo(Transform.convert(sentenceQuestion, QuestionNoExtendDto.class));
|
|
|
+ break;
|
|
|
+ case TEXTBOOK:
|
|
|
+ TextbookQuestion textbookQuestion = textbookQuestionService.get(userQuestion.getQuestionNoId());
|
|
|
+ dto.setQuestionNo(Transform.convert(textbookQuestion, QuestionNoExtendDto.class));
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
- return ResponseHelp.success(null);
|
|
|
+ return ResponseHelp.success(dto);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/exercise/paper", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "获取练习卷", notes = "获取练习卷", httpMethod = "GET")
|
|
|
public Response<PaperBaseDto> detailExercise(
|
|
|
- @RequestParam(required = true, name="id") Integer paperId
|
|
|
+ @RequestParam(required = true) Integer paperId
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
- ExercisePaper paper = exercisePaperService.get(paperId);
|
|
|
+ UserPaper paper = questionFlowService.paper(user.getId(), PaperOrigin.EXERCISE, paperId);
|
|
|
PaperBaseDto paperDto = Transform.convert(paper, PaperBaseDto.class);
|
|
|
|
|
|
return ResponseHelp.success(paperDto);
|
|
@@ -202,10 +413,10 @@ public class QuestionController {
|
|
|
@RequestMapping(value = "/examination/paper", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "获取模考卷", notes = "获取模考卷", httpMethod = "GET")
|
|
|
public Response<PaperBaseDto> detailExamination(
|
|
|
- @RequestParam(required = true, name="id") Integer paperId
|
|
|
+ @RequestParam(required = true) Integer paperId
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
- ExaminationPaper paper = examinationPaperService.get(paperId);
|
|
|
+ UserPaper paper = questionFlowService.paper(user.getId(), PaperOrigin.EXAMINATION, paperId);
|
|
|
PaperBaseDto paperDto = Transform.convert(paper, PaperBaseDto.class);
|
|
|
|
|
|
return ResponseHelp.success(paperDto);
|
|
@@ -214,7 +425,7 @@ public class QuestionController {
|
|
|
@RequestMapping(value = "/report/base", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "获取练习记录", notes = "获取练习记录", httpMethod = "GET")
|
|
|
public Response<UserReportBaseDto> baseReport(
|
|
|
- @RequestParam(required = true, name="id") Integer userReportId
|
|
|
+ @RequestParam(required = true) Integer userReportId
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
UserReportRelation report = questionFlowService.baseReport(user.getId(), userReportId);
|
|
@@ -226,28 +437,42 @@ public class QuestionController {
|
|
|
@RequestMapping(value = "/report/detail", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "获取练习详细记录", notes = "获取练习卷", httpMethod = "GET")
|
|
|
public Response<UserReportDetailDto> detailReport(
|
|
|
- @RequestParam(required = true, name="id") Integer userReportId
|
|
|
+ @RequestParam(required = true) Integer userReportId
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
UserReportRelation report = questionFlowService.baseReport(user.getId(), userReportId);
|
|
|
|
|
|
UserReportDetailDto userReportDto = Transform.convert(report, UserReportDetailDto.class);
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ UserPaper userPaper = userPaperService.get(report.getPaperId());
|
|
|
+ userReportDto.setPaper(Transform.convert(userPaper, UserPaperBaseExtendDto.class));
|
|
|
|
|
|
return ResponseHelp.success(userReportDto);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/report/question", method = RequestMethod.GET)
|
|
|
- @ApiOperation(value = "获取练习做题记录", notes = "获取练习卷", httpMethod = "GET")
|
|
|
- public Response<List<UserQuestionDetailDto>> detailReportQuestion(
|
|
|
- @RequestParam(required = true, name="id") Integer userReportId
|
|
|
+ @ApiOperation(value = "获取做题记录", notes = "获取做题记录", httpMethod = "GET")
|
|
|
+ public Response<List<UserQuestionExtendDto>> detailReportQuestion(
|
|
|
+ @RequestParam(required = true) Integer userReportId
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
List<UserQuestion> userQuestionList = questionFlowService.listByReport(user.getId(), userReportId);
|
|
|
+ List<UserQuestionExtendDto> userQuestionDtos = Transform.convert(userQuestionList, UserQuestionExtendDto.class);
|
|
|
+
|
|
|
+ Collection ids = Transform.getIds(userQuestionList, UserQuestion.class, "questionId");
|
|
|
+ List<UserCollectQuestion> userCollectQuestionList = userCollectQuestionService.listByUserAndQuestions(user.getId(), ids);
|
|
|
+ Map collectMap = Transform.getMap(userCollectQuestionList, UserCollectQuestion.class, "questionId", "id");
|
|
|
|
|
|
- List<UserQuestionDetailDto> userQuestionDetailDtos = Transform.convert(userQuestionList, UserQuestionDetailDto.class);
|
|
|
+ List<UserNoteQuestion> userNoteQuestionList = userNoteQuestionService.listByUserAndQuestions(user.getId(), ids);
|
|
|
+ Map noteMap = Transform.getMap(userNoteQuestionList, UserNoteQuestion.class, "questionId", "id");
|
|
|
|
|
|
- return ResponseHelp.success(userQuestionDetailDtos);
|
|
|
+ for(UserQuestionExtendDto dto : userQuestionDtos){
|
|
|
+ dto.setCollect(collectMap.containsKey(dto.getQuestionId()));
|
|
|
+ dto.setNote(noteMap.containsKey(dto.getQuestionId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ return ResponseHelp.success(userQuestionDtos);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/examination/start", method = RequestMethod.POST)
|
|
@@ -289,10 +514,10 @@ public class QuestionController {
|
|
|
@RequestMapping(value = "/textbook/paper", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "获取机经练习卷", notes = "获取练习卷", httpMethod = "GET")
|
|
|
public Response<PaperBaseDto> detailTextbookPaper(
|
|
|
- @RequestParam(required = true, name="id") Integer paperId
|
|
|
+ @RequestParam(required = true) Integer paperId
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
- TextbookPaper paper = textbookPaperService.get(paperId);
|
|
|
+ UserPaper paper = questionFlowService.paper(user.getId(), PaperOrigin.TEXTBOOK, paperId);
|
|
|
|
|
|
PaperBaseDto paperDto = Transform.convert(paper, PaperBaseDto.class);
|
|
|
|
|
@@ -315,10 +540,10 @@ public class QuestionController {
|
|
|
@RequestMapping(value = "/sentence/paper", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "获取长难句练习卷", notes = "获取练习卷", httpMethod = "GET")
|
|
|
public Response<PaperBaseDto> detailSentencePaper(
|
|
|
- @RequestParam(required = true, name="id") Integer paperId
|
|
|
+ @RequestParam(required = true) Integer paperId
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
- SentencePaper paper = sentencePaperService.get(paperId);
|
|
|
+ UserPaper paper = questionFlowService.paper(user.getId(), PaperOrigin.SENTENCE, paperId);
|
|
|
|
|
|
PaperBaseDto paperDto = Transform.convert(paper, PaperBaseDto.class);
|
|
|
|
|
@@ -340,7 +565,7 @@ public class QuestionController {
|
|
|
@RequestMapping(value = "/error/paper", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "获取错题组卷", notes = "获取错题组卷", httpMethod = "GET")
|
|
|
public Response<PaperBaseDto> detailError(
|
|
|
- @RequestParam(required = true, name="id") Integer paperId
|
|
|
+ @RequestParam(required = true) Integer paperId
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
UserPaper paper = userPaperService.get(paperId);
|
|
@@ -371,7 +596,7 @@ public class QuestionController {
|
|
|
@RequestMapping(value = "/collect/paper", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "获取收藏组卷", notes = "获取收藏组卷", httpMethod = "GET")
|
|
|
public Response<PaperBaseDto> detailCollect(
|
|
|
- @RequestParam(required = true, name="id") Integer paperId
|
|
|
+ @RequestParam(required = true) Integer paperId
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
UserPaper paper = userPaperService.get(paperId);
|
|
@@ -415,13 +640,16 @@ public class QuestionController {
|
|
|
public Response<UserQuestionBaseDto> next(@RequestBody @Validated ReportNextDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
UserQuestion userQuestion = questionFlowService.next(user.getId(), dto.getUserReportId());
|
|
|
+ if (userQuestion == null) {
|
|
|
+ throw new ParameterException("finish");
|
|
|
+ }
|
|
|
UserQuestionBaseDto baseDto = Transform.convert(userQuestion, UserQuestionBaseDto.class);
|
|
|
|
|
|
|
|
|
baseDto.setQuestionNos(Transform.convert(questionNoService.listByQuestion(userQuestion.getQuestionId()), QuestionNoExtendDto.class));
|
|
|
|
|
|
|
|
|
- baseDto.setQuestion(Transform.convert(questionService.get(userQuestion.getQuestionId()), QuestionExtendDto.class));
|
|
|
+ baseDto.setQuestion(Transform.convert(questionService.get(userQuestion.getQuestionId()), QuestionBaseExtendDto.class));
|
|
|
|
|
|
|
|
|
baseDto.setQuestionNo(Transform.convert(questionNoService.get(userQuestion.getQuestionNoId()), QuestionNoExtendDto.class));
|