Преглед на файлове

通知管理

tags/正式3.13.3
雍文秀 преди 1 година
родител
ревизия
d1c4f3f259
променени са 31 файла, в които са добавени 149 реда и са изтрити 383 реда
  1. 3
    0
      sapi/src/main/java/com/xhkjedu/sapi/mapper/notice/NoticeFileMapper.java
  2. 3
    0
      sapi/src/main/java/com/xhkjedu/sapi/mapper/notice/NoticeUserMapper.java
  3. 0
    3
      sapi/src/main/java/com/xhkjedu/sapi/model/notice/TNoticeUser.java
  4. 66
    6
      sapi/src/main/java/com/xhkjedu/sapi/service/notice/NoticeService.java
  5. 4
    0
      sapi/src/main/resources/mapper/notice/NoticeFileMapper.xml
  6. 1
    1
      sapi/src/main/resources/mapper/notice/NoticeMapper.xml
  7. 6
    2
      sapi/src/main/resources/mapper/notice/NoticeUserMapper.xml
  8. 0
    7
      sexam/src/main/java/com/xhkjedu/sexam/mapper/notice/NoticeClassMapper.java
  9. 0
    7
      sexam/src/main/java/com/xhkjedu/sexam/mapper/notice/NoticeSchoolMapper.java
  10. 0
    4
      sexam/src/main/java/com/xhkjedu/sexam/model/notice/TNotice.java
  11. 0
    27
      sexam/src/main/java/com/xhkjedu/sexam/model/notice/TNoticeClass.java
  12. 0
    27
      sexam/src/main/java/com/xhkjedu/sexam/model/notice/TNoticeSchool.java
  13. 0
    3
      sexam/src/main/java/com/xhkjedu/sexam/model/notice/TNoticeUser.java
  14. 0
    2
      sexam/src/main/java/com/xhkjedu/sexam/service/notice/NoticeService.java
  15. 0
    4
      sexam/src/main/resources/mapper/notice/NoticeMapper.xml
  16. 0
    4
      sexam/src/main/resources/mapper/notice/NoticeUserMapper.xml
  17. 0
    17
      slive/src/main/java/com/xhkjedu/slive/mapper/notice/NoticeClassMapper.java
  18. 0
    7
      slive/src/main/java/com/xhkjedu/slive/mapper/notice/NoticeMapper.java
  19. 0
    11
      slive/src/main/java/com/xhkjedu/slive/mapper/notice/NoticeSchoolMapper.java
  20. 0
    63
      slive/src/main/java/com/xhkjedu/slive/model/notice/TNotice.java
  21. 0
    27
      slive/src/main/java/com/xhkjedu/slive/model/notice/TNoticeClass.java
  22. 0
    27
      slive/src/main/java/com/xhkjedu/slive/model/notice/TNoticeSchool.java
  23. 0
    58
      slive/src/main/java/com/xhkjedu/slive/service/notice/NoticeService.java
  24. 0
    12
      slive/src/main/resources/mapper/notice/NoticeClassMapper.xml
  25. 0
    12
      slive/src/main/resources/mapper/notice/NoticeSchoolMapper.xml
  26. 0
    8
      sstudy/src/main/java/com/xhkjedu/sstudy/mapper/system/NoticeClassMapper.java
  27. 8
    0
      sstudy/src/main/java/com/xhkjedu/sstudy/mapper/system/NoticeUserMapper.java
  28. 0
    31
      sstudy/src/main/java/com/xhkjedu/sstudy/model/system/TNoticeClass.java
  29. 39
    0
      sstudy/src/main/java/com/xhkjedu/sstudy/model/system/TNoticeUser.java
  30. 16
    10
      sstudy/src/main/java/com/xhkjedu/sstudy/service/system/NoticeService.java
  31. 3
    3
      suser/src/main/resources/mapper/gradeclass/ClassTeacherMapper.xml

+ 3
- 0
sapi/src/main/java/com/xhkjedu/sapi/mapper/notice/NoticeFileMapper.java Целия файл

@@ -14,4 +14,7 @@ import java.util.List;
14 14
 public interface NoticeFileMapper extends TkMapper<TNoticeFile> {
15 15
     //通知附件列表
16 16
     List<TNoticeFile> listByNoticeId(@Param("noticeid") Integer noticeid);
17
+
18
+    //删除通知附件
19
+    void deleteByNoticeId(@Param("noticeid") Integer noticeid);
17 20
 }

+ 3
- 0
sapi/src/main/java/com/xhkjedu/sapi/mapper/notice/NoticeUserMapper.java Целия файл

