Browse Source

试题、资源列表sharenum获取完善

tags/正式3.11.0
雍文秀 1 year ago
parent
commit
8308cad3e6

+ 14
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/controller/resource/ResourceController.java View File

165
         return new ResultVo(0,"更新下载次数成功");
165
         return new ResultVo(0,"更新下载次数成功");
166
     }
166
     }
167
 
167
 
168
+    /**
169
+     * @Description 我的空间(网页、app端)
170
+     * @Date 2023/9/1 15:39
171
+     * @Author YWX
172
+     * @Param [tResource]
173
+     * @Return com.xhkjedu.vo.ResultVo
174
+     **/
168
     @PostMapping("/my_list")
175
     @PostMapping("/my_list")
169
     public ResultVo myList(@RequestBody TResource tResource) {
176
     public ResultVo myList(@RequestBody TResource tResource) {
170
         Integer page = tResource.getPage();
177
         Integer page = tResource.getPage();
179
         return new ResultVo(0,"获取教师备课资源列表成功",pageResult);
186
         return new ResultVo(0,"获取教师备课资源列表成功",pageResult);
180
     }
187
     }
181
 
188
 
189
+    /**
190
+     * @Description 我的空间(课堂端)
191
+     * @Date 2023/9/1 15:38
192
+     * @Author YWX
193
+     * @Param [tResource]
194
+     * @Return com.xhkjedu.vo.ResultVo
195
+     **/
182
     @PostMapping("/my_list2")
196
     @PostMapping("/my_list2")
183
     public ResultVo myList2(@RequestBody TResource tResource) {
197
     public ResultVo myList2(@RequestBody TResource tResource) {
184
         Integer createid = tResource.getCreateid();
198
         Integer createid = tResource.getCreateid();

+ 3
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/mapper/question/QuestionMapper.java View File

101
     //更新分享过伙伴校试题的时间
101
     //更新分享过伙伴校试题的时间
102
     void batchUpdateTime(@Param("list") List<Integer> schoolIds, @Param("shareqid") String shareqid
102
     void batchUpdateTime(@Param("list") List<Integer> schoolIds, @Param("shareqid") String shareqid
103
             ,@Param("timestamp") int timestamp);
103
             ,@Param("timestamp") int timestamp);
104
+
105
+    //试题是否分享过
106
+    List<Map<String, String>> listShareNumByIds(@Param("shareqids") String shareqids);
104
 }
107
 }

+ 3
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/mapper/resource/ResourceMapper.java View File

87
     //更新分享过伙伴校资源的时间
87
     //更新分享过伙伴校资源的时间
88
     void batchUpdateTime(@Param("list") List<Integer> schoolIds,@Param("resourceid") String resourceid
88
     void batchUpdateTime(@Param("list") List<Integer> schoolIds,@Param("resourceid") String resourceid
89
             ,@Param("timestamp") int timestamp);
89
             ,@Param("timestamp") int timestamp);
90
+
91
+    //资源是否分享过
92
+    List<Map<String, String>> listShareNumByIds(@Param("shareqids") String shareqids);
90
 }
93
 }

+ 46
- 5
sstudy/src/main/java/com/xhkjedu/sstudy/service/question/QuestionService.java View File

15
 import com.xhkjedu.utils.N_Utils;
15
 import com.xhkjedu.utils.N_Utils;
16
 import com.xhkjedu.vo.ResultVo;
16
 import com.xhkjedu.vo.ResultVo;
17
 import org.springframework.beans.BeanUtils;
17
 import org.springframework.beans.BeanUtils;
18
-import org.springframework.scheduling.annotation.Async;
19
 import org.springframework.stereotype.Service;
18
 import org.springframework.stereotype.Service;
20
 import org.springframework.transaction.annotation.Transactional;
19
 import org.springframework.transaction.annotation.Transactional;
21
 import org.springframework.util.CollectionUtils;
20
 import org.springframework.util.CollectionUtils;
89
 
88
 
90
     //获取列表
89
     //获取列表
