Browse Source

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

tags/正式3.11.0
王宁 1 year ago
parent
commit
ab01b1aaff

+ 29
- 1
sstudy/src/main/java/com/xhkjedu/sstudy/controller/question/QuestionController.java View File

62
         Integer pageSize = tQuestion.getPageSize();
62
         Integer pageSize = tQuestion.getPageSize();
63
         N_Utils.validation(new Object[]{page,"显示页码",1,pageSize,"显示条数",1});
63
         N_Utils.validation(new Object[]{page,"显示页码",1,pageSize,"显示条数",1});
64
         PageHelper.startPage(page, pageSize);
64
         PageHelper.startPage(page, pageSize);
65
-        List<QuestionVo> list = tQuestionService.findAll(tQuestion);
65
+        List<Map<String, Object>> list = tQuestionService.findAll(tQuestion);
66
         PageResult pageResult = PageUtil.getPageResult(new PageInfo(list));
66
         PageResult pageResult = PageUtil.getPageResult(new PageInfo(list));
67
         return new ResultVo(0,"获取列表成功",pageResult);
67
         return new ResultVo(0,"获取列表成功",pageResult);
68
     }
68
     }
169
         return new ResultVo(0, "保存成功",list);
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 View File

20
 
20
 
21
 import javax.annotation.Resource;
21
 import javax.annotation.Resource;
22
 import java.util.List;
22
 import java.util.List;
23
+import java.util.Map;
23
 
24
 