@@ -30,4 +30,7 @@ public interface NoticeUserMapper extends TkMapper<TNoticeUser> {
30 30
 
31 31
     //通知对象
32 32
     List<Map> listByNoticeId(@Param("noticeid") Integer noticeid);
33
+
34
+    //删除通知对象
35
+    void deleteByNoticeId(@Param("noticeid") Integer noticeid);
33 36
 }

+ 0
- 3
sapi/src/main/java/com/xhkjedu/sapi/model/notice/TNoticeUser.java Целия файл

@@ -36,7 +36,4 @@ public class TNoticeUser extends BaseBean {
36 36
 
37 37
     //创建时间
38 38
     private Integer createtime;
39
-
40
-    //学校id
41
-    private Integer schoolid;
42 39
 }

+ 66
- 6
sapi/src/main/java/com/xhkjedu/sapi/service/notice/NoticeService.java Целия файл

@@ -1,5 +1,6 @@
1 1
 package com.xhkjedu.sapi.service.notice;
2 2
 
3
+import com.xhkjedu.sapi.listener.MessageSender;
3 4
 import com.xhkjedu.sapi.mapper.notice.NoticeClassMapper;
4 5
 import com.xhkjedu.sapi.mapper.notice.NoticeMapper;
5 6
 import com.xhkjedu.sapi.mapper.notice.NoticeUserMapper;
@@ -11,9 +12,11 @@ import com.xhkjedu.sapi.model.notice.TNotice;
11 12
 import com.xhkjedu.utils.N_Utils;
12 13
 import com.xhkjedu.sapi.vo.notice.NoticeVo;
13 14
 import org.springframework.stereotype.Service;
15
+import org.springframework.transaction.annotation.Transactional;
14 16
 
15 17
 import javax.annotation.Resource;
16 18
 import java.util.*;
19
+import java.util.stream.Collectors;
17 20
 
18 21
 /**
19 22
  * @author ywx
@@ -31,8 +34,11 @@ public class NoticeService {
31 34
     private NoticeUserMapper noticeUserMapper;
32 35
     @Resource
33 36
     private NoticeFileMapper noticeFileMapper;
37
+    @Resource
38
+    private MessageSender messageSender;
34 39
 
35 40
     //添加
41
+    @Transactional(rollbackFor = Exception.class)
36 42
     public Integer save(TNotice model) {
37 43
         if (N_Utils.isEmptyInteger(model.getCreatetime())) {
38 44
             model.setCreatetime(N_Utils.getSecondTimestamp());
@@ -42,7 +48,19 @@ public class NoticeService {
42 48
         //添加通知对象
43 49
         saveNoticeObj(model);
44 50
 
45
-        //通知附件
51
+        //添加通知附件
52
+        saveFile(model);
53
+        return model.getId();
54
+    }
55
+
56
+    /**
57
+     * @Description 添加通知附件
58
+     * @Date 2023/12/20 9:33
59
+     * @Author YWX
60
+     * @Param [model]
61
+     * @Return void
62
+     **/
63
+    private void saveFile(TNotice model) {
46 64
         List<TNoticeFile> files = model.getFiles();
47 65
         if (N_Utils.isListNotEmpty(files)) {
48 66
             Integer noticeid = model.getNoticeid();
@@ -51,17 +69,59 @@ public class NoticeService {
51 69
             }
52 70
             noticeFileMapper.insertList(files);
53 71
         }
54
-        return model.getId();
55 72
     }
56 73
 
57 74
     //删除
