Jelajahi Sumber

修改题目列表字段联合查询,增加业务字段

zhaosongshan 7 bulan lalu
induk
melakukan
460c77ed3f

+ 12 - 0
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/controller/admin/QuestionController.java

@@ -39,6 +39,18 @@ public class QuestionController extends BaseApiController {
 
     @RequestMapping(value = "/page", method = RequestMethod.POST)
     public CommonResult<Page<Question>> pageList(@RequestBody QuestionPageRequestVM model) {
+        Page<Question> pageInfo = questionService.page(model);
+        pageInfo.getRecords().forEach(question -> {
+            question.setCreateTimeStr(DateTimeUtil.dateFormat(question.getCreateTime()));
+            question.setScoreStr(ExamUtil.scoreToVM(question.getScore()));
+            TextContent textContent = textContentService.selectById(question.getInfoTextContentId());
+            String clearHtml = "";
+            if(textContent != null && textContent.getContent() != null && !textContent.getContent().isEmpty()){
+                QuestionObject questionObject = JsonUtil.toJsonObject(textContent.getContent(), QuestionObject.class);
+                clearHtml = HtmlUtil.clear(questionObject.getTitleContent());
+            }
+            question.setShortTitle(clearHtml);
+        });
         return CommonResult.data(questionService.page(model));
     }
 

+ 29 - 0
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/domain/Question.java

@@ -28,6 +28,8 @@ public class Question implements Serializable {
      */
     private Integer score;
 
+    private String scoreStr;
+
     /**
      * 级别
      */
@@ -63,8 +65,12 @@ public class Question implements Serializable {
      */
     private Date createTime;
 
+    private String createTimeStr;
+
     private Boolean deleted;
 
+    private String shortTitle;
+
     public Integer getId() {
         return id;
     }
@@ -161,6 +167,29 @@ public class Question implements Serializable {
         this.deleted = deleted;
     }
 
+    public String getShortTitle() {
+        return shortTitle;
+    }
+
+    public void setShortTitle(String shortTitle) {
+        this.shortTitle = shortTitle;
+    }
+
+    public String getCreateTimeStr() {
+        return createTimeStr;
+    }
+
+    public void setCreateTimeStr(String createTimeStr) {
+        this.createTimeStr = createTimeStr;
+    }
+
+    public String getScoreStr() {
+        return scoreStr;
+    }
+
+    public void setScoreStr(String scoreStr) {
+        this.scoreStr = scoreStr;
+    }
 
     public void setCorrectFromVM(String correct, List<String> correctArray) {
         int qType = this.getQuestionType();