91
     public List <Map<String, Object>> findAll(TQuestion question) {
90
     public List <Map<String, Object>> findAll(TQuestion question) {
92
-        return questionMapper.findAll(question);
91
+        List<Map<String, Object>> list = questionMapper.findAll(question);
92
+        Integer schoolid = question.getSchoolid();
93
+        if(N_Utils.isEmptyInteger(schoolid)) return list;
94
+        String shareqids = list.stream().filter(m -> schoolid.equals(m.get("schoolid")) && !m.get("belong").equals(10))
95
+                               .map(m -> m.get("questionid").toString()).collect(Collectors.joining("','"));
96
+        List<Map<String, String>> shareList = questionMapper.listShareNumByIds(shareqids);
97
+        for (Map<String, Object> map : list) {
98
+            setShareNum(shareList, map);
99
+        }
100
+        return list;
93
     }
101
     }
94
 
102
 
95
     /**
103
     /**
272
         List<Map<String, Object>> list = questionMapper.listForSelect(question);
280
         List<Map<String, Object>> list = questionMapper.listForSelect(question);
273
         String questionids = list.stream().filter(m -> m.get("qlevel").toString().equals("2")).map(
281
         String questionids = list.stream().filter(m -> m.get("qlevel").toString().equals("2")).map(
274
                 m -> m.get("questionid").toString()).collect(Collectors.joining("','"));
282
                 m -> m.get("questionid").toString()).collect(Collectors.joining("','"));
283
+        boolean rtn = false;
284
+        List<Map<String, String>> sonList;
275
         if (N_Utils.isNotEmpty(questionids)) {
285
         if (N_Utils.isNotEmpty(questionids)) {
276
-            List<Map<String, String>> sonList = questionMapper.listSonQuestionForSelect(questionids);
277
-            for (Map<String, Object> map : list) {
286
+            sonList = questionMapper.listSonQuestionForSelect(questionids);
287
+            rtn = true;
288
+        } else {
289
+            sonList = null;
290
+        }
291
+
292
+        Integer createid = question.getCreateid();
293
+        String shareqids = list.stream().filter(m -> createid.equals(m.get("createid")) && !m.get("belong").equals(10))
294
+                               .map(m -> m.get("questionid").toString()).collect(Collectors.joining("','"));
295
+        List<Map<String, String>> shareList = questionMapper.listShareNumByIds(shareqids);
296
+        for (Map<String, Object> map : list) {
297
+            setShareNum(shareList, map);
298
+            if (rtn) {
278
                 setSonQList(sonList, map);
299
                 setSonQList(sonList, map);
279
             }
300
             }
280
         }
301
         }
281
         return list;
302
         return list;
282
     }
303
     }
283
 
304
 
305
+    /**
306
+     * @Description 试题是否分享过
307
+     * @Date 2023/9/1 14:28
308
+     * @Author YWX
309
+     * @Param [shareList, map]
310
+     * @Return void
311
+     **/
312
+    private void setShareNum(List<Map<String, String>> shareList, Map<String, Object> map) {
313
+        Object shareqid = map.get("questionid");
314
+        Object sharenum = 0;
315
+        if (N_Utils.isListNotEmpty(shareList)) {
316
+            for (Map<String, String> s : shareList) {
317
+                if (s.get("shareqid").equals(shareqid)) {
318
+                    sharenum = s.get("sharenum");
319
+                    break;
320
+                }
321
+            }
322
+        }
323
+        map.put("sharenum", sharenum);
324
+    }
325
+
284
     /**
326
     /**
285
      * @Description 处理试题子题
327
      * @Description 处理试题子题
286
      * @Date 2023/8/16 8:38
328
      * @Date 2023/8/16 8:38
288
      * @Param [sonList, map]
330
      * @Param [sonList, map]
289
      * @Return void
331
      * @Return void
290
      **/
332
      **/