58
-    public Integer deleteById(Integer noticeid) {
59
-        return noticeMapper.deleteByPrimaryKey(noticeid);
75
+    public void deleteById(Integer noticeid) {
76
+        List<TNoticeFile> files = noticeFileMapper.listByNoticeId(noticeid);
77
+        noticeMapper.deleteByPrimaryKey(noticeid);
78
+        resourceDel(files);
79
+    }
80
+
81
+    /**
82
+     * @Description 删除服务器文件
83
+     * @Date 2023/12/20 9:48
84
+     * @Author YWX
85
+     * @Param [files]
86
+     * @Return void
87
+     **/
88
+    private void resourceDel(List<TNoticeFile> files) {
89
+        if (N_Utils.isListNotEmpty(files)) {
90
+            List<String> resourceUrls = new ArrayList<>();
91
+            for (TNoticeFile file : files) {
92
+                resourceUrls.add(file.getResourceurl());
93
+                String resourcecover = file.getResourcecover();
94
+                if (N_Utils.isNotEmpty(resourcecover)) resourceUrls.add(resourcecover);
95
+                String pdfurl = file.getPdfurl();
96
+                if (N_Utils.isNotEmpty(pdfurl)) resourceUrls.add(pdfurl);
97
+            }
98
+            messageSender.resourceDel(resourceUrls);//给文件服务器发送mq删除文件
99
+        }
60 100
     }
61 101
 
62 102
     //修改
63
-    public Integer update(TNotice model) {
64
-        return noticeMapper.updateByPrimaryKeySelective(model);
103
+    @Transactional(rollbackFor = Exception.class)
104
+    public void update(TNotice model) {
105
+        noticeMapper.updateByPrimaryKeySelective(model);
106
+        Integer noticeid = model.getNoticeid();
107
+        //添加通知对象
108
+        noticeUserMapper.deleteByNoticeId(noticeid);//删除通知对象
109
+        saveNoticeObj(model);//重新添加
110
+
111
+        //添加通知附件
112
+        List<TNoticeFile> oldFiles = noticeFileMapper.listByNoticeId(noticeid);
113
+        noticeFileMapper.deleteByNoticeId(noticeid);//删除通知附件
114
+        saveFile(model);//重新添加
115
+        //删除的文件从服务器删除
116
+        List<TNoticeFile> delFiles = new ArrayList<>();
117
+        List<String> resourceurls = model.getFiles().stream().map(TNoticeFile::getResourceurl).collect(Collectors.toList());
118
+        for (TNoticeFile oldFile : oldFiles) {
119
+            String resourceurl = oldFile.getResourceurl();
120
+            if(!resourceurls.contains(resourceurl)){
121
+                delFiles.add(oldFile);
122
+            }
123
+        }
124
+        resourceDel(delFiles);
65 125
     }
66 126
 
67 127
     //添加通知对象

+ 4
- 0
sapi/src/main/resources/mapper/notice/NoticeFileMapper.xml Целия файл

@@ -5,4 +5,8 @@
5 5
     <select id="listByNoticeId" resultType="com.xhkjedu.sapi.model.notice.TNoticeFile">
6 6
         select * from t_notice_file where noticeid=#{noticeid}
7 7
     </select>
8
+    <!--删除通知附件-->
9
+    <delete id="deleteByNoticeId">
10
+        delete from t_notice_file where noticeid=#{noticeid}
11
+    </delete>
8 12
 </mapper>

+ 1
- 1
sapi/src/main/resources/mapper/notice/NoticeMapper.xml Целия файл

@@ -61,7 +61,7 @@
61 61
     </select>
62 62
     <!-- 用户通知列表 -->
63 63
     <select id="listMy" resultType="com.xhkjedu.sapi.vo.notice.NoticeVo">
64
-        select n.noticeid,n.noticetitle,n.createtime,u.username createname,IFNULL(nt.readed,0) as readed
64
+        select n.noticeid,n.noticetitle,n.noticetxt,n.createtime,u.username createname,IFNULL(nt.readed,0) as readed
65 65
         from t_notice n left join t_user u on n.createid=u.userid
66 66
         left join t_notice_user nt on n.noticeid = nt.noticeid
67 67
         where nt.userid=#{notice.createid}

+ 6
- 2
sapi/src/main/resources/mapper/notice/NoticeUserMapper.xml Целия файл

@@ -3,10 +3,10 @@
3 3
 <mapper namespace="com.xhkjedu.sapi.mapper.notice.NoticeUserMapper">
4 4
     <!--批量添加-->
5 5
     <insert id="batchSave" parameterType="com.xhkjedu.sapi.model.notice.TNotice">
6
-        INSERT INTO t_notice_user (noticeid,userid,createtime,schoolid,gradeid,classid,subjectid)
6
+        INSERT INTO t_notice_user (noticeid,userid,createtime,gradeid,classid,subjectid)
7 7
         VALUES
8 8
         <foreach collection ="notice.users" item="t" index= "index" separator =",">
9
-            (#{notice.noticeid},#{t.userid},#{notice.createtime},#{notice.schoolid}
9
+            (#{notice.noticeid},#{t.userid},#{notice.createtime}
10 10
             ,#{t.gradeid},#{t.classid},#{t.subjectid})
11 11
         </foreach>
12 12
     </insert>
@@ -15,6 +15,10 @@
15 15
         update t_notice_user nt set nt.readed=1,nt.readtime=#{timestamp}
16 16
         where nt.noticeid=#{noticeid} and nt.userid=#{userid}
17 17
     </update>
18
+    <!--删除通知对象-->
19
+    <delete id="deleteByNoticeId">
20
+        delete from t_notice_user where noticeid=#{noticeid}
21
+    </delete>
18 22
     <!--通知对象-->
19 23
     <resultMap id="userResult" type="java.util.Map">
20 24
         <result property="gradeid" column="gradeid"/>

+ 0
- 7
sexam/src/main/java/com/xhkjedu/sexam/mapper/notice/NoticeClassMapper.java Целия файл

@@ -1,7 +0,0 @@
1
-package com.xhkjedu.sexam.mapper.notice;
2
-
3
-import com.xhkjedu.base.TkMapper;
4
-import com.xhkjedu.sexam.model.notice.TNoticeClass;
5
-
6
-public interface NoticeClassMapper extends TkMapper<TNoticeClass> {
7
-}

+ 0
- 7
sexam/src/main/java/com/xhkjedu/sexam/mapper/notice/NoticeSchoolMapper.java Целия файл

@@ -1,7 +0,0 @@
1
-package com.xhkjedu.sexam.mapper.notice;
2
-
3
-import com.xhkjedu.base.TkMapper;
4
-import com.xhkjedu.sexam.model.notice.TNoticeSchool;
5
-
6
-public interface NoticeSchoolMapper extends TkMapper<TNoticeSchool> {
7
-}

+ 0
- 4
sexam/src/main/java/com/xhkjedu/sexam/model/notice/TNotice.java Целия файл

@@ -38,10 +38,6 @@ public class TNotice extends BaseBean {
38 38
     //通知内容纯文本
39 39
     private String noticetxt;
40 40
 
41
-    @Transient
42
-    //班级id集合
43
-    private List<TNoticeClass> classes = new ArrayList<>();
44
-
45 41
     @Transient
46 42
     //教师id集合
47 43
     private List<TNoticeUser> users = new ArrayList<>();

+ 0
- 27
sexam/src/main/java/com/xhkjedu/sexam/model/notice/TNoticeClass.java Целия файл

@@ -1,27 +0,0 @@
1
-package com.xhkjedu.sexam.model.notice;
2
-
3
-import com.xhkjedu.model.BaseBean;
4
-import lombok.Data;
5
-
6
-import javax.persistence.Id;
7
-import javax.persistence.Table;
8
-
9
-@Table(name = "t_notice_class")
10
-@Data
11
-public class TNoticeClass extends BaseBean {
12
-    @Id
13
-    //通知班级表
14
-    private Integer ncid;
15
-
16
-    //通知id
17
-    private Integer noticeid;
18
-
19
-    //班级id
20
-    private Integer classid;
21
-
22
-    //创建时间
23
-    private Integer createid;
24
-
25
-    //创建时间
26
-    private Integer createtime;
27
-}

+ 0
- 27
sexam/src/main/java/com/xhkjedu/sexam/model/notice/TNoticeSchool.java Целия файл

@@ -1,27 +0,0 @@
1
-package com.xhkjedu.sexam.model.notice;
2
-
3
-import com.xhkjedu.model.BaseBean;
4
-import lombok.Data;
5
-
6
-import javax.persistence.Id;
7
-import javax.persistence.Table;
8
-
9
-@Table(name = "t_notice_school")
10
-@Data
11
-public class TNoticeSchool extends BaseBean {
12
-    @Id
13
-    //通知公告学校关联关系表
14
-    private Integer nsid;
15
-
16
-    //通知id
17
-    private Integer noticeid;
18
-
19
-    //学校id
20
-    private Integer schoolid;
21
-
22
-    //创建时间
23
-    private Integer createid;
24
-
25
-    //创建时间
26
-    private Integer createtime;
27
-}

+ 0
- 3
sexam/src/main/java/com/xhkjedu/sexam/model/notice/TNoticeUser.java Целия файл

@@ -36,7 +36,4 @@ public class TNoticeUser extends BaseBean {
36 36
 
37 37
     //创建时间
38 38
     private Integer createtime;
39
-
40
-    //学校id
41
-    private Integer schoolid;
42 39
 }

+ 0
- 2
sexam/src/main/java/com/xhkjedu/sexam/service/notice/NoticeService.java Целия файл

@@ -65,7 +65,6 @@ public class NoticeService {
65 65
                         t.setNoticeid(noticeid);
66 66
                         t.setReaded(0);
67 67
                         t.setCreatetime(createtime);
68
-                        t.setSchoolid(schoolid);
69 68
                     });
70 69
                     teacherList.addAll(teachers);
71 70
                 });
@@ -217,7 +216,6 @@ public class NoticeService {
217 216
                         t.setNoticeid(noticeid);
218 217
                         t.setReaded(0);
219 218
                         t.setCreatetime(createtime);
220
-                        t.setSchoolid(schoolid);
221 219
                     });
222 220
                     nteacherList.addAll(cteachers);
223 221
                 });