24
 /**
25
 /**
25
  * @author ywx
26
  * @author ywx
87
         Integer pageSize = tResource.getPageSize();
88
         Integer pageSize = tResource.getPageSize();
88
         N_Utils.validation(new Object[]{page,"显示页码",1,pageSize,"显示条数",1});
89
         N_Utils.validation(new Object[]{page,"显示页码",1,pageSize,"显示条数",1});
89
         PageHelper.startPage(page, pageSize);
90
         PageHelper.startPage(page, pageSize);
90
-        List<TResource> list = resourceService.findAll(tResource);
91
+        List<Map> list = resourceService.findAll(tResource);
91
         PageResult pageResult = PageUtil.getPageResult(new PageInfo(list));
92
         PageResult pageResult = PageUtil.getPageResult(new PageInfo(list));
92
         return new ResultVo(0,"获取列表成功",pageResult);
93
         return new ResultVo(0,"获取列表成功",pageResult);
93
     }
94
     }
128
         tResource.setLevel(1);//资源级别1校本
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
     @PostMapping("/update_downcount")
160
     @PostMapping("/update_downcount")
132
     public ResultVo updateDownCount(@RequestBody TResource tResource) {
161
     public ResultVo updateDownCount(@RequestBody TResource tResource) {
133
         String resourceid = tResource.getResourceid();
162
         String resourceid = tResource.getResourceid();
145
         N_Utils.validation(new Object[]{page,"显示页码",1,pageSize,"显示条数",1,createid,"教师id",1
174
         N_Utils.validation(new Object[]{page,"显示页码",1,pageSize,"显示条数",1,createid,"教师id",1
146
                 ,level,"资源级别",1});
175
                 ,level,"资源级别",1});
147
         PageHelper.startPage(page, pageSize);
176
         PageHelper.startPage(page, pageSize);
148
-        List<TResource> list = resourceService.listMyResource(tResource);
177
+        List<Map> list = resourceService.listMyResource(tResource);
149
         PageResult pageResult = PageUtil.getPageResult(new PageInfo(list));
178
         PageResult pageResult = PageUtil.getPageResult(new PageInfo(list));
150
         return new ResultVo(0,"获取教师备课资源列表成功",pageResult);
179
         return new ResultVo(0,"获取教师备课资源列表成功",pageResult);
151
     }
180
     }
155
         Integer createid = tResource.getCreateid();
184
         Integer createid = tResource.getCreateid();
156
         N_Utils.validation(new Object[]{createid,"教师id",1});
185
         N_Utils.validation(new Object[]{createid,"教师id",1});
157
         tResource.setLevel(2);
186
         tResource.setLevel(2);
158
-        List<TResource> list = resourceService.listMyResource(tResource);
187
+        List<Map> list = resourceService.listMyResource(tResource);
159
         return new ResultVo(0,"获取我的备课列表成功",list);
188
         return new ResultVo(0,"获取我的备课列表成功",list);
160
     }
189
     }
161
 
190
 

+ 11
- 1
sstudy/src/main/java/com/xhkjedu/sstudy/mapper/question/QuestionMapper.java View File

43
      * @Date 2020/6/9 8:48
43
      * @Date 2020/6/9 8:48
44
      * @return java.util.List<com.xhkjedu.model.question.TQuestion>
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
 
98
 
99
     //子题集合
99
     //子题集合
100
     List<Map<String, String>> listSonQuestionForSelect(@Param("questionids") String questionids);
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 View File

7
 import org.springframework.stereotype.Repository;
7
 import org.springframework.stereotype.Repository;
8
 
8
 
9
 import java.util.List;
9
 import java.util.List;
10
+import java.util.Map;
10
 
11
 
11
 @Repository
12
 @Repository
12
 public interface ResourceMapper extends TkMapper<TResource> {
13
 public interface ResourceMapper extends TkMapper<TResource> {
20
     ResourceVo findById2(@Param("resourceid") String resourceid);
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
     void updateDownCount(@Param("resourceid") String resourceid);
27
     void updateDownCount(@Param("resourceid") String resourceid);
48
      * @Date 2020/7/9 11:44
49
      * @Date 2020/7/9 11:44
49
      * @return java.util.List<com.xhkjedu.model.resource.TResource>
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
     //根据模块和资源id获取资源数量
78
     //根据模块和资源id获取资源数量
78
     Integer getResourceNumByLevelAndResourceid(@Param("resourceid") String resourceid);
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 View File

7
 import javax.persistence.Table;
7
 import javax.persistence.Table;
8
 import javax.persistence.Transient;
8
 import javax.persistence.Transient;
9
 import java.util.List;
9
 import java.util.List;
10
+import java.util.Map;
10
 
11
 
11
 @Table(name = "t_question")
12
 @Table(name = "t_question")
12
 @Data
13
 @Data
50
     //组题次数
51
     //组题次数
51
     private Integer count;
52
     private Integer count;
52
 
53
 
53
-    //资源归属1平台1区平台3学校4个人(搜索时5我的收藏 6我的上传)
54
+    //资源归属1平台1区平台3学校4个人10伙伴校(搜索时5我的收藏 6我的上传)
54
     private Integer belong;
55
     private Integer belong;
55
 
56
 
56
     //试题类型1单体2母题3子题
57
     //试题类型1单体2母题3子题
125
 
126
 
126
     @Transient
127
     @Transient
127
     private List<TQuestion> questions;//子题集合
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 View File

13
 import com.xhkjedu.sstudy.vo.question.QuestionVo;
13
 import com.xhkjedu.sstudy.vo.question.QuestionVo;
14
 import com.xhkjedu.sstudy.vo.subjectbook.DirectorVo;
14
 import com.xhkjedu.sstudy.vo.subjectbook.DirectorVo;
15
 import com.xhkjedu.utils.N_Utils;
15
 import com.xhkjedu.utils.N_Utils;
16
+import com.xhkjedu.vo.ResultVo;
17
+import org.springframework.beans.BeanUtils;
16
 import org.springframework.scheduling.annotation.Async;
18
 import org.springframework.scheduling.annotation.Async;
17
 import org.springframework.stereotype.Service;
19
 import org.springframework.stereotype.Service;
18
 import org.springframework.transaction.annotation.Transactional;
20
 import org.springframework.transaction.annotation.Transactional;
86
     }
88
     }
87
 
89
 
88
     //获取列表
90
     //获取列表
89
-    public List <QuestionVo> findAll(TQuestion question) {
91
+    public List <Map<String, Object>> findAll(TQuestion question) {
90
         return questionMapper.findAll(question);
92
         return questionMapper.findAll(question);
91
     }
93
     }
92
 
94
 
475
     public List<Map> listPointsByQuestionid(String questionid) {
477
     public List<Map> listPointsByQuestionid(String questionid) {
476
         return questionPointMapper.listPointsByQuestionid(questionid);
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 View File

15
 import com.xhkjedu.sstudy.vo.resource.ResourceVo;
15
 import com.xhkjedu.sstudy.vo.resource.ResourceVo;
16
 import com.xhkjedu.vo.ResultVo;
16
 import com.xhkjedu.vo.ResultVo;
17
 import lombok.extern.slf4j.Slf4j;
17
 import lombok.extern.slf4j.Slf4j;
18
+import org.springframework.beans.BeanUtils;
18
 import org.springframework.stereotype.Service;
19
 import org.springframework.stereotype.Service;
19
 import org.springframework.transaction.annotation.Transactional;
20
 import org.springframework.transaction.annotation.Transactional;
20
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
21
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
21
 
22
 
22
 import javax.annotation.Resource;
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
  * @author ywx
28
  * @author ywx
145
     }
146
     }
146
 
147
 
147
     //获取列表
148
     //获取列表
148
-    public List <TResource> findAll(TResource tResource) {
149
+    public List <Map> findAll(TResource tResource) {
149
         return resourceMapper.findAll(tResource);
150
         return resourceMapper.findAll(tResource);
150
     }
151
     }
151
 
152
 
228
      * @Date 2020/7/9 11:45
229
      * @Date 2020/7/9 11:45
229
      * @return java.util.List<com.xhkjedu.model.resource.TResource>
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
         return resourceMapper.listMyResource(resource);
233
         return resourceMapper.listMyResource(resource);
233
     }
234
     }
234
 
235
 
333
         String resourceid = resource.getResourceid();
334
         String resourceid = resource.getResourceid();
334
         Integer createid = resource.getCreateid();
335
         Integer createid = resource.getCreateid();
335
         int timestamp = N_Utils.getSecondTimestamp();
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
         List<TResourceDirector> directors = new ArrayList<>(groups.size());
339
         List<TResourceDirector> directors = new ArrayList<>(groups.size());
340
+        List<Integer> schoolIds = new ArrayList<>();//已分享过的学校集合
338
         try {
341
         try {
339
             for (TGuideGroup g : groups) {
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
                 TResource r = new TResource();
348
                 TResource r = new TResource();
341
                 String id = StudyUtil.getId();
349
                 String id = StudyUtil.getId();
342
                 r.setResourceid(id);
350
                 r.setResourceid(id);
366
                 r.setCreateid(createid);
374
                 r.setCreateid(createid);
367
                 r.setCreatetime(timestamp);
375
                 r.setCreatetime(timestamp);
368
                 r.setBelong(10);
376
                 r.setBelong(10);
369
-                r.setSchoolid(g.getSchoolid());
377
+                r.setSchoolid(schoolid);
370
                 r.setResourcepid(resourceid);
378
                 r.setResourcepid(resourceid);
371
                 resourceMapper.insertSelective(r);
379
                 resourceMapper.insertSelective(r);
372
 
380
 
379
                 rd.setDirectorid(resource.getDirectorid());
387
                 rd.setDirectorid(resource.getDirectorid());
380
                 directors.add(rd);
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
         } catch (Exception e) {
392
         } catch (Exception e) {
384
             log.error("分享伙伴校出错:" + e.getMessage());
393
             log.error("分享伙伴校出错:" + e.getMessage());
385
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
394
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
387
         }
396
         }
388
         return new ResultVo(0, "分享成功");
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 View File

134
         from t_question q where q.qlevel=3 and q.questionpid=#{questionid} order by q.sorder
134
         from t_question q where q.qlevel=3 and q.questionpid=#{questionid} order by q.sorder
135
     </select>
135
     </select>
136
     <!--管理端试题列表-->
136
     <!--管理端试题列表-->
137
-    <select id="findAll" resultType="com.xhkjedu.sstudy.vo.question.QuestionVo">
137
+    <select id="findAll" resultType="java.util.Map">
138
         select q.questionid,q.score,q.complexity,q.ctype,q.qstem,q.qoption,q.qanswer,q.qanalyze,q.belong,q.createid
138
         select q.questionid,q.score,q.complexity,q.ctype,q.qstem,q.qoption,q.qanswer,q.qanalyze,q.belong,q.createid
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
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
         from t_question q
141
         from t_question q
141
         <if test="question.lsbid!=null and question.lsbid!='0'.toString() and question.lsbid!=''">
142
         <if test="question.lsbid!=null and question.lsbid!='0'.toString() and question.lsbid!=''">
142
             left join t_question_director qd on q.questionid=qd.questionid
143
             left join t_question_director qd on q.questionid=qd.questionid
148
         <if test="question.belong==0">
149
         <if test="question.belong==0">
149
             and (q.belong in(1,2)
150
             and (q.belong in(1,2)
150
             <if test="question.schoolid!=null">
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
             </if>
153
             </if>
153
             <if test="question.createid!=null">
154
             <if test="question.createid!=null">
154
                 or (q.belong=4 and q.createid=#{question.createid})
155
                 or (q.belong=4 and q.createid=#{question.createid})
164
         <if test="question.belong==3">
165
         <if test="question.belong==3">
165
             and q.schoolid=#{question.schoolid}
166
             and q.schoolid=#{question.schoolid}
166
         </if>
167
         </if>
168
+        <if test="question.belong==10">
169
+            and q.schoolid=#{question.schoolid} and q.belong=#{question.belong}
170
+        </if>
167
         <if test="question.subjectid!=null and question.subjectid!='0'.toString() and question.subjectid!=''">
171
         <if test="question.subjectid!=null and question.subjectid!='0'.toString() and question.subjectid!=''">
168
             and q.subjectid=#{question.subjectid}
172
             and q.subjectid=#{question.subjectid}
169
         </if>
173
         </if>
237
     <!--章节、知识点选题-->
241
     <!--章节、知识点选题-->
238
     <select id="listForSelect" resultType="java.util.Map">
242
     <select id="listForSelect" resultType="java.util.Map">
239
         select q.questionid,q.score,q.complexity,q.qstem,q.qstemtxt,q.qoption,q.qanswer,q.qanalyze
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
         from t_question q
247
         from t_question q
243
         <if test="question.pointid!=null and question.pointid!='0'.toString() and question.pointid!=''">
248
         <if test="question.pointid!=null and question.pointid!='0'.toString() and question.pointid!=''">
244
             left join t_question_point qp on q.questionid = qp.questionid
249
             left join t_question_point qp on q.questionid = qp.questionid
274
         <if test="question.belong==0">
279
         <if test="question.belong==0">
275
             and (q.belong in(1,2)
280
             and (q.belong in(1,2)
276
             <if test="question.schoolid!=null">
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
             </if>
283
             </if>
279
             <if test="question.createid!=null">
284
             <if test="question.createid!=null">
280
                 or (q.belong=4 and q.createid=#{question.createid})
285
                 or (q.belong=4 and q.createid=#{question.createid})
290
         <if test="question.belong==3">
295
         <if test="question.belong==3">
291
             and q.schoolid=#{question.schoolid}
296
             and q.schoolid=#{question.schoolid}
292
         </if>
297
         </if>
298
+        <if test="question.belong==10">
299
+            and q.schoolid=#{question.schoolid} and q.belong=#{question.belong}
300
+        </if>
293
         <if test="question.belong!=null and question.belong!=0">
301
         <if test="question.belong!=null and question.belong!=0">
294
             <if test="question.belong==4 or question.belong==6">
302
             <if test="question.belong==4 or question.belong==6">
295
                 and q.createid=#{question.createid}
303
                 and q.createid=#{question.createid}
331
     <insert id="saveBathQuestion" parameterType="com.xhkjedu.sstudy.model.question.TQuestion">
339
     <insert id="saveBathQuestion" parameterType="com.xhkjedu.sstudy.model.question.TQuestion">
332
         INSERT INTO t_question (questionid,qstem,qstemtxt,qoption,qanswer,qanalyze,score,complexity,
340
         INSERT INTO t_question (questionid,qstem,qstemtxt,qoption,qanswer,qanalyze,score,complexity,
333
                                 ctype,hashear,hearfile,qtypeid,qtypename, subjectid,qlevel,snum,sorder,questionpid,
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
         VALUES
343
         VALUES
336
         <foreach collection ="list" item="p" index= "index" separator =",">
344
         <foreach collection ="list" item="p" index= "index" separator =",">
337
             (#{p.questionid},#{p.qstem},#{p.qstemtxt},#{p.qoption},#{p.qanswer},#{p.qanalyze},#{p.score},#{p.complexity},
345
             (#{p.questionid},#{p.qstem},#{p.qstemtxt},#{p.qoption},#{p.qanswer},#{p.qanalyze},#{p.score},#{p.complexity},
338
              #{p.ctype},#{p.hashear},#{p.hearfile},#{p.qtypeid},#{p.qtypename},#{p.subjectid},#{p.qlevel},#{p.snum},#{p.sorder},#{p.questionpid},
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
         </foreach>
348
         </foreach>
341
     </insert>
349
     </insert>
342
 
350
 
344
     <select id="getQuestionHasHearNum" resultType="java.lang.Integer">
352
     <select id="getQuestionHasHearNum" resultType="java.lang.Integer">
345
         select count(*) from t_question where hashear=1 and qstate=1 and subjectid=#{subjectid}
353
         select count(*) from t_question where hashear=1 and qstate=1 and subjectid=#{subjectid}
346
     </select>
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
 </mapper>
386
 </mapper>

+ 33
- 4
sstudy/src/main/resources/mapper/resource/ResourceMapper.xml View File

9
         delete from t_resource where resourceid=#{resourceid}
9
         delete from t_resource where resourceid=#{resourceid}
10
     </delete>
10
     </delete>
11
     <!--列表-->
11
     <!--列表-->
12
-    <select id="findAll" resultType="com.xhkjedu.sstudy.model.resource.TResource">
12
+    <select id="findAll" resultType="java.util.Map">
13
         select r.resourceid,r.resourcename,r.createtime,r.suffix,u.username createname,r.resourceurl,rd.lsbid,
13
         select r.resourceid,r.resourcename,r.createtime,r.suffix,u.username createname,r.resourceurl,rd.lsbid,
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
15
         ,r.comm,r.duration,r.resourcesize,r.mp4code,r.createid,r.belong
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
17
         from t_resource r left join t_user u on u.userid=r.createid
18
         from t_resource r left join t_user u on u.userid=r.createid
18
         left join t_resource_director rd on r.resourceid=rd.resourceid
19
         left join t_resource_director rd on r.resourceid=rd.resourceid
19
         <if test="resource.belong!=null and resource.belong==5">
20
         <if test="resource.belong!=null and resource.belong==5">
87
     </select>
88
     </select>
88
     <!--教师备课、预习导学资源列表-->
89
     <!--教师备课、预习导学资源列表-->
89
     <!--2020.11.16 教师备课只获取自己上传到个人空间文件,不获取收藏的文件-->
90
     <!--2020.11.16 教师备课只获取自己上传到个人空间文件,不获取收藏的文件-->
90
-    <select id="listMyResource" resultType="com.xhkjedu.sstudy.vo.resource.ResourceVo">
91
+    <select id="listMyResource" resultType="java.util.Map">
91
         select r.resourceid,r.resourcename,r.createtime,r.suffix,u.username createname,r.resourceurl,rd.lsbid,
92
         select r.resourceid,r.resourcename,r.createtime,r.suffix,u.username createname,r.resourceurl,rd.lsbid,
92
         rd.directorid,r.resourceclass,r.resourcetype,r.readcount,r.downcount,r.pdfurl,r.converted,r.resourcecover
93
         rd.directorid,r.resourceclass,r.resourcetype,r.readcount,r.downcount,r.pdfurl,r.converted,r.resourcecover
93
         ,r.comm,r.duration,r.resourcesize,r.mp4code
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
         from t_resource r left join t_user u on u.userid=r.createid
96
         from t_resource r left join t_user u on u.userid=r.createid
95
         left join t_resource_director rd on r.resourceid=rd.resourceid
97
         left join t_resource_director rd on r.resourceid=rd.resourceid
96
         where r.resourcestate=1 and r.level=#{resource.level} and r.createid=#{resource.createid}
98
         where r.resourcestate=1 and r.level=#{resource.level} and r.createid=#{resource.createid}
177
     <select id="studentVideoList" resultType="com.xhkjedu.sstudy.model.resource.TResource">
179
     <select id="studentVideoList" resultType="com.xhkjedu.sstudy.model.resource.TResource">
178
         select r.resourceid,r.resourcename,r.createtime,r.suffix,u.username createname
180
         select r.resourceid,r.resourcename,r.createtime,r.suffix,u.username createname
179
         ,r.readcount,r.comm,r.resourceurl,r.resourcecover,r.duration,r.resourcesize
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
         from t_resource r left join t_user u on u.userid=r.createid
183
         from t_resource r left join t_user u on u.userid=r.createid
182
         left join t_resource_director rd on r.resourceid=rd.resourceid
184
         left join t_resource_director rd on r.resourceid=rd.resourceid
183
         where r.resourcestate=1 and (r.belong in(1,2) or (r.belong=3 and r.schoolid=#{resource.schoolid}))
185
         where r.resourcestate=1 and (r.belong in(1,2) or (r.belong=3 and r.schoolid=#{resource.schoolid}))
231
     <select id="studentVideoWebList" resultType="com.xhkjedu.sstudy.model.resource.TResource">
233
     <select id="studentVideoWebList" resultType="com.xhkjedu.sstudy.model.resource.TResource">
232
         select r.resourceid,r.resourcename,r.createtime,r.suffix,u.username createname
234
         select r.resourceid,r.resourcename,r.createtime,r.suffix,u.username createname
233
         ,r.readcount,r.comm,r.resourceurl,r.resourcecover,r.duration,r.resourcesize,r.mp4code
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
         from t_resource r left join t_user u on u.userid=r.createid
237
         from t_resource r left join t_user u on u.userid=r.createid
236
         left join t_resource_director rd on r.resourceid=rd.resourceid
238
         left join t_resource_director rd on r.resourceid=rd.resourceid
237
         where r.resourcestate=1 and (r.belong in(1,2) or (r.belong=3 and r.schoolid=#{resource.schoolid}))
239
         where r.resourcestate=1 and (r.belong in(1,2) or (r.belong=3 and r.schoolid=#{resource.schoolid}))
269
     <select id="getResourceNumByLevelAndResourceid" resultType="java.lang.Integer">
271
     <select id="getResourceNumByLevelAndResourceid" resultType="java.lang.Integer">
270
         select count(*) from t_resource where level=2 and resourceid=#{resourceid}
272
         select count(*) from t_resource where level=2 and resourceid=#{resourceid}
271
     </select>
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
 </mapper>
302
 </mapper>

Loading…
Cancel
Save