瀏覽代碼

模拟卷返回科目名称

mingfu 1 周之前
父節點
當前提交
7ce50f50f7
共有 1 個文件被更改,包括 9 次插入3 次删除
  1. 9 3
      ie-admin/src/main/java/com/ruoyi/web/controller/front/FrontPaperController.java

+ 9 - 3
ie-admin/src/main/java/com/ruoyi/web/controller/front/FrontPaperController.java

@@ -1,10 +1,10 @@
 package com.ruoyi.web.controller.front;
 
+import com.alibaba.fastjson2.JSONObject;
 import com.ruoyi.common.core.content.VistorContextHolder;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.AjaxResult2;
 import com.ruoyi.common.core.domain.entity.SysUser;
-import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.utils.NumberUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.dz.domain.DzControl;
@@ -33,6 +33,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
 
@@ -132,7 +133,7 @@ public class FrontPaperController {
 
     @ApiOperation("05 取模拟卷列表")
     @GetMapping("/list")
-    public AjaxResult2<List<LearnPaper>> list(LearnPaper learnPaper) {
+    public AjaxResult2<List<JSONObject>> list(LearnPaper learnPaper) {
         SysUser sysUser = SecurityUtils.getLoginUser().getUser();
         learnPaper.setPaperType(PaperType.Simulated.name());
         String subjectKey = NumberUtils.isPositive(learnPaper.getSubjectId()) ? String.valueOf(sysUser.getExamMajor()) : "0";
@@ -140,6 +141,11 @@ public class FrontPaperController {
         learnPaper.setDirectKey(sysUser.getExamType().name() + "_" + subjectKey);
         learnPaper.setSubjectId(null);
         List<LearnPaper> list = learnPaperService.selectLearnPaperList(learnPaper);
-        return AjaxResult2.success(list);
+        Map<Long, String> subjectMap = dzSubjectService.selectDzSubjectList(new DzSubject()).stream().collect(Collectors.toMap(DzSubject::getSubjectId, DzSubject::getSubjectName));
+        List<JSONObject> jsonList = list.stream().map(t -> {
+            JSONObject o = JSONObject.from(t);
+            o.put("subjectName", subjectMap.get(t.getSubjectId()));
+        }).collect(Collectors.toList());
+        return AjaxResult2.success(jsonList);
     }
 }