Sfoglia il codice sorgente

试题篮详情优化

tags/正式3.10.1
雍文秀 1 anno fa
parent
commit
2e288089db

+ 19
- 2
sstudy/src/main/java/com/xhkjedu/sstudy/service/question/UserBasketService.java Vedi File

@@ -10,8 +10,7 @@ import com.xhkjedu.sstudy.vo.question.UserBasketVo;
10 10
 import org.springframework.stereotype.Service;
11 11
 
12 12
 import javax.annotation.Resource;
13
-import java.util.ArrayList;
14
-import java.util.List;
13
+import java.util.*;
15 14
 import java.util.stream.Collectors;
16 15
 
17 16
 /**
@@ -63,6 +62,24 @@ public class UserBasketService {
63 62
     //获取列表
64 63
     public List <UserBasketVo> findAll(Integer userid, String subjectid) {
65 64
         List<UserBasketVo> baskets = userBasketMapper.findAll(userid, subjectid);
65
+        List<String> questionids = new ArrayList<>();
66
+        for (UserBasketVo basket : baskets) {
67
+            questionids.addAll(basket.getQuestions().stream().filter(b -> b.getQlevel().equals(2)).map(
68
+                    QuestionVo::getQuestionid).collect(Collectors.toList()));
69
+        }
70
+        if (N_Utils.isListNotEmpty(questionids)) {
71
+            List<Map<String, String>> sonList = questionMapper.listSonQuestionForSelect(String.join("','", questionids));
72
+            for (UserBasketVo basket : baskets) {
73
+                for (QuestionVo question : basket.getQuestions()) {
74
+                    if (question.getQlevel().equals(2)) {
75
+                        String questionid = question.getQuestionid();
76
+                        List<Map> sonqlist = sonList.stream().filter(
77
+                                s -> s.get("questionpid").equals(questionid)).collect(Collectors.toList());
78
+                        question.setSonqlist(sonqlist);
79
+                    }
80
+                }
81
+            }
82
+        }
66 83
         String sujectname = subjectMapper.getSubjectnameById(subjectid);
67 84
         //英语学科时处理听力题
68 85
         if(sujectname.contains("英语")){

+ 3
- 3
sstudy/src/main/resources/mapper/question/UserBasketMapper.xml Vedi File

@@ -29,10 +29,10 @@
29 29
                 <result property="pointid" column="pointid"></result>
30 30
                 <result property="pointname" column="pointname"></result>
31 31
             </collection>
32
-            <collection property="sonqlist" ofType="com.xhkjedu.sstudy.vo.question.QuestionVo"
33
-                        javaType="java.util.List" select="listSonQuestions" column="questionid">
32
+            <!--<collection property="sonqlist" ofType="com.xhkjedu.sstudy.vo.question.QuestionVo"-->
33
+            <!--            javaType="java.util.List" select="listSonQuestions" column="questionid">-->
34 34
 
35
-            </collection>
35
+            <!--</collection>-->
36 36
         </collection>
37 37
     </resultMap>
38 38
     <resultMap id="listSonQuestions" type="com.xhkjedu.sstudy.vo.question.QuestionVo" >

Loading…
Annulla
Salva