+ 0
- 4
sexam/src/main/resources/mapper/notice/NoticeMapper.xml Целия файл

@@ -1,4 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8" ?>
2
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
-<mapper namespace="com.xhkjedu.sexam.mapper.notice.NoticeMapper">
4
-</mapper>

+ 0
- 4
sexam/src/main/resources/mapper/notice/NoticeUserMapper.xml Целия файл

@@ -1,4 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8" ?>
2
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
-<mapper namespace="com.xhkjedu.sexam.mapper.notice.NoticeUserMapper">
4
-</mapper>

+ 0
- 17
slive/src/main/java/com/xhkjedu/slive/mapper/notice/NoticeClassMapper.java Целия файл

@@ -1,17 +0,0 @@
1
-package com.xhkjedu.slive.mapper.notice;
2
-
3
-import com.xhkjedu.base.TkMapper;
4
-import com.xhkjedu.slive.model.notice.TNotice;
5
-import com.xhkjedu.slive.model.notice.TNoticeClass;
6
-import org.apache.ibatis.annotations.Param;
7
-
8
-public interface NoticeClassMapper extends TkMapper<TNoticeClass> {
9
-    /**
10
-     * 批量添加
11
-     * @Param [notice]
12
-     * @Author ywx
13
-     * @Date 2020/6/13 10:01
14
-     * @return java.lang.Integer
15
-     **/
16
-    Integer batchSave(@Param("notice") TNotice notice);
17
-}

