Explorar el Código

Merge remote-tracking branch 'origin/ywx' into wn

tags/正式3.11.0
王宁 hace 1 año
padre
commit
ab01b1aaff

+ 29
- 1
sstudy/src/main/java/com/xhkjedu/sstudy/controller/question/QuestionController.java Ver fichero

@@ -62,7 +62,7 @@ public class QuestionController {
62 62
         Integer pageSize = tQuestion.getPageSize();
63 63
         N_Utils.validation(new Object[]{page,"显示页码",1,pageSize,"显示条数",1});
64 64
         PageHelper.startPage(page, pageSize);
65
-        List<QuestionVo> list = tQuestionService.findAll(tQuestion);
65
+        List<Map<String, Object>> list = tQuestionService.findAll(tQuestion);
66 66
         PageResult pageResult = PageUtil.getPageResult(new PageInfo(list));
67 67
         return new ResultVo(0,"获取列表成功",pageResult);
68 68
     }
@@ -169,4 +169,32 @@ public class QuestionController {
169 169
         return new ResultVo(0, "保存成功",list);
170 170
     }
171 171
 
172
+    /**
173
+     * @Description 分享集团校
174
+     * @Date 2023/8/29 9:25
175
+     * @Author YWX
176
+     * @Param [question]
177
+     * @Return com.xhkjedu.vo.ResultVo
178
+     **/
179
+    @PostMapping("/share_gs")
180
+    public ResultVo shareGroupSchool(@RequestBody TQuestion question) {
181
+        N_Utils.validation(new Object[]{question.getQuestionid(), "试题id", 2, question.getCreateid(), "用户id", 1});
182
+        return tQuestionService.shareGroupSchool(question);
183
+    }
184
+
185
+    /**
186
+     * @Description 获取分享的伙伴校
187
+     * @Date 2023/8/29 11:22
188
+     * @Author YWX
189
+     * @Param [question]
190
+     * @Return com.xhkjedu.vo.ResultVo
191
+     **/
192
+    @PostMapping("/list_share_ps")
193
+    public ResultVo listSharePartnerSchool(@RequestBody TQuestion question) {
194
+        String questionid = question.getQuestionid();
195
+        N_Utils.validation(new Object[]{questionid, "试题id", 2});
196
+        List<Map<String, Object>> list=tQuestionService.listSharePartnerSchool(questionid);
197
+        return new ResultVo(0,"获取分享的伙伴校成功",list);
198
+    }
199
+
172 200
 }

+ 32
- 3
sstudy/src/main/java/com/xhkjedu/sstudy/controller/resource/ResourceController.java Ver fichero

@@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.RestController;
20 20
 
21 21
 import javax.annotation.Resource;
22 22
 import java.util.List;
23
+import java.util.Map;
23 24
 
24 25
 /**
25 26
  * @author ywx
@@ -87,7 +88,7 @@ public class ResourceController {
87 88
         Integer pageSize = tResource.getPageSize();
88 89
         N_Utils.validation(new Object[]{page,"显示页码",1,pageSize,"显示条数",1});
89 90
         PageHelper.startPage(page, pageSize);
90
-        List<TResource> list = resourceService.findAll(tResource);
91
+        List<Map> list = resourceService.findAll(tResource);
91 92
         PageResult pageResult = PageUtil.getPageResult(new PageInfo(list));
92 93
         return new ResultVo(0,"获取列表成功",pageResult);
93 94
     }
@@ -128,6 +129,34 @@ public class ResourceController {
128 129
         tResource.setLevel(1);//资源级别1校本
129 130
     }
130 131
 
132
+    /**
133
+     * @Description 获取分享的伙伴校
134
+     * @Date 2023/8/29 14:48
135
+     * @Author YWX
136
+     * @Param [tResource]
137
+     * @Return com.xhkjedu.vo.ResultVo
138
+     **/
139
+    @PostMapping("/list_share_ps")
140
+    public ResultVo listSharePartnerSchool(@RequestBody TResource tResource) {
141
+        String resourceid = tResource.getResourceid();
142
+        N_Utils.validation(new Object[]{resourceid, "资源id", 2});
143
+        List<Map<String, Object>> list=resourceService.listSharePartnerSchool(resourceid);
144
+        return new ResultVo(0,"获取分享的伙伴校成功",list);
145
+    }
146
+
147
+    /**
148
+     * @Description 分享集团校
149
+     * @Date 2023/8/29 16:11
150
+     * @Author YWX
151
+     * @Param [tResource]
152
+     * @Return com.xhkjedu.vo.ResultVo
153
+     **/
154
+    @PostMapping("/share_gs")
155
+    public ResultVo shareGroupSchool(@RequestBody TResource tResource) {
156
+        N_Utils.validation(new Object[]{tResource.getResourceid(), "资源id", 2, tResource.getCreateid(), "用户id", 1});
157
+        return resourceService.shareGroupSchool(tResource);
158
+    }
159
+
131 160
     @PostMapping("/update_downcount")
