Bläddra i källkod

试题、资源列表搜索完善

tags/正式3.11.0
雍文秀 1 år sedan
förälder
incheckning
ad7492ba5e

+ 0
- 9
sstudy/src/main/java/com/xhkjedu/sstudy/mapper/question/QuestionMapper.java Visa fil

@@ -27,15 +27,6 @@ public interface QuestionMapper extends TkMapper<TQuestion> {
27 27
      **/
28 28
     Integer updateQuestionState(@Param("qstate") int qstate, @Param("delQuestionId") String delQuestionId);
29 29
 
30
-    /**
31
-     * 试题知识点列表
32
-     * @Param [qs]
33
-     * @Author ywx
34
-     * @Date 2020/6/8 16:37
35
-     * @return java.util.List<com.xhkjedu.vo.question.QuestionVo>
36
-     **/
37
-    List<QuestionVo> listQuestions(@Param("questions") List<QuestionVo> questions);
38
-
39 30
     /**
40 31
      * 列表
41 32
      * @Param [question]

+ 94
- 145
sstudy/src/main/resources/mapper/question/QuestionMapper.xml Visa fil

@@ -53,72 +53,57 @@
53 53
     </update>
54 54
     <!--试题知识点列表-->
55 55
     <resultMap id="questionResult" type="com.xhkjedu.sstudy.vo.question.QuestionVo">
56
-        <result property="questionid" column="questionid"></result>
57
-        <result property="score" column="score"></result>
58
-        <result property="complexity" column="complexity"></result>
59
-        <result property="ctype" column="ctype"></result>
60
-        <result property="qstem" column="qstem"></result>
61
-        <result property="qstemtxt" column="qstemtxt"></result>
62
-        <result property="qoption" column="qoption"></result>
63
-        <result property="qanswer" column="qanswer"></result>
64
-        <result property="qanalyze" column="qanalyze"></result>
65
-        <result property="qtypeid" column="qtypeid"></result>
66
-        <result property="qtypename" column="qtypename"></result>
67
-        <result property="createtime" column="createtime"></result>
68
-        <result property="createname" column="createname"></result>
69
-        <result property="count" column="count"></result>
70
-        <result property="directorid" column="directorid"></result>
71
-        <result property="directorname" column="directorname"></result>
72
-        <result property="hashear" column="hashear"></result>
73
-        <result property="hearfile" column="hearfile"></result>
74
-        <result property="belong" column="belong"></result>
75
-        <result property="createid" column="createid"></result>
76
-        <result property="source" column="source"></result>
77
-        <result property="year" column="year"></result>
78
-        <result property="region" column="region"></result>
79
-        <result property="schoolname" column="schoolname"></result>
80
-        <result property="schoolid" column="schoolid"></result>
81
-        <result property="subjectid" column="subjectid"></result>
82
-        <result property="areaall" column="areaall"></result>
83
-        <result property="qlevel" column="qlevel"></result>
56
+        <result property="questionid" column="questionid"/>
57
+        <result property="score" column="score"/>
58
+        <result property="complexity" column="complexity"/>
59
+        <result property="ctype" column="ctype"/>
60
+        <result property="qstem" column="qstem"/>
61
+        <result property="qstemtxt" column="qstemtxt"/>
62
+        <result property="qoption" column="qoption"/>
63
+        <result property="qanswer" column="qanswer"/>
64
+        <result property="qanalyze" column="qanalyze"/>
65
+        <result property="qtypeid" column="qtypeid"/>
66
+        <result property="qtypename" column="qtypename"/>
67
+        <result property="createtime" column="createtime"/>
68
+        <result property="createname" column="createname"/>
69
+        <result property="count" column="count"/>
70
+        <result property="directorid" column="directorid"/>
71
+        <result property="directorname" column="directorname"/>
72
+        <result property="hashear" column="hashear"/>
73
+        <result property="hearfile" column="hearfile"/>
74
+        <result property="belong" column="belong"/>
75
+        <result property="createid" column="createid"/>
76
+        <result property="source" column="source"/>
77
+        <result property="year" column="year"/>
78
+        <result property="region" column="region"/>
79
+        <result property="schoolname" column="schoolname"/>
80
+        <result property="schoolid" column="schoolid"/>
81
+        <result property="subjectid" column="subjectid"/>
82
+        <result property="areaall" column="areaall"/>
83
+        <result property="qlevel" column="qlevel"/>
84 84
         <collection property="points" ofType="com.xhkjedu.sstudy.vo.subjectbook.PointVo" javaType="java.util.List"
85 85
                     select="listPoint" column="{questionid=questionid}">
86 86
         </collection>
87 87
         <collection property="directors" ofType="com.xhkjedu.sstudy.vo.subjectbook.DirectorVo" javaType="java.util.List">
88
-            <result property="lsbid" column="lsbid"></result>
89
-            <result property="directorid" column="directorid"></result>
90
-            <result property="directorname" column="directorname"></result>
91
-            <result property="level" column="level"></result>
92
-            <result property="subjectid" column="subjectid"></result>
93
-            <result property="subjectname" column="subjectname"></result>
94
-            <result property="versionname" column="versionname"></result>
95
-            <result property="lsbname" column="lsbname"></result>
88
+            <result property="lsbid" column="lsbid"/>
89
+            <result property="directorid" column="directorid"/>
90
+            <result property="directorname" column="directorname"/>
91
+            <result property="level" column="level"/>
92
+            <result property="subjectid" column="subjectid"/>
93
+            <result property="subjectname" column="subjectname"/>
94
+            <result property="versionname" column="versionname"/>
95
+            <result property="lsbname" column="lsbname"/>
96 96
         </collection>
97 97
     </resultMap>
98
-    <resultMap id="pointResult" type="com.xhkjedu.sstudy.vo.subjectbook.PointVo">
99
-        <result property="pointid" column="pointid"></result>
100
-        <result property="pointname" column="pointname"></result>
101
-    </resultMap>
102
-    <select id="listPoint" resultMap="pointResult">
98
+    <select id="listPoint" resultType="com.xhkjedu.sstudy.vo.subjectbook.PointVo">
103 99
         select qp.pointid,p.pointname from t_question_point qp left join t_point p on qp.pointid = p.pointid
104 100
         where qp.questionid=#{questionid}
105 101
     </select>
106
-    <select id="listQuestions" resultMap="questionResult">
107
-        select q.questionid,q.score,q.complexity,q.ctype,q.qstem,q.qoption,q.qanswer,q.qanalyze,q.belong,q.hashear,q.hearfile
108
-        ,q.qtypeid,q.qtypename,q.createtime,u.username createname,q.count,qd.directorid,d.directorname,0 pointid
109
-        from t_question q left join t_user u on u.userid = q.createid
110
-        left join t_question_director qd on q.questionid=qd.questionid
111
-        left join t_director d on qd.directorid = d.directorid
112
-        where q.questionid in
113
-        <foreach item="question" collection="questions" open="(" separator="," close=")">
114
-            #{question.questionid}
115
-        </foreach>
116
-    </select>
117 102
     <!--详情-->
118 103
     <select id="findById" resultMap="questionResult">
119 104
         select q.questionid,q.score,q.complexity,q.ctype,q.qstem,q.qstemtxt,q.qoption,q.qanswer,q.qanalyze,q.belong
120 105
         ,q.qtypeid,q.qtypename,q.createtime,q.source,q.year,q.region,q.schoolname,q.subjectid,q.schoolid
121
-        ,qd.directorid,d.directorall directorname,d.lsbid,q.hashear,q.hearfile,q.qlevel,
106
+        ,qd.directorid,d.directorall as directorname,d.lsbid,q.hashear,q.hearfile,q.qlevel,
122 107
         sb.level,sb.subjectid,s.subjectname,v.versionname,sb.lsbname
123 108
         ,(select a.areaall from t_areazone a where a.areacode=q.region)areaall
124 109
         from t_question q left join t_question_director qd on q.questionid=qd.questionid
@@ -146,28 +131,33 @@
146 131
             left join t_question_collect qc on q.questionid = qc.questionid
147 132
         </if>
148 133
         <where>
149
-        <if test="question.belong==0">
150
-            and (q.belong in(1,2)
151
-            <if test="question.schoolid!=null">
152
-                or (q.belong in(3,10) and q.schoolid=#{question.schoolid})
153
-            </if>
154
-            <if test="question.createid!=null">
155
-                or (q.belong=4 and q.createid=#{question.createid})
156
-            </if>
157
-            )
158
-        </if>
159
-        <if test="question.belong>=3 and question.belong&lt;=4">
160
-            and q.belong=#{question.belong}
161
-        </if>
162
-        <if test="question.belong==2">
163
-            and q.belong in(1,2)
164
-        </if>
165
-        <if test="question.belong==3">
166
-            and q.schoolid=#{question.schoolid}
167
-        </if>
168
-        <if test="question.belong==10">
169
-            and q.schoolid=#{question.schoolid} and q.belong=#{question.belong}
170
-        </if>
134
+        <choose>
135
+            <when test="question.belong==0">
136
+                and (q.belong in(1,2)
137
+                <if test="question.schoolid!=null">
138
+                    or (q.belong in(3,10) and q.schoolid=#{question.schoolid})
139
+                </if>
140
+                <if test="question.createid!=null">
141
+                    or (q.belong=4 and q.createid=#{question.createid})
142
+                </if>
143
+                )
144
+            </when>
145
+            <when test="question.belong==2">
146
+                and q.belong in(1,2)
147
+            </when>
148
+            <when test="question.belong==3 or question.belong==10">
149
+                and q.schoolid=#{question.schoolid} and q.belong=#{question.belong}
150
+            </when>
151
+            <when test="question.belong==4">
152
+                and q.belong=#{question.belong} and q.createid=#{question.createid}
153
+            </when>
154
+            <when test="question.belong==5">
155
+                and qc.userid=#{question.createid}
156
+            </when>
157
+            <when test="question.belong==6">
158
+                and q.schoolid=#{question.schoolid} and q.createid=#{question.createid}
159
+            </when>
160
+        </choose>
171 161
         <if test="question.subjectid!=null and question.subjectid!='0'.toString() and question.subjectid!=''">
172 162
             and q.subjectid=#{question.subjectid}
173 163
         </if>
@@ -189,14 +179,6 @@
189 179
         <if test="question.hashear!=1 and question.qtypeid!=null and question.qtypeid!='0'.toString() and question.qtypeid!=''">
190 180
             and q.hashear=0 and q.qtypeid=#{question.qtypeid}
191 181
         </if>
192
-        <if test="question.belong!=null and question.belong!=0">
193
-            <if test="question.belong==4 or question.belong==6">
194
-                and q.createid=#{question.createid}
195
-            </if>
196
-            <if test="question.belong==5">
197
-                and qc.userid=#{question.createid}
198
-            </if>
199
-        </if>
200 182
         <if test="question.complexity!=null and question.complexity!=0">
201 183
             and q.complexity=#{question.complexity}
202 184
         </if>
@@ -208,36 +190,6 @@
208 190
         group by q.questionid order by q.qstate,q.createtime desc
209 191
     </select>
210 192
 
211
-    <!--章节、知识点选题-->
212
-    <!--<resultMap id="directPointQuestions" type="java.util.Map">
213
-        <result property="questionid" column="questionid"></result>
214
-        <result property="score" column="score"></result>
215
-        <result property="complexity" column="complexity"></result>
216
-        <result property="qstem" column="qstem"></result>
217
-        <result property="qoption" column="qoption"></result>
218
-        <result property="qanswer" column="qanswer"></result>
219
-        <result property="qanalyze" column="qanalyze"></result>
220
-        <result property="qtypeid" column="qtypeid"></result>
221
-        <result property="qtypename" column="qtypename"></result>
222
-        <result property="count" column="count"></result>
223
-        <result property="points" column="points"></result>
224
-        <result property="ctype" column="ctype"></result>
225
-        <result property="source" column="source"></result>
226
-        <result property="year" column="year"></result>
227
-        <result property="region" column="region"></result>
228
-        <result property="schoolname" column="schoolname"></result>
229
-        <result property="qlevel" column="qlevel"></result>
230
-        <result property="snum" column="snum"></result>
231
-        <result property="hashear" column="hashear"></result>
232
-        <result property="hearfile" column="hearfile"></result>
233
-        <collection property="sonqlist" ofType="java.util.Map"
234
-                    column="questionid" select="listSonQuestionForSelect">
235
-        </collection>
236
-        <collection property="points" ofType="java.util.Map" javaType="java.util.List"
237
-                    column="questionid" select="selectQuesitonPoints">
238
-        </collection>
239
-    </resultMap>-->
240
-
241 193
     <!--章节、知识点选题-->
242 194
     <select id="listForSelect" resultType="java.util.Map">
243 195
         select q.questionid,q.score,q.complexity,q.qstem,q.qstemtxt,q.qoption,q.qanswer,q.qanalyze
@@ -276,36 +228,33 @@
276 228
         <if test="question.complexity!=null and question.complexity!=0">
277 229
             and q.complexity=#{question.complexity}
278 230
         </if>
279
-        <if test="question.belong==0">
280
-            and (q.belong in(1,2)
281
-            <if test="question.schoolid!=null">
282
-                or (q.belong in(3,10) and q.schoolid=#{question.schoolid})
283
-            </if>
284
-            <if test="question.createid!=null">
285
-                or (q.belong=4 and q.createid=#{question.createid})
286
-            </if>
287
-            )
288
-        </if>
289
-        <if test="question.belong>=3 and question.belong&lt;=4">
290
-            and q.belong=#{question.belong}
291
-        </if>
292
-        <if test="question.belong==2">
293
-            and q.belong in(1,2)
294
-        </if>
295
-        <if test="question.belong==3">
296
-            and q.schoolid=#{question.schoolid}
297
-        </if>
298
-        <if test="question.belong==10">
299
-            and q.schoolid=#{question.schoolid} and q.belong=#{question.belong}
300
-        </if>
301
-        <if test="question.belong!=null and question.belong!=0">
302
-            <if test="question.belong==4 or question.belong==6">
303
-                and q.createid=#{question.createid}
304
-            </if>
305
-            <if test="question.belong==5">
231
+        <choose>
232
+            <when test="question.belong==0">
233
+                and (q.belong in(1,2)
234
+                <if test="question.schoolid!=null">
235
+                    or (q.belong in(3,10) and q.schoolid=#{question.schoolid})
236
+                </if>
237
+                <if test="question.createid!=null">
238
+                    or (q.belong=4 and q.createid=#{question.createid})
239
+                </if>
240
+                )
241
+            </when>
242
+            <when test="question.belong==2">
243
+                and q.belong in(1,2)
244
+            </when>
245
+            <when test="question.belong==3 or question.belong==10">
246
+                and q.schoolid=#{question.schoolid} and q.belong=#{question.belong}
247
+            </when>
248
+            <when test="question.belong==4">
249
+                and q.belong=#{question.belong} and q.createid=#{question.createid}
250
+            </when>
251
+            <when test="question.belong==5">
306 252
                 and qc.userid=#{question.createid}
307
-            </if>
308
-        </if>
253
+            </when>
254
+            <when test="question.belong==6">
255
+                and q.schoolid=#{question.schoolid} and q.createid=#{question.createid}
256
+            </when>
257
+        </choose>
309 258
         <if test="question.year!=null and question.year!=0">
310 259
             and FROM_UNIXTIME(q.createtime,'%Y')=#{question.year}
311 260
         </if>
@@ -354,9 +303,9 @@
354 303
     </select>
355 304
     <!--获取试题详情及关联章节、知识点、伙伴校-->
356 305
     <resultMap id="questionMap" type="com.xhkjedu.sstudy.model.question.TQuestion">
357
-        <collection property="questionPoints" select="listPoint2" column="questionid"></collection>
358
-        <collection property="directors" select="listDirector" column="questionid"></collection>
359
-        <collection property="schools" select="listSchool" column="questionid"></collection>
306
+        <collection property="questionPoints" select="listPoint2" column="questionid"/>
307
+        <collection property="directors" select="listDirector" column="questionid"/>
308
+        <collection property="schools" select="listSchool" column="questionid"/>
360 309
     </resultMap>
361 310
     <select id="listPoint2" resultType="com.xhkjedu.sstudy.model.question.TQuestionPoint">
362 311
         select * from t_question_point where questionid=#{questionid}

+ 29
- 32
sstudy/src/main/resources/mapper/resource/ResourceMapper.xml Visa fil

@@ -21,28 +21,33 @@
21 21
             left join t_resource_collect rc on r.resourceid = rc.resourceid
22 22
         </if>
23 23
         where r.resourcestate=1
24
-        <if test="resource.belong==0">
25
-            and (r.belong in(1,2)
26
-            <if test="resource.schoolid!=null">
27
-                or (r.belong in(3,10) and r.schoolid=#{resource.schoolid})
28
-            </if>
29
-            <if test="resource.createid!=null">
30
-                or (r.belong=4 and r.createid=#{resource.createid})
31
-            </if>
32
-            )
33
-        </if>
34
-        <if test="resource.belong>=3 and resource.belong&lt;=4">
35
-            and r.belong=#{resource.belong}
36
-        </if>
37
-        <if test="resource.belong==2">
38
-            and r.belong in(1,2)
39
-        </if>
40
-        <if test="resource.belong==3">
41
-            and r.schoolid=#{resource.schoolid}
42
-        </if>
43
-        <if test="resource.belong==10">
44
-            and r.schoolid=#{resource.schoolid} and r.belong=#{resource.belong}
45
-        </if>
24
+        <choose>
25
+            <when test="resource.belong==0">
26
+                and (r.belong in(1,2)
27
+                <if test="resource.schoolid!=null">
28
+                    or (r.belong in(3,10) and r.schoolid=#{resource.schoolid})
29
+                </if>
30
+                <if test="resource.createid!=null">
31
+                    or (r.belong=4 and r.createid=#{resource.createid})
32
+                </if>
33
+                )
34
+            </when>
35
+            <when test="resource.belong==2">
36
+                and r.belong in(1,2)
37
+            </when>
38
+            <when test="resource.belong==3 or resource.belong==10">
39
+                and r.schoolid=#{resource.schoolid} and r.belong=#{resource.belong}
40
+            </when>
41
+            <when test="resource.belong==4">
42
+                and r.schoolid=#{resource.schoolid} and r.createid=#{resource.createid}
43
+            </when>
44
+            <when test="resource.belong==5">
45
+                and rc.userid=#{resource.createid}
46
+            </when>
47
+            <when test="resource.belong==6">
48
+                and r.schoolid=#{resource.schoolid} and r.createid=#{resource.createid}
49
+            </when>
50
+        </choose>
46 51
         <if test="resource.resourcename!=null and resource.resourcename!=''">
47 52
             and r.resourcename like '%${resource.resourcename}%'
48 53
         </if>
@@ -64,14 +69,6 @@
64 69
         <if test="resource.resourcetype!=null and resource.resourcetype!=0">
65 70
             and r.resourcetype=#{resource.resourcetype}
66 71
         </if>
67
-        <if test="resource.createid!=null and resource.createid!=0">
68
-            <if test="resource.belong==4 or resource.belong==6">
69
-                and r.createid=#{resource.createid}
70
-            </if>
71
-            <if test="resource.belong==5">
72
-                and rc.userid=#{resource.createid}
73
-            </if>
74
-        </if>
75 72
         <if test="resource.year!=null and resource.year!=0">
76 73
             and FROM_UNIXTIME(r.createtime,'%Y')=#{resource.year}
77 74
         </if>
@@ -280,8 +277,8 @@
280 277
     </select>
281 278
     <!--获取资源详情及关联章节、伙伴校-->
282 279
     <resultMap id="resourceMap" type="com.xhkjedu.sstudy.model.resource.TResource">
283
-        <collection property="directors" select="listDirector" column="resourceid"></collection>
284
-        <collection property="guideGroups" select="listSchool" column="resourceid"></collection>
280
+        <collection property="directors" select="listDirector" column="resourceid"/>
281
+        <collection property="guideGroups" select="listSchool" column="resourceid"/>
285 282
     </resultMap>
286 283
     <select id="listDirector" resultType="com.xhkjedu.sstudy.model.resource.TResourceDirector">
287 284
         select * from t_resource_director where resourceid=#{resourceid}

Laddar…
Avbryt
Spara