+ 0
- 7
slive/src/main/java/com/xhkjedu/slive/mapper/notice/NoticeMapper.java Целия файл

@@ -1,7 +0,0 @@
1
-package com.xhkjedu.slive.mapper.notice;
2
-
3
-import com.xhkjedu.base.TkMapper;
4
-import com.xhkjedu.slive.model.notice.TNotice;
5
-
6
-public interface NoticeMapper extends TkMapper<TNotice> {
7
-}

+ 0
- 11
slive/src/main/java/com/xhkjedu/slive/mapper/notice/NoticeSchoolMapper.java Целия файл

@@ -1,11 +0,0 @@
1
-package com.xhkjedu.slive.mapper.notice;
2
-
3
-import com.xhkjedu.base.TkMapper;
4
-import com.xhkjedu.slive.model.notice.TNotice;
5
-import com.xhkjedu.slive.model.notice.TNoticeSchool;
6
-import org.apache.ibatis.annotations.Param;
7
-
8
-public interface NoticeSchoolMapper extends TkMapper<TNoticeSchool> {
9
-    //批量添加
10
-    void batchSave(@Param("notice") TNotice notice);
11
-}

+ 0
- 63
slive/src/main/java/com/xhkjedu/slive/model/notice/TNotice.java Целия файл

@@ -1,63 +0,0 @@
1
-package com.xhkjedu.slive.model.notice;
2
-
3
-import com.xhkjedu.model.BaseBean;
4
-import com.xhkjedu.slive.model.gradeclass.TSchool;
5
-import com.xhkjedu.slive.vo.gradeclass.ClassVo;
6
-import lombok.Data;
7
-
8
-import javax.persistence.Id;
9
-import javax.persistence.Table;
10
-import javax.persistence.Transient;
11
-import java.util.List;
12
-
13
-@Table(name = "t_notice")
14
-@Data
15
-public class TNotice extends BaseBean {
16
-    @Id
17
-    //通知表
18
-    private Integer noticeid;
19
-
20
-    //通知标题
21
-    private String noticetitle;
22
-
23
-    //通知对象1班级2老师3学校师生4学校教师5学校学生
24
-    private Integer noticetype;
25
-
26
-    //创建人
27
-    private Integer createid;
28
-
29
-    //创建时间
30
-    private Integer createtime;
31
-
32
-    //学校id
33
-    private Integer schoolid;
34
-
35
-    //通知内容
36
-    private String noticecontent;
37
-
38
-    //通知内容纯文本
39
-    private String noticetxt;
40
-
41
-    @Transient
42
-    //班级id集合
43
-    private List<ClassVo> classes;
44
-
45
-    //@Transient
46
-    ////教师id集合
47
-    //private List<NoticeTeacherVo> teachers;
48
-
49
-    @Transient
50
-    //开始时间
51
-    private Integer starttime;
52
-
53
-    @Transient
54
-    //结束时间
55
-    private Integer stoptime;
56
-
57
-    @Transient
58
-    private Integer readed;//是否查看0未查看1已查看
59
-
60
-    @Transient
61
-    //学校id集合
62
-    private List<TSchool> schools;
63
-}

