Просмотр исходного кода

知识点搜索试题

tags/正式3.14.1
王宁 3 месяцев назад
Родитель
Сommit
c3cbd4cf98

+ 18
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/controller/question/QuestionController.java Просмотреть файл

@@ -6,8 +6,10 @@ import com.xhkjedu.annotation.Action;
6 6
 import com.xhkjedu.sstudy.model.question.TQuestion;
7 7
 import com.xhkjedu.sstudy.model.question.TQuestionCollect;
8 8
 import com.xhkjedu.sstudy.model.subjectbook.TDirector;
9
+import com.xhkjedu.sstudy.model.subjectbook.TPoint;
9 10
 import com.xhkjedu.sstudy.service.question.QuestionService;
10 11
 import com.xhkjedu.sstudy.service.subjectbook.DirectorService;
12
+import com.xhkjedu.sstudy.service.subjectbook.PointService;
11 13
 import com.xhkjedu.sstudy.vo.question.QuestionCollectVo;
12 14
 import com.xhkjedu.sstudy.vo.question.QuestionVo;
13 15
 import com.xhkjedu.sstudy.vo.system.CollectVo;
@@ -38,6 +40,8 @@ public class QuestionController {
38 40
     private QuestionService tQuestionService;
39 41
     @Resource
40 42
     private DirectorService directorService;
43
+    @Resource
44
+    private PointService pointService;
41 45
 
42 46
     @PostMapping("/update_state")
43 47
     @Action("试题管理-修改状态")
@@ -112,6 +116,20 @@ public class QuestionController {
112 116
         Integer page = tQuestion.getPage();
113 117
         Integer pageSize = tQuestion.getPageSize();
114 118
         N_Utils.validation(new Object[]{page,"显示页码",1,pageSize,"显示条数",1});
119
+        //获取所选知识点信息
120
+        if(N_Utils.isNotEmpty(tQuestion.getPointid()) && !"0".equals(tQuestion.getPointid())){
121
+            TPoint point = pointService.getPointInfoById(tQuestion.getPointid());
122
+
123
+            if(point.getSonnum() == 0){
124
+                //没有子知识点,属于叶子节点
125
+                tQuestion.setPointLeaf(1);
126
+            }else{
127
+                //说明有子知识点,直接获取
128
+                tQuestion.setPointLeaf(0);
129
+                tQuestion.setPointall(point.getPointall());
130
+            }
131
+        }
132
+
115 133
         PageHelper.startPage(page, pageSize);
116 134
         tQuestion.setLsbid(null);
117 135
         List<Map<String, Object>> list = tQuestionService.listForSelect(tQuestion);

+ 3
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/mapper/subjectbook/PointMapper.java Просмотреть файл

@@ -24,4 +24,7 @@ public interface PointMapper extends TkMapper<TPoint> {
24 24
 
25 25
     //查找使用知识点的模块
26 26
     String findUseModule(String pointid);
27
+
28
+    //根据知识点ID获取知识点信息
29
+    TPoint getPointInfoById(@Param("pointid")String pointid);
27 30
 }

+ 6
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/model/question/TQuestion.java Просмотреть файл

@@ -135,4 +135,10 @@ public class TQuestion extends BaseBean {
135 135
 
136 136
     @Transient
137 137
     private String directorall;//所有层章节拼接
138
+
139
+    @Transient
140
+    private Integer pointLeaf;//知识点是否是叶子节点0不是1是
141
+
142
+    @Transient
143
+    private String pointall;//所有层知识点拼接
138 144
 }

+ 6
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/model/subjectbook/TPoint.java Просмотреть файл

@@ -31,6 +31,9 @@ public class TPoint extends BaseBean {
31 31
     //知识点所属层级
32 32
     private Integer pointlevel;
33 33
 
34
+    //所有层级知识点;拼接
35
+    private String pointall;
36
+
34 37
     //创建人
35 38
     private Integer createid;
36 39
 
@@ -50,4 +53,7 @@ public class TPoint extends BaseBean {
50 53
     private String createformat;
51 54
 
52 55
     private List<TPoint> children = new ArrayList<>();
56
+
57
+    @Transient
58
+    private Integer sonnum;//子知识点数量
53 59
 }

+ 5
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/service/subjectbook/PointService.java Просмотреть файл

@@ -105,5 +105,10 @@ public class PointService {
105 105
         }
106 106
         return useModule;
107 107
     }
108
+
109
+    //获取知识点详情
110
+    public TPoint getPointInfoById(String pointid) {
111
+        return pointMapper.getPointInfoById(pointid);
112
+    }
108 113
 }
109 114
 

+ 7
- 1
sstudy/src/main/resources/mapper/question/QuestionMapper.xml Просмотреть файл

@@ -208,6 +208,9 @@
208 208
         </if>
209 209
         left join t_question_director qd on q.questionid=qd.questionid
210 210
         left join t_director d on qd.directorid=d.directorid
211
+        <if test="question.pointid!=null and question.pointid!='0'.toString() and question.pointid!='' and question.pointLeaf==0">
212
+            left join t_point p on qp.pointid = p.pointid
213
+        </if>
211 214
         where d.disabled=0 and q.qstate=1
212 215
         <if test="question.lsbid!=null and question.lsbid!='0'.toString() and question.lsbid!=''">
213 216
             and qd.lsbid=#{question.lsbid}
@@ -221,9 +224,12 @@
221 224
         <if test="question.subjectid!=null and question.subjectid!='0'.toString() and question.subjectid!=''">
222 225
             and q.subjectid=#{question.subjectid}
223 226
         </if>
224
-        <if test="question.pointid!=null and question.pointid!='0'.toString() and question.pointid!=''">
227
+        <if test="question.pointid!=null and question.pointid!='0'.toString() and question.pointid!='' and question.pointLeaf==1">
225 228
             and qp.pointid=#{question.pointid}
226 229
         </if>
230
+        <if test="question.pointid!=null and question.pointid!='0'.toString() and question.pointid!='' and question.pointLeaf==0">
231
+            and p.pointall like concat('%',#{question.pointall},'%')
232
+        </if>
227 233
         <if test="question.hashear!=null and question.hashear == 1">
228 234
             and q.hashear=1
229 235
         </if>

+ 7
- 0
sstudy/src/main/resources/mapper/subjectbook/PointMapper.xml Просмотреть файл

@@ -35,4 +35,11 @@
35 35
         )
36 36
     </select>
37 37
 
38
+    <!--根据知识点ID获取知识点信息-->
39
+    <select id="getPointInfoById" resultType="com.xhkjedu.sstudy.model.subjectbook.TPoint">
40
+        select pointid,pointname,pointall,
41
+         (select count(*) from t_point p where p.pointpid=#{pointid}) sonnum
42
+        from t_point where pointid=#{pointid}
43
+    </select>
44
+
38 45
 </mapper>

Загрузка…
Отмена
Сохранить