Browse Source

update PaperDetail

reghao 7 months ago
parent
commit
4e638e1228

+ 4 - 1
content/content-service/src/main/java/cn/reghao/tnb/content/app/exam/model/vo/PaperDetail.java

@@ -3,6 +3,7 @@ package cn.reghao.tnb.content.app.exam.model.vo;
 import cn.reghao.tnb.content.app.exam.model.po.Paper;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author reghao
@@ -15,13 +16,15 @@ public class PaperDetail {
     private int duration;
     private int totalScore;
     private List<QuestionInfo> questions;
+    private Map<Integer, List<QuestionInfo>> questionMap;
 
-    public PaperDetail(Paper paper, List<QuestionInfo> questions) {
+    public PaperDetail(Paper paper, List<QuestionInfo> questions, Map<Integer, List<QuestionInfo>> questionMap) {
         this.paperId = paper.getId();
         this.name = paper.getName();
         this.description = paper.getDescription();
         this.duration = paper.getDuration();
         this.totalScore = paper.getTotalScore();
         this.questions = questions;
+        this.questionMap = questionMap;
     }
 }

+ 3 - 1
content/content-service/src/main/java/cn/reghao/tnb/content/app/exam/service/PaperService.java

@@ -137,7 +137,9 @@ public class PaperService {
     public PaperDetail getPaperDetail(int paperId) {
         Paper paper = paperMapper.findById(paperId);
         List<QuestionInfo> questions = getPaperQuestions(paperId);
-        return new PaperDetail(paper, questions);
+        Map<Integer, List<QuestionInfo>> groupMap = questions.stream()
+                .collect(Collectors.groupingBy(QuestionInfo::getQuestionType));
+        return new PaperDetail(paper, questions, groupMap);
     }
 
     public List<KeyValue> getKeyValues() {