+ 0
- 27
slive/src/main/java/com/xhkjedu/slive/model/notice/TNoticeClass.java Целия файл

@@ -1,27 +0,0 @@
1
-package com.xhkjedu.slive.model.notice;
2
-
3
-import com.xhkjedu.model.BaseBean;
4
-import lombok.Data;
5
-
6
-import javax.persistence.Id;
7
-import javax.persistence.Table;
8
-
9
-@Table(name = "t_notice_class")
10
-@Data
11
-public class TNoticeClass extends BaseBean {
12
-    @Id
13
-    //通知班级表
14
-    private Integer ncid;
15
-
16
-    //通知id
17
-    private Integer noticeid;
18
-
19
-    //班级id
20
-    private Integer classid;
21
-
22
-    //创建时间
23
-    private Integer createid;
24
-
25
-    //创建时间
26
-    private Integer createtime;
27
-}

+ 0
- 27
slive/src/main/java/com/xhkjedu/slive/model/notice/TNoticeSchool.java Целия файл

@@ -1,27 +0,0 @@
1
-package com.xhkjedu.slive.model.notice;
2
-
3
-import com.xhkjedu.model.BaseBean;
4
-import lombok.Data;
5
-
6
-import javax.persistence.Id;
7
-import javax.persistence.Table;
8
-
9
-@Table(name = "t_notice_school")
10
-@Data
11
-public class TNoticeSchool extends BaseBean {
12
-    @Id
13
-    //通知公告学校关联关系表
14
-    private Integer nsid;
15
-
16
-    //通知id
17
-    private Integer noticeid;
18
-
19
-    //学校id
20
-    private Integer schoolid;
21
-
22
-    //创建时间
23
-    private Integer createid;
24
-
25
-    //创建时间
26
-    private Integer createtime;
27
-}

+ 0
- 58
slive/src/main/java/com/xhkjedu/slive/service/notice/NoticeService.java Целия файл

@@ -1,58 +0,0 @@
1
-package com.xhkjedu.slive.service.notice;
2
-
3
-import com.xhkjedu.slive.mapper.notice.NoticeClassMapper;
4
-import com.xhkjedu.slive.mapper.notice.NoticeMapper;
5
-import com.xhkjedu.slive.mapper.notice.NoticeSchoolMapper;
6
-import com.xhkjedu.slive.model.gradeclass.TSchool;
7
-import com.xhkjedu.slive.model.notice.TNotice;
8
-import com.xhkjedu.utils.N_Utils;
9
-import org.springframework.stereotype.Service;
10
-
11
-import javax.annotation.Resource;
12
-import java.util.ArrayList;
13
-import java.util.List;
14
-
15
-/**
16
- * @author ywx
17
- * @classname NoticeService
18
- * @description 
19
- * @date 2020/6/12 17:55
20
- **/
21
-@Service
22
-public class NoticeService {
23
-    @Resource
24
-    private NoticeMapper noticeMapper;
25
-    @Resource
26
-    private NoticeClassMapper noticeClassMapper;
27
-    @Resource
28
-    private NoticeSchoolMapper noticeSchoolMapper;
29
-
30
-    //添加
31
-    public Integer save(TNotice model) {
32
-        if (N_Utils.isEmptyInteger(model.getCreatetime())) {
33
-            model.setCreatetime(N_Utils.getSecondTimestamp());
34
-        }
35
-        noticeMapper.insertUseGeneratedKeys(model);
36
-        model.setNoticeid(model.getId());
37
-        //添加通知对象
38
-        saveNoticeObj(model);
39
-
40
-        return model.getId();
41
-    }
42
-
43
-    //添加通知对象
44
-    private void saveNoticeObj(TNotice model) {
45
-        if (model.getNoticetype() == 1) {//通知对象1班级
46
-            noticeClassMapper.batchSave(model);
47
-        }
48
-
49
-        if (N_Utils.isListEmpty(model.getSchools())) {//兼容以前添加单个学校模式
50
-            List<TSchool> schools = new ArrayList<>();
51
-            TSchool s = new TSchool();
52
-            s.setSchoolid(model.getSchoolid());
53
-            schools.add(s);
54
-            model.setSchools(schools);
55
-        }
56
-        noticeSchoolMapper.batchSave(model);//通知学校关联信息
57
-    }
58
-}