291
-    @Async("asyncPoolTaskExecutor")
292
     public void setSonQList(List<Map<String, String>> sonList, Map<String, Object> map) {
333
     public void setSonQList(List<Map<String, String>> sonList, Map<String, Object> map) {
293
         if (map.get("qlevel").toString().equals("2")) {
334
         if (map.get("qlevel").toString().equals("2")) {
294
             Object questionid = map.get("questionid");
335
             Object questionid = map.get("questionid");

+ 38
- 2
sstudy/src/main/java/com/xhkjedu/sstudy/service/resource/ResourceService.java View File

147
 
147
 
148
     //获取列表
148
     //获取列表
149
     public List <Map> findAll(TResource tResource) {
149
     public List <Map> findAll(TResource tResource) {
150
-        return resourceMapper.findAll(tResource);
150
+        List<Map> list = resourceMapper.findAll(tResource);
151
+        Integer schoolid = tResource.getSchoolid();
152
+        if(N_Utils.isEmptyInteger(schoolid)) return list;
153
+        String shareqids = list.stream().filter(m -> schoolid.equals(m.get("schoolid")) && !m.get("belong").equals(10))
154
+                               .map(m -> m.get("resourceid").toString()).collect(Collectors.joining("','"));
155
+        List<Map<String, String>> shareList = resourceMapper.listShareNumByIds(shareqids);
156
+        for (Map map : list) {
157
+            setShareNum(shareList, map);
158
+        }
159
+        return list;
151
     }
160
     }
152
 
161
 
153
     //分享
162
     //分享
230
      * @return java.util.List<com.xhkjedu.model.resource.TResource>
239
      * @return java.util.List<com.xhkjedu.model.resource.TResource>
231
      **/
240
      **/
232
     public List<Map> listMyResource(TResource resource) {
241
     public List<Map> listMyResource(TResource resource) {
233
-        return resourceMapper.listMyResource(resource);
242
+        List<Map> list = resourceMapper.listMyResource(resource);
243
+        String shareqids = list.stream().map(m -> m.get("resourceid").toString()).collect(Collectors.joining("','"));
244
+        List<Map<String, String>> shareList = resourceMapper.listShareNumByIds(shareqids);
245
+        for (Map map : list) {
246
+            setShareNum(shareList, map);
247
+        }
248
+        return list;
249
+    }
250
+
251
+    /**
252
+     * @Description 资源是否分享过
253
+     * @Date 2023/9/1 15:12
254
+     * @Author YWX
255
+     * @Param [shareList, map]
256
+     * @Return void
257
+     **/
258
+    private void setShareNum(List<Map<String, String>> shareList, Map<String, Object> map) {
259
+        Object shareqid = map.get("resourceid");
260
+        Object sharenum = 0;
261
+        if (N_Utils.isListNotEmpty(shareList)) {
262
+            for (Map<String, String> s : shareList) {
263
+                if (s.get("resourcepid").equals(shareqid)) {
264
+                    sharenum = s.get("sharenum");
265
+                    break;
266
+                }
267
+            }
268
+        }
269
+        map.put("sharenum", sharenum);
234
     }
270
     }
235
 
271
 
236
     /**
272
     /**

+ 6
- 1
sstudy/src/main/resources/mapper/question/QuestionMapper.xml View File

199
         select q.questionid,q.score,q.complexity,q.qstem,q.qstemtxt,q.qoption,q.qanswer,q.qanalyze
199
         select q.questionid,q.score,q.complexity,q.qstem,q.qstemtxt,q.qoption,q.qanswer,q.qanalyze
200
         ,q.qtypeid,q.qtypename,q.count,q.ctype,q.source,q.year,q.region,q.schoolname
200
         ,q.qtypeid,q.qtypename,q.count,q.ctype,q.source,q.year,q.region,q.schoolname
201
         ,q.qlevel,q.hearfile,q.hashear,q.belong,q.createid,q.schoolid
201
         ,q.qlevel,q.hearfile,q.hashear,q.belong,q.createid,q.schoolid
202
-        ,(select count(*) from t_question q2 where q2.shareqid=q.questionid and q2.qstate=1 and q.schoolid=#{question.schoolid})sharenum
203
         from t_question q
202
         from t_question q
204
         <if test="question.pointid!=null and question.pointid!='0'.toString() and question.pointid!=''">
203
         <if test="question.pointid!=null and question.pointid!='0'.toString() and question.pointid!=''">
205
             left join t_question_point qp on q.questionid = qp.questionid
204
             left join t_question_point qp on q.questionid = qp.questionid
265
         and q.qlevel &lt; 3
264
         and q.qlevel &lt; 3
266
         group by q.questionid order by q.createtime desc
265
         group by q.questionid order by q.createtime desc
267
     </select>
266
     </select>
267
+    <!--试题是否分享过-->
268
+    <select id="listShareNumByIds" resultType="java.util.Map">
269
+        select shareqid,count(*) as sharenum
270
+        from t_question where qstate=1 and shareqid in('${shareqids}')
271
+        group by shareqid
272
+    </select>
268
 
273
 
269
     <select id="listSonQuestionForSelect" resultType="java.util.Map">
274
     <select id="listSonQuestionForSelect" resultType="java.util.Map">
270
         select q.questionid,q.questionpid,q.score,q.complexity,q.qstem,q.qstemtxt,q.qoption,q.qanswer,q.qanalyze
275
         select q.questionid,q.questionpid,q.score,q.complexity,q.qstem,q.qstemtxt,q.qoption,q.qanswer,q.qanalyze

+ 6
- 2
sstudy/src/main/resources/mapper/resource/ResourceMapper.xml View File

14
         rd.directorid,r.resourceclass,r.resourcetype,r.readcount,r.downcount,r.pdfurl,r.converted,r.resourcecover
14
         rd.directorid,r.resourceclass,r.resourcetype,r.readcount,r.downcount,r.pdfurl,r.converted,r.resourcecover
15
         ,r.comm,r.duration,r.resourcesize,r.mp4code,r.createid,r.belong,r.schoolid
15
         ,r.comm,r.duration,r.resourcesize,r.mp4code,r.createid,r.belong,r.schoolid
16
         ,r.resourcegrade,r.source,r.year,r.region,r.schoolname
16
         ,r.resourcegrade,r.source,r.year,r.region,r.schoolname
17
-        ,(select count(*) from t_resource r2 where r2.resourcepid=r.resourceid and r.resourcestate=1)sharenum
18
         from t_resource r left join t_user u on u.userid=r.createid
17
         from t_resource r left join t_user u on u.userid=r.createid
19
         left join t_resource_director rd on r.resourceid=rd.resourceid
18
         left join t_resource_director rd on r.resourceid=rd.resourceid
20
         <if test="resource.belong!=null and resource.belong==5">
19
         <if test="resource.belong!=null and resource.belong==5">
89
         select r.resourceid,r.resourcename,r.createtime,r.suffix,u.username createname,r.resourceurl,rd.lsbid,
88
         select r.resourceid,r.resourcename,r.createtime,r.suffix,u.username createname,r.resourceurl,rd.lsbid,
90
         rd.directorid,r.resourceclass,r.resourcetype,r.readcount,r.downcount,r.pdfurl,r.converted,r.resourcecover
89
         rd.directorid,r.resourceclass,r.resourcetype,r.readcount,r.downcount,r.pdfurl,r.converted,r.resourcecover
91
         ,r.comm,r.duration,r.resourcesize,r.mp4code
90
         ,r.comm,r.duration,r.resourcesize,r.mp4code
92
-        ,(select count(*) from t_resource r2 where r2.resourcepid=r.resourceid and r.resourcestate=1)sharenum
93
         from t_resource r left join t_user u on u.userid=r.createid
91
         from t_resource r left join t_user u on u.userid=r.createid
94
         left join t_resource_director rd on r.resourceid=rd.resourceid
92
         left join t_resource_director rd on r.resourceid=rd.resourceid
95
         where r.resourcestate=1 and r.level=#{resource.level} and r.createid=#{resource.createid}
93
         where r.resourcestate=1 and r.level=#{resource.level} and r.createid=#{resource.createid}
110
         </if>
108
         </if>
111
         order by r.createtime desc,r.resourcename,r.resourceid
109
         order by r.createtime desc,r.resourcename,r.resourceid
112
     </select>
110
     </select>
111
+    <!--资源是否分享过-->
112
+    <select id="listShareNumByIds" resultType="java.util.Map">
113
+        select resourcepid,count(*) as sharenum
114
+        from t_resource where resourcestate=1 and resourcepid in('${shareqids}')
115
+        group by resourcepid
116
+    </select>
113
 
117
 
114
     <!--详情-->
118
     <!--详情-->
115
     <resultMap id="resourceResult" type="com.xhkjedu.sstudy.vo.resource.ResourceVo">
119
     <resultMap id="resourceResult" type="com.xhkjedu.sstudy.vo.resource.ResourceVo">

Loading…
Cancel
Save