132 161
     public ResultVo updateDownCount(@RequestBody TResource tResource) {
133 162
         String resourceid = tResource.getResourceid();
@@ -145,7 +174,7 @@ public class ResourceController {
145 174
         N_Utils.validation(new Object[]{page,"显示页码",1,pageSize,"显示条数",1,createid,"教师id",1
146 175
                 ,level,"资源级别",1});
147 176
         PageHelper.startPage(page, pageSize);
148
-        List<TResource> list = resourceService.listMyResource(tResource);
177
+        List<Map> list = resourceService.listMyResource(tResource);
149 178
         PageResult pageResult = PageUtil.getPageResult(new PageInfo(list));
150 179
         return new ResultVo(0,"获取教师备课资源列表成功",pageResult);
151 180
     }
@@ -155,7 +184,7 @@ public class ResourceController {
155 184
         Integer createid = tResource.getCreateid();
156 185
         N_Utils.validation(new Object[]{createid,"教师id",1});
157 186
         tResource.setLevel(2);
158
-        List<TResource> list = resourceService.listMyResource(tResource);
187
+        List<Map> list = resourceService.listMyResource(tResource);
159 188
         return new ResultVo(0,"获取我的备课列表成功",list);
160 189
     }
161 190
 

+ 11
- 1
sstudy/src/main/java/com/xhkjedu/sstudy/mapper/question/QuestionMapper.java Ver fichero

@@ -43,7 +43,7 @@ public interface QuestionMapper extends TkMapper<TQuestion> {
43 43
      * @Date 2020/6/9 8:48
44 44
      * @return java.util.List<com.xhkjedu.model.question.TQuestion>
45 45
      **/
46
-    List<QuestionVo> findAll(@Param("question") TQuestion question);
46
+    List<Map<String, Object>> findAll(@Param("question") TQuestion question);
47 47
 
48 48
     /**
49 49
      * 更新单个试题状态
@@ -98,4 +98,14 @@ public interface QuestionMapper extends TkMapper<TQuestion> {
98 98
 
99 99
     //子题集合
100 100
     List<Map<String, String>> listSonQuestionForSelect(@Param("questionids") String questionids);
101
+
102
+    //获取试题详情及关联章节、知识点、伙伴校
103
+    TQuestion getQuestionAndDirectorPointById(String questionid);
104
+
105
+    //获取分享的伙伴校
106
+    List<Map<String, Object>> listSharePartnerSchool(@Param("questionid") String questionid);
107
+
108
+    //更新分享过伙伴校试题的时间
109
+    void batchUpdateTime(@Param("list") List<Integer> schoolIds, @Param("shareqid") String shareqid
110
+            ,@Param("timestamp") int timestamp);
101 111
 }

+ 12
- 2
sstudy/src/main/java/com/xhkjedu/sstudy/mapper/resource/ResourceMapper.java Ver fichero

@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Param;
7 7
 import org.springframework.stereotype.Repository;
8 8
 
9 9
 import java.util.List;
10
+import java.util.Map;
10 11
 
11 12
 @Repository
12 13
 public interface ResourceMapper extends TkMapper<TResource> {
@@ -20,7 +21,7 @@ public interface ResourceMapper extends TkMapper<TResource> {
20 21
     ResourceVo findById2(@Param("resourceid") String resourceid);
21 22
 
22 23
     //列表
23
-    List<TResource> findAll(@Param("resource") TResource tResource);
24
+    List<Map> findAll(@Param("resource") TResource tResource);
24 25
 
25 26
     //更新下载次数
26 27
     void updateDownCount(@Param("resourceid") String resourceid);
@@ -48,7 +49,7 @@ public interface ResourceMapper extends TkMapper<TResource> {
48 49
      * @Date 2020/7/9 11:44
49 50
      * @return java.util.List<com.xhkjedu.model.resource.TResource>
50 51
      **/
51
-    List<TResource> listMyResource(@Param("resource") TResource resource);
52
+    List<Map> listMyResource(@Param("resource") TResource resource);
52 53
 
53 54
 
54 55
     /**
@@ -77,4 +78,13 @@ public interface ResourceMapper extends TkMapper<TResource> {
77 78
     //根据模块和资源id获取资源数量
78 79
     Integer getResourceNumByLevelAndResourceid(@Param("resourceid") String resourceid);
79 80
 
81
+    //获取分享的伙伴校
82
+    List<Map<String, Object>> listSharePartnerSchool(@Param("resourceid") String resourceid);
83
+
84
+    //获取资源详情及关联章节、伙伴校
85
+    TResource getResourceAndSchoolById(@Param("resourceid") String resourceid);
86
+
87
+    //更新分享过伙伴校资源的时间
88
+    void batchUpdateTime(@Param("list") List<Integer> schoolIds,@Param("resourceid") String resourceid
89
+            ,@Param("timestamp") int timestamp);
80 90
 }

+ 5
- 1
sstudy/src/main/java/com/xhkjedu/sstudy/model/question/TQuestion.java Ver fichero

@@ -7,6 +7,7 @@ import javax.persistence.Id;
7 7
 import javax.persistence.Table;
8 8
 import javax.persistence.Transient;
9 9
 import java.util.List;
10
+import java.util.Map;
10 11
 
11 12
 @Table(name = "t_question")
12 13
 @Data
@@ -50,7 +51,7 @@ public class TQuestion extends BaseBean {
50 51
     //组题次数
51 52
     private Integer count;
52 53
 
53
-    //资源归属1平台1区平台3学校4个人(搜索时5我的收藏 6我的上传)
54
+    //资源归属1平台1区平台3学校4个人10伙伴校(搜索时5我的收藏 6我的上传)
54 55
     private Integer belong;
55 56
 
56 57
     //试题类型1单体2母题3子题
@@ -125,4 +126,7 @@ public class TQuestion extends BaseBean {
125 126
 
126 127
     @Transient
127 128
     private List<TQuestion> questions;//子题集合
129
+    @Transient
130
+    private List<Map> schools;//伙伴校
131
+    private String shareqid;//分享试题id
128 132
 }

+ 85
- 1
sstudy/src/main/java/com/xhkjedu/sstudy/service/question/QuestionService.java Ver fichero

@@ -13,6 +13,8 @@ import com.xhkjedu.sstudy.vo.question.QuestionCollectVo;
13 13
 import com.xhkjedu.sstudy.vo.question.QuestionVo;
14 14
 import com.xhkjedu.sstudy.vo.subjectbook.DirectorVo;
15 15
 import com.xhkjedu.utils.N_Utils;
16
+import com.xhkjedu.vo.ResultVo;
17
+import org.springframework.beans.BeanUtils;
16 18
 import org.springframework.scheduling.annotation.Async;
17 19
 import org.springframework.stereotype.Service;
18 20
 import org.springframework.transaction.annotation.Transactional;
@@ -86,7 +88,7 @@ public class QuestionService {
86 88
     }
87 89
 
88 90
     //获取列表
89
-    public List <QuestionVo> findAll(TQuestion question) {
91
+    public List <Map<String, Object>> findAll(TQuestion question) {
90 92
         return questionMapper.findAll(question);
91 93
     }
92 94
 
@@ -475,4 +477,86 @@ public class QuestionService {
475 477
     public List<Map> listPointsByQuestionid(String questionid) {
476 478
         return questionPointMapper.listPointsByQuestionid(questionid);
477 479
     }
480
+
481
+    /**
482
+     * @Description 分享伙伴校
483
+     * @Date 2023/8/29 9:26
484
+     * @Author YWX
485
+     * @Param [question]
486
+     * @Return com.xhkjedu.vo.ResultVo
487
+     **/
488
+    @Transactional(rollbackFor = Exception.class)
489
+    public ResultVo shareGroupSchool(TQuestion question) {
490
+        List<Map> schools = question.getSchools();
491
+        if (N_Utils.isListEmpty(schools)) return new ResultVo(1, "伙伴校不能为空");
492
+        String shareqid = question.getQuestionid();
493
+        Integer createid = question.getCreateid();
494
+        int timestamp = N_Utils.getSecondTimestamp();
495
+        TQuestion q = questionMapper.getQuestionAndDirectorPointById(shareqid);
496
+        List<TQuestionPoint> questionPoints = q.getQuestionPoints();
497
+        List<TQuestionDirector> questionDirectors = q.getDirectors();
498
+        List<Integer> schoolids = q.getSchools().stream().map(s -> (Integer) s.get("schoolid")).collect(Collectors.toList());
499
+        List<TQuestion> questions = new ArrayList<>();//未分享过的学校试题集合
500
+        List<TQuestionPoint> points = new ArrayList<>();//未分享过的学校试题知识点集合
501
+        List<TQuestionDirector> directors = new ArrayList<>();//未分享过的学校试题章节集合
502
+        List<Integer> schoolIds = new ArrayList<>();//已分享过的学校集合
503
+        for (Map<String, Integer> school : schools) {
504
+            Integer schoolid = school.get("schoolid");
505
+            if (N_Utils.numInList(schoolid, schoolids)) {//已分享过的学校需更新试题时间
506
+                schoolIds.add(schoolid);
507
+                continue;
508
+            }
509
+            //试题
510
+            TQuestion tq = new TQuestion();
511
+            BeanUtils.copyProperties(q, tq);
512
+            String questionid = StudyUtil.getId();
513
+            tq.setQuestionid(questionid);
514
+            tq.setCount(0);
515
+            tq.setCreateid(createid);
516
+            tq.setCreatetime(timestamp);
517
+            tq.setBelong(10);
518
+            tq.setSchoolid(schoolid);
519
+            tq.setShareqid(shareqid);
520
+            questions.add(tq);
521
+
522
+            //试题关联知识点
523
+            for (TQuestionPoint p : questionPoints) {
524
+                TQuestionPoint qp = new TQuestionPoint();
525
+                BeanUtils.copyProperties(p, qp);
526
+                qp.setQpid(StudyUtil.getId());
527
+                qp.setQuestionid(questionid);
528
+                qp.setCreateid(createid);
529
+                qp.setCreatetime(timestamp);
530
+                points.add(qp);
531
+            }
532
+
533
+            //试题关联章节
534
+            for (TQuestionDirector d : questionDirectors) {
535
+                TQuestionDirector qd = new TQuestionDirector();
536
+                BeanUtils.copyProperties(d, qd);
537
+                qd.setQdid(StudyUtil.getId());
538
+                qd.setQuestionid(questionid);
539
+                qd.setCreateid(createid);
540
+                qd.setCreatetime(timestamp);
541
+                directors.add(qd);
542
+            }
543
+        }
544
+
545
+        if (N_Utils.isListNotEmpty(questions)) questionMapper.saveBathQuestion(questions);
546
+        if (N_Utils.isListNotEmpty(points)) questionPointMapper.batchSave(points);
547
+        if (N_Utils.isListNotEmpty(directors)) questionDirectorMapper.batchSave(directors);
548
+        if (N_Utils.isListNotEmpty(schoolIds)) questionMapper.batchUpdateTime(schoolIds, shareqid, timestamp);
549
+        return new ResultVo(0, "分享成功");
550
+    }
551
+
552
+    /**
553
+     * @Description 获取分享的伙伴校
554
+     * @Date 2023/8/29 11:22
555
+     * @Author YWX
556
+     * @Param [questionid]
557
+     * @Return java.util.List<java.util.Map>
558
+     **/
559
+    public List<Map<String, Object>> listSharePartnerSchool(String questionid) {
560
+        return questionMapper.listSharePartnerSchool(questionid);
561
+    }
478 562
 }

+ 82
- 7
sstudy/src/main/java/com/xhkjedu/sstudy/service/resource/ResourceService.java Ver fichero

@@ -15,13 +15,14 @@ import com.xhkjedu.sstudy.vo.resource.ResourceCollectVo;
15 15
 import com.xhkjedu.sstudy.vo.resource.ResourceVo;
16 16
 import com.xhkjedu.vo.ResultVo;
17 17
 import lombok.extern.slf4j.Slf4j;
18
+import org.springframework.beans.BeanUtils;
18 19
 import org.springframework.stereotype.Service;
19 20
 import org.springframework.transaction.annotation.Transactional;
20 21
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
21 22
 
22 23
 import javax.annotation.Resource;
23
-import java.util.ArrayList;
24
-import java.util.List;
24
+import java.util.*;
25
+import java.util.stream.Collectors;
25 26
 
26 27
 /**
27 28
  * @author ywx
@@ -145,7 +146,7 @@ public class ResourceService {
145 146
     }
146 147
 
147 148
     //获取列表
148
-    public List <TResource> findAll(TResource tResource) {
149
+    public List <Map> findAll(TResource tResource) {
149 150
         return resourceMapper.findAll(tResource);
150 151
     }
151 152
 
@@ -228,7 +229,7 @@ public class ResourceService {
228 229
      * @Date 2020/7/9 11:45
229 230
      * @return java.util.List<com.xhkjedu.model.resource.TResource>
230 231
      **/
231
-    public List<TResource> listMyResource(TResource resource) {
232
+    public List<Map> listMyResource(TResource resource) {
232 233
         return resourceMapper.listMyResource(resource);
233 234
     }
234 235
 
@@ -333,10 +334,17 @@ public class ResourceService {
333 334
         String resourceid = resource.getResourceid();
334 335
         Integer createid = resource.getCreateid();
335 336
         int timestamp = N_Utils.getSecondTimestamp();
336
-        TResource vo = resourceMapper.selectByPrimaryKey(resourceid);
337
+        TResource vo = resourceMapper.getResourceAndSchoolById(resourceid);
338
+        List<Integer> schoolids = vo.getGuideGroups().stream().map(TGuideGroup::getSchoolid).collect(Collectors.toList());
337 339
         List<TResourceDirector> directors = new ArrayList<>(groups.size());
340
+        List<Integer> schoolIds = new ArrayList<>();//已分享过的学校集合
338 341
         try {
339 342
             for (TGuideGroup g : groups) {
343
+                Integer schoolid = g.getSchoolid();
344
+                if (N_Utils.numInList(schoolid, schoolids)) {//已分享过的学校需更新试题时间
345
+                    schoolIds.add(schoolid);
346
+                    continue;
347
+                }
340 348
                 TResource r = new TResource();
341 349
                 String id = StudyUtil.getId();
342 350
                 r.setResourceid(id);
@@ -366,7 +374,7 @@ public class ResourceService {
366 374
                 r.setCreateid(createid);
367 375
                 r.setCreatetime(timestamp);
368 376
                 r.setBelong(10);
369
-                r.setSchoolid(g.getSchoolid());
377
+                r.setSchoolid(schoolid);
370 378
                 r.setResourcepid(resourceid);
371 379
                 resourceMapper.insertSelective(r);
372 380
 
@@ -379,7 +387,8 @@ public class ResourceService {
379 387
                 rd.setDirectorid(resource.getDirectorid());
380 388
                 directors.add(rd);
381 389
             }
382
-            resourceDirectorMapper.batchSave(directors);
390
+            if(N_Utils.isListNotEmpty(directors)) resourceDirectorMapper.batchSave(directors);
391
+            if (N_Utils.isListNotEmpty(schoolIds)) resourceMapper.batchUpdateTime(schoolIds, resourceid, timestamp);
383 392
         } catch (Exception e) {
384 393
             log.error("分享伙伴校出错:" + e.getMessage());
385 394
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -387,4 +396,70 @@ public class ResourceService {
387 396
         }
388 397
         return new ResultVo(0, "分享成功");
389 398
     }
399
+
400
+    /**
401
+     * @Description 获取分享的伙伴校
402
+     * @Date 2023/8/29 14:48
403
+     * @Author YWX
404
+     * @Param [resourceid]
405
+     * @Return java.util.List<java.util.Map>
406
+     **/
407
+    public List<Map<String, Object>> listSharePartnerSchool(String resourceid) {
408
+        return resourceMapper.listSharePartnerSchool(resourceid);
409
+    }
410
+
411
+    /**
412
+     * @Description 分享集团校
413
+     * @Date 2023/8/29 16:33
414
+     * @Author YWX
415
+     * @Param [tResource]
416
+     * @Return com.xhkjedu.vo.ResultVo
417
+     **/
418
+    @Transactional(rollbackFor = Exception.class)
419
+    public ResultVo shareGroupSchool(TResource tResource) {
420
+        List<TGuideGroup> groups = tResource.getGuideGroups();
421
+        if (N_Utils.isListEmpty(groups)) return new ResultVo(1, "伙伴校不能为空");
422
+        String resourcepid = tResource.getResourceid();
423
+        Integer createid = tResource.getCreateid();
424
+        int timestamp = N_Utils.getSecondTimestamp();
425
+        TResource r = resourceMapper.getResourceAndSchoolById(resourcepid);
426
+        List<Integer> schoolids = r.getGuideGroups().stream().map(TGuideGroup::getSchoolid).collect(Collectors.toList());
427
+        List<TResourceDirector> resourceDirectors = r.getDirectors();
428
+        List<TResourceDirector> directors = new ArrayList<>();
429
+        List<Integer> schoolIds = new ArrayList<>();//已分享过的学校集合
430
+        for (TGuideGroup group : groups) {
431
+            Integer schoolid = group.getSchoolid();
432
+            if (N_Utils.numInList(schoolid, schoolids)) {//已分享过的学校需更新资源时间
433
+                schoolIds.add(schoolid);
434
+                continue;
435
+            }
436
+            //资源
437
+            TResource tr = new TResource();
438
+            BeanUtils.copyProperties(r, tr);
439
+            String resourceid = StudyUtil.getId();
440
+            tr.setResourceid(resourceid);
441
+            tr.setReadcount(0);
442
+            tr.setDowncount(0);
443
+            tr.setCreateid(createid);
444
+            tr.setCreatetime(timestamp);
445
+            tr.setBelong(10);
446
+            tr.setSchoolid(schoolid);
447
+            tr.setResourcepid(resourcepid);
448
+            resourceMapper.insertSelective(tr);
449
+
450
+            //资源管理章节
451
+            for (TResourceDirector d : resourceDirectors) {
452
+                TResourceDirector rd = new TResourceDirector();
453
+                BeanUtils.copyProperties(d, rd);
454
+                rd.setRdid(StudyUtil.getId());
455
+                rd.setResourceid(resourceid);
456
+                rd.setCreateid(createid);
457
+                rd.setCreatetime(timestamp);
458
+                directors.add(rd);
459
+            }
460
+        }
461
+        if (N_Utils.isListNotEmpty(directors)) resourceDirectorMapper.batchSave(directors);
462
+        if (N_Utils.isListNotEmpty(schoolIds)) resourceMapper.batchUpdateTime(schoolIds, resourcepid, timestamp);
463
+        return new ResultVo(0, "分享成功");
464
+    }
390 465
 }

+ 46
- 8
sstudy/src/main/resources/mapper/question/QuestionMapper.xml Ver fichero

@@ -134,9 +134,10 @@
134 134
         from t_question q where q.qlevel=3 and q.questionpid=#{questionid} order by q.sorder
135 135
     </select>
136 136
     <!--管理端试题列表-->
137
-    <select id="findAll" resultType="com.xhkjedu.sstudy.vo.question.QuestionVo">
137
+    <select id="findAll" resultType="java.util.Map">
138 138
         select q.questionid,q.score,q.complexity,q.ctype,q.qstem,q.qoption,q.qanswer,q.qanalyze,q.belong,q.createid
139 139
         ,q.qtypeid,q.qtypename,q.createtime,q.count,q.qstate,q.source,q.year,q.region,q.schoolname,q.hashear,q.hearfile,q.qlevel
140
+        ,(select count(*) from t_question q2 where q2.shareqid=q.questionid and q2.qstate=1 and q.schoolid=#{question.schoolid})sharenum
140 141
         from t_question q
141 142
         <if test="question.lsbid!=null and question.lsbid!='0'.toString() and question.lsbid!=''">
142 143
             left join t_question_director qd on q.questionid=qd.questionid
@@ -148,7 +149,7 @@
148 149
         <if test="question.belong==0">
149 150
             and (q.belong in(1,2)
150 151
             <if test="question.schoolid!=null">
151
-                or (q.belong=3 and q.schoolid=#{question.schoolid})
152
+                or (q.belong in(3,10) and q.schoolid=#{question.schoolid})
152 153
             </if>
153 154
             <if test="question.createid!=null">
154 155
                 or (q.belong=4 and q.createid=#{question.createid})
@@ -164,6 +165,9 @@
164 165
         <if test="question.belong==3">
165 166
             and q.schoolid=#{question.schoolid}
166 167
         </if>
168
+        <if test="question.belong==10">
169
+            and q.schoolid=#{question.schoolid} and q.belong=#{question.belong}
170
+        </if>
167 171
         <if test="question.subjectid!=null and question.subjectid!='0'.toString() and question.subjectid!=''">
168 172
             and q.subjectid=#{question.subjectid}
169 173
         </if>
@@ -237,8 +241,9 @@
237 241
     <!--章节、知识点选题-->
238 242
     <select id="listForSelect" resultType="java.util.Map">
239 243
         select q.questionid,q.score,q.complexity,q.qstem,q.qstemtxt,q.qoption,q.qanswer,q.qanalyze
240
-        ,q.qtypeid,q.qtypename,q.count,q.ctype,q.source,q.year,q.region,q.schoolname,
241
-               q.qlevel,q.hearfile,q.hashear
244
+        ,q.qtypeid,q.qtypename,q.count,q.ctype,q.source,q.year,q.region,q.schoolname
245
+        ,q.qlevel,q.hearfile,q.hashear,q.belong,q.createid
246
+        ,(select count(*) from t_question q2 where q2.shareqid=q.questionid and q2.qstate=1 and q.schoolid=#{question.schoolid})sharenum
242 247
         from t_question q
243 248
         <if test="question.pointid!=null and question.pointid!='0'.toString() and question.pointid!=''">
244 249
             left join t_question_point qp on q.questionid = qp.questionid
@@ -274,7 +279,7 @@
274 279
         <if test="question.belong==0">
275 280
             and (q.belong in(1,2)
276 281
             <if test="question.schoolid!=null">
277
-                or (q.belong=3 and q.schoolid=#{question.schoolid})
282
+                or (q.belong in(3,10) and q.schoolid=#{question.schoolid})
278 283
             </if>
279 284
             <if test="question.createid!=null">
280 285
                 or (q.belong=4 and q.createid=#{question.createid})
@@ -290,6 +295,9 @@
290 295
         <if test="question.belong==3">
291 296
             and q.schoolid=#{question.schoolid}
292 297
         </if>
298
+        <if test="question.belong==10">
299
+            and q.schoolid=#{question.schoolid} and q.belong=#{question.belong}
300
+        </if>
293 301
         <if test="question.belong!=null and question.belong!=0">
294 302
             <if test="question.belong==4 or question.belong==6">
295 303
                 and q.createid=#{question.createid}
@@ -331,12 +339,12 @@
331 339
     <insert id="saveBathQuestion" parameterType="com.xhkjedu.sstudy.model.question.TQuestion">
332 340
         INSERT INTO t_question (questionid,qstem,qstemtxt,qoption,qanswer,qanalyze,score,complexity,
333 341
                                 ctype,hashear,hearfile,qtypeid,qtypename, subjectid,qlevel,snum,sorder,questionpid,
334
-                                qstate,source,year,region,schoolname,createid,createtime,belong,schoolid)
342
+                                qstate,source,year,region,schoolname,createid,createtime,belong,schoolid,shareqid)
335 343
         VALUES
336 344
         <foreach collection ="list" item="p" index= "index" separator =",">
337 345
             (#{p.questionid},#{p.qstem},#{p.qstemtxt},#{p.qoption},#{p.qanswer},#{p.qanalyze},#{p.score},#{p.complexity},
338 346
              #{p.ctype},#{p.hashear},#{p.hearfile},#{p.qtypeid},#{p.qtypename},#{p.subjectid},#{p.qlevel},#{p.snum},#{p.sorder},#{p.questionpid},
339
-             #{p.qstate},#{p.source},#{p.year},#{p.region},#{p.schoolname},#{p.createid},#{p.createtime},#{p.belong},#{p.schoolid})
347
+             #{p.qstate},#{p.source},#{p.year},#{p.region},#{p.schoolname},#{p.createid},#{p.createtime},#{p.belong},#{p.schoolid},#{p.shareqid})
340 348
         </foreach>
341 349
     </insert>
342 350
 
@@ -344,5 +352,35 @@
344 352
     <select id="getQuestionHasHearNum" resultType="java.lang.Integer">
345 353
         select count(*) from t_question where hashear=1 and qstate=1 and subjectid=#{subjectid}
346 354
     </select>
347
-
355
+    <!--获取试题详情及关联章节、知识点、伙伴校-->
356
+    <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>
360
+    </resultMap>
361
+    <select id="listPoint2" resultType="com.xhkjedu.sstudy.model.question.TQuestionPoint">
362
+        select * from t_question_point where questionid=#{questionid}
363
+    </select>
364
+    <select id="listDirector" resultType="com.xhkjedu.sstudy.model.question.TQuestionDirector">
365
+        select * from t_question_director where questionid=#{questionid}
366
+    </select>
367
+    <select id="listSchool" resultType="java.util.Map">
368
+        select schoolid from t_question where shareqid=#{questionid} group by schoolid
369
+    </select>
370
+    <select id="getQuestionAndDirectorPointById" resultMap="questionMap">
371
+        select * from t_question where questionid=#{questionid}
372
+    </select>
373
+    <!--获取分享的伙伴校-->
374
+    <select id="listSharePartnerSchool" resultType="java.util.Map">
375
+        select s.schoolid,s.schoolname
376
+        from t_question q left join t_school s on q.schoolid=s.schoolid
377
+        where q.shareqid=#{questionid} and s.schoolstate=1
378
+        group by s.schoolid order by s.schoolid
379
+    </select>
380
+    <!--更新分享过伙伴校试题的时间-->
381
+    <update id="batchUpdateTime">
382
+        update t_question set createtime=#{timestamp}
383
+        where shareqid=#{shareqid} and schoolid in
384
+        <foreach collection="list" item="schoolid" open="(" separator="," close=")">${schoolid}</foreach>
385
+    </update>
348 386
 </mapper>

+ 33
- 4
sstudy/src/main/resources/mapper/resource/ResourceMapper.xml Ver fichero

@@ -9,11 +9,12 @@
9 9
         delete from t_resource where resourceid=#{resourceid}
10 10
     </delete>
11 11
     <!--列表-->
12
-    <select id="findAll" resultType="com.xhkjedu.sstudy.model.resource.TResource">
12
+    <select id="findAll" resultType="java.util.Map">
13 13
         select r.resourceid,r.resourcename,r.createtime,r.suffix,u.username createname,r.resourceurl,rd.lsbid,
14 14
         rd.directorid,r.resourceclass,r.resourcetype,r.readcount,r.downcount,r.pdfurl,r.converted,r.resourcecover
15 15
         ,r.comm,r.duration,r.resourcesize,r.mp4code,r.createid,r.belong
16 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
17 18
         from t_resource r left join t_user u on u.userid=r.createid
18 19
         left join t_resource_director rd on r.resourceid=rd.resourceid
19 20
         <if test="resource.belong!=null and resource.belong==5">
@@ -87,10 +88,11 @@
87 88
     </select>
88 89
     <!--教师备课、预习导学资源列表-->
89 90
     <!--2020.11.16 教师备课只获取自己上传到个人空间文件,不获取收藏的文件-->
90
-    <select id="listMyResource" resultType="com.xhkjedu.sstudy.vo.resource.ResourceVo">
91
+    <select id="listMyResource" resultType="java.util.Map">
91 92
         select r.resourceid,r.resourcename,r.createtime,r.suffix,u.username createname,r.resourceurl,rd.lsbid,
92 93
         rd.directorid,r.resourceclass,r.resourcetype,r.readcount,r.downcount,r.pdfurl,r.converted,r.resourcecover
93 94
         ,r.comm,r.duration,r.resourcesize,r.mp4code
95
+        ,(select count(*) from t_resource r2 where r2.resourcepid=r.resourceid and r.resourcestate=1)sharenum
94 96
         from t_resource r left join t_user u on u.userid=r.createid
95 97
         left join t_resource_director rd on r.resourceid=rd.resourceid
96 98
         where r.resourcestate=1 and r.level=#{resource.level} and r.createid=#{resource.createid}
@@ -177,7 +179,7 @@
177 179
     <select id="studentVideoList" resultType="com.xhkjedu.sstudy.model.resource.TResource">
178 180
         select r.resourceid,r.resourcename,r.createtime,r.suffix,u.username createname
179 181
         ,r.readcount,r.comm,r.resourceurl,r.resourcecover,r.duration,r.resourcesize
180
-        ,r.resourcegrade,r.source,r.year,r.region,r.schoolname
182
+        ,r.resourcegrade,r.source,r.year,r.region,r.schoolname,r.belong
181 183
         from t_resource r left join t_user u on u.userid=r.createid
182 184
         left join t_resource_director rd on r.resourceid=rd.resourceid
183 185
         where r.resourcestate=1 and (r.belong in(1,2) or (r.belong=3 and r.schoolid=#{resource.schoolid}))
@@ -231,7 +233,7 @@
231 233
     <select id="studentVideoWebList" resultType="com.xhkjedu.sstudy.model.resource.TResource">
232 234
         select r.resourceid,r.resourcename,r.createtime,r.suffix,u.username createname
233 235
         ,r.readcount,r.comm,r.resourceurl,r.resourcecover,r.duration,r.resourcesize,r.mp4code
234
-        ,r.resourcegrade,r.source,r.year,r.region,r.schoolname,r.converted
236
+        ,r.resourcegrade,r.source,r.year,r.region,r.schoolname,r.converted,r.belong
235 237
         from t_resource r left join t_user u on u.userid=r.createid
236 238
         left join t_resource_director rd on r.resourceid=rd.resourceid
237 239
         where r.resourcestate=1 and (r.belong in(1,2) or (r.belong=3 and r.schoolid=#{resource.schoolid}))
@@ -269,5 +271,32 @@
269 271
     <select id="getResourceNumByLevelAndResourceid" resultType="java.lang.Integer">
270 272
         select count(*) from t_resource where level=2 and resourceid=#{resourceid}
271 273
     </select>
274
+    <!--获取分享的伙伴校-->
275
+    <select id="listSharePartnerSchool" resultType="java.util.Map">
276
+        select s.schoolid,s.schoolname
277
+        from t_resource r left join t_school s on r.schoolid=s.schoolid
278
+        where r.resourcepid=#{resourceid} and s.schoolstate=1
279
+        group by s.schoolid order by s.schoolid
280
+    </select>
281
+    <!--获取资源详情及关联章节、伙伴校-->
282
+    <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>
285
+    </resultMap>
286
+    <select id="listDirector" resultType="com.xhkjedu.sstudy.model.resource.TResourceDirector">
287
+        select * from t_resource_director where resourceid=#{resourceid}
288
+    </select>
289
+    <select id="listSchool" resultType="com.xhkjedu.sstudy.model.resource.TGuideGroup">
290
+        select schoolid from t_resource where resourcepid=#{resourceid} group by schoolid
291
+    </select>
292
+    <select id="getResourceAndSchoolById" resultMap="resourceMap">
293
+        select r.* from t_resource r where r.resourceid=#{resourceid}
294
+    </select>
295
+    <!--更新分享过伙伴校资源的时间-->
296
+    <update id="batchUpdateTime">
297
+        update t_resource set createtime=#{timestamp}
298
+        where resourcepid=#{resourceid} and schoolid in
299
+        <foreach collection="list" item="schoolid" open="(" separator="," close=")">${schoolid}</foreach>
300
+    </update>
272 301
 
273 302
 </mapper>

Loading…
Cancelar
Guardar