+ 0
- 12
slive/src/main/resources/mapper/notice/NoticeClassMapper.xml Целия файл

@@ -1,12 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8" ?>
2
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
-<mapper namespace="com.xhkjedu.slive.mapper.notice.NoticeClassMapper">
4
-    <!--批量添加-->
5
-    <insert id="batchSave" parameterType="com.xhkjedu.slive.model.notice.TNotice">
6
-        INSERT INTO t_notice_class (noticeid,classid,createid,createtime)
7
-        VALUES
8
-        <foreach collection ="notice.classes" item="c" index= "index" separator =",">
9
-            (#{notice.noticeid},#{c.classid},#{notice.createid},#{notice.createtime})
10
-        </foreach>
11
-    </insert>
12
-</mapper>

+ 0
- 12
slive/src/main/resources/mapper/notice/NoticeSchoolMapper.xml Целия файл

@@ -1,12 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8" ?>
2
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
-<mapper namespace="com.xhkjedu.slive.mapper.notice.NoticeSchoolMapper">
4
-    <!--批量添加-->
5
-    <insert id="batchSave" parameterType="com.xhkjedu.slive.model.notice.TNotice">
6
-        INSERT INTO t_notice_school (noticeid,schoolid,createid,createtime)
7
-        VALUES
8
-        <foreach collection ="notice.schools" item="school" index= "index" separator =",">
9
-            (#{notice.noticeid},#{school.schoolid},#{notice.createid},#{notice.createtime})
10
-        </foreach>
11
-    </insert>
12
-</mapper>

+ 0
- 8
sstudy/src/main/java/com/xhkjedu/sstudy/mapper/system/NoticeClassMapper.java Целия файл

@@ -1,8 +0,0 @@
1
-package com.xhkjedu.sstudy.mapper.system;
2
-
3
-import com.xhkjedu.base.TkMapper;
4
-import com.xhkjedu.sstudy.model.system.TNoticeClass;
5
-
6
-public interface NoticeClassMapper extends TkMapper<TNoticeClass> {
7
-
8
-}

+ 8
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/mapper/system/NoticeUserMapper.java Целия файл

@@ -0,0 +1,8 @@
1
+package com.xhkjedu.sstudy.mapper.system;
2
+
3
+import com.xhkjedu.base.TkMapper;
4
+import com.xhkjedu.sstudy.model.system.TNoticeUser;
5
+
6
+public interface NoticeUserMapper extends TkMapper<TNoticeUser> {
7
+
8
+}

+ 0
- 31
sstudy/src/main/java/com/xhkjedu/sstudy/model/system/TNoticeClass.java Целия файл

@@ -1,31 +0,0 @@
1
-package com.xhkjedu.sstudy.model.system;
2
-
3
-import com.xhkjedu.model.BaseBean;
4
-import lombok.Data;
5
-
6
-import javax.persistence.Id;
7
-import javax.persistence.Table;
8
-
9
-/*
10
-* @Description 班级通知,学生个人通知
11
-* @Author WN
12
-*/
13
-@Table(name = "t_notice_class")
14
-@Data
15
-public class TNoticeClass extends BaseBean {
16
-    @Id
17
-    //通知班级表
18
-    private Integer ncid;
19
-
20
-    //通知id
21
-    private Integer noticeid;
22
-
23
-    //班级id
24
-    private Integer classid;
25
-
26
-    //创建时间
27
-    private Integer createid;
28
-
29
-    //创建时间
30
-    private Integer createtime;
31
-}

+ 39
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/model/system/TNoticeUser.java Целия файл

@@ -0,0 +1,39 @@
1
+package com.xhkjedu.sstudy.model.system;
2
+
3
+import com.xhkjedu.model.BaseBean;
4
+import lombok.Data;
5
+
6
+import javax.persistence.Id;
7
+import javax.persistence.Table;
8
+
9
+@Table(name = "t_notice_user")
10
+@Data
11
+public class TNoticeUser extends BaseBean {
12
+    @Id
13
+    //通知用户表
14
+    private Integer nuid;
15
+
16
+    //通知id
17
+    private Integer noticeid;
18
+
19
+    //用户id
20
+    private Integer userid;
21
+
22
+    //是否查看0未查看1已查看
23
+    private Integer readed;
24
+
25
+    //查看时间
26
+    private Integer readtime;
27
+
28
+    //年级id
29
+    private Integer gradeid;
30
+
31
+    //班级id
32
+    private Integer classid;
33
+
34
+    //科目id
35
+    private String subjectid;
36
+
37
+    //创建时间
38
+    private Integer createtime;
39
+}

+ 16
- 10
sstudy/src/main/java/com/xhkjedu/sstudy/service/system/NoticeService.java Целия файл

@@ -1,11 +1,12 @@
1 1
 package com.xhkjedu.sstudy.service.system;
2 2
 
3
-import com.xhkjedu.sstudy.mapper.system.NoticeClassMapper;
3
+import com.xhkjedu.sstudy.mapper.gradeclass.ClassMapper;
4
+import com.xhkjedu.sstudy.mapper.system.NoticeUserMapper;
4 5
 import com.xhkjedu.sstudy.mapper.system.NoticeMapper;
5 6
 import com.xhkjedu.sstudy.mapper.system.SchoolMapper;
7
+import com.xhkjedu.sstudy.model.gradeclass.TClass;
6 8
 import com.xhkjedu.sstudy.model.paperstudent.TPaperStudentBack;
7
-import com.xhkjedu.sstudy.model.system.TNotice;
8
-import com.xhkjedu.sstudy.model.system.TNoticeClass;
9
+import com.xhkjedu.sstudy.model.system.*;
9 10
 import com.xhkjedu.utils.N_Utils;
10 11
 import org.springframework.scheduling.annotation.Async;
11 12
 import org.springframework.stereotype.Service;
@@ -24,9 +25,11 @@ public class NoticeService {
24 25
     @Resource
25 26
     private NoticeMapper noticeMapper;
26 27
     @Resource
27
-    private NoticeClassMapper noticeClassMapper;
28
+    private NoticeUserMapper noticeUserMapper;
28 29
     @Resource
29 30
     private SchoolMapper schoolMapper;
31
+    @Resource
32
+    private ClassMapper classMapper;
30 33
 
31 34
     @Async("asyncPoolTaskExecutor")
32 35
     public void save(Map map, TPaperStudentBack psb){
@@ -58,11 +61,14 @@ public class NoticeService {
58 61
         notice.setSchoolid(schoolid);
59 62
         noticeMapper.insertUseGeneratedKeys(notice);
60 63
         //保存学生通知内容
61
-        TNoticeClass noticeClass = new TNoticeClass();
62
-        noticeClass.setNoticeid(notice.getId());
63
-        noticeClass.setClassid(Integer.parseInt(map.get("studentid").toString()));
64
-        noticeClass.setCreateid(psb.getCreateid());
65
-        noticeClass.setCreatetime(psb.getCreatetime());
66
-        noticeClassMapper.insertUseGeneratedKeys(noticeClass);
64
+        TNoticeUser nu = new TNoticeUser();
65
+        nu.setNoticeid(notice.getId());
66
+        nu.setUserid(Integer.parseInt(map.get("studentid").toString()));
67
+        Integer classid = N_Utils.str2Int(map.get("classid").toString());
68
+        TClass tClass = classMapper.selectByPrimaryKey(classid);
69
+        nu.setGradeid(tClass.getGradeid());
70
+        nu.setClassid(classid);
71
+        nu.setCreatetime(psb.getCreatetime());
72
+        noticeUserMapper.insertUseGeneratedKeys(nu);
67 73
     }
68 74
 }

+ 3
- 3
suser/src/main/resources/mapper/gradeclass/ClassTeacherMapper.xml Целия файл

@@ -228,10 +228,10 @@
228 228
         left join t_user u on cs.studentid=u.userid
229 229
         where ct.teacherid=#{role.teacherid} and c.year=#{role.year} and c.classstate=1
230 230
         and c.schoolid=#{role.schoolid} and c.classnum>0
231
-        <if test="classtype!=null and classtype!=0">
232
-            and c.classtype=#{classtype}
231
+        <if test="role.classtype!=null and role.classtype!=0">
232
+            and c.classtype=#{role.classtype}
233 233
         </if>
234
-        <if test="classtype==null or classtype==0">
234
+        <if test="role.classtype==null or role.classtype==0">
235 235
             and c.classtype <![CDATA[ < ]]>5
236 236
         </if>
237 237
         order by c.gradeid,c.classtype,c.classorder,c.classname,convert(u.username using gbk)

Loading…
Отказ
Запис