Browse Source

通知管理

tags/正式3.13.3
雍文秀 1 year ago
parent
commit
579f58e943

+ 9
- 0
sapi/src/main/java/com/xhkjedu/sapi/controller/notice/NoticeController.java View File

@@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
17 17
 
18 18
 import javax.annotation.Resource;
19 19
 import java.util.List;
20
+import java.util.Map;
20 21
 
21 22
 /**
22 23
 * @author ywx
@@ -148,4 +149,12 @@ public class NoticeController {
148 149
         PageResult pageResult = PageUtil.getPageResult(new PageInfo(list));
149 150
         return new ResultVo(0,"获取学生通知列表成功",pageResult);
150 151
     }
152
+
153
+    @PostMapping("/list_user")
154
+    public ResultVo listUser(@RequestBody TNotice notice) {
155
+        Integer noticeid = notice.getNoticeid();
156
+        N_Utils.validation(new Object[]{noticeid, "通知id", 1});
157
+        List<Map> list = noticeService.listUser(noticeid);
158
+        return new ResultVo(0, "获取通知对象成功", list);
159
+    }
151 160
 }

+ 5
- 0
sapi/src/main/java/com/xhkjedu/sapi/mapper/notice/NoticeFileMapper.java View File

@@ -2,6 +2,9 @@ package com.xhkjedu.sapi.mapper.notice;
2 2
 
3 3
 import com.xhkjedu.base.TkMapper;
4 4
 import com.xhkjedu.sapi.model.notice.TNoticeFile;
5
+import org.apache.ibatis.annotations.Param;
6
+
7
+import java.util.List;
5 8
 
6 9
 /**
7 10
  * @Description
@@ -9,4 +12,6 @@ import com.xhkjedu.sapi.model.notice.TNoticeFile;
9 12
  * Date 2023/12/18 14:08
10 13
  **/
11 14
 public interface NoticeFileMapper extends TkMapper<TNoticeFile> {
15
+    //通知附件列表
16
+    List<TNoticeFile> listByNoticeId(@Param("noticeid") Integer noticeid);
12 17
 }

+ 6
- 0
sapi/src/main/java/com/xhkjedu/sapi/mapper/notice/NoticeUserMapper.java View File

@@ -5,6 +5,9 @@ import com.xhkjedu.sapi.model.notice.TNotice;
5 5
 import com.xhkjedu.sapi.model.notice.TNoticeUser;
6 6
 import org.apache.ibatis.annotations.Param;
7 7
 
8
+import java.util.List;
9
+import java.util.Map;
10
+
8 11
 public interface NoticeUserMapper extends TkMapper<TNoticeUser> {
9 12
     /**
10 13
      * 批量添加
@@ -24,4 +27,7 @@ public interface NoticeUserMapper extends TkMapper<TNoticeUser> {
24 27
      **/
25 28
     Integer reade(@Param("noticeid") Integer noticeid, @Param("userid") Integer userid
26 29
             , @Param("timestamp") int timestamp);
30
+
31
+    //通知对象
32
+    List<Map> listByNoticeId(@Param("noticeid") Integer noticeid);
27 33
 }

+ 1
- 1
sapi/src/main/java/com/xhkjedu/sapi/model/notice/TNoticeFile.java View File

@@ -14,7 +14,7 @@ public class TNoticeFile extends BaseBean {
14 14
     private Integer nfid;
15 15
 
16 16
     //通知id
17
-    private String noticeid;
17
+    private Integer noticeid;
18 18
 
19 19
     //资源名称
20 20
     private String resourcename;

+ 9
- 0
sapi/src/main/java/com/xhkjedu/sapi/model/notice/TNoticeUser.java View File

@@ -25,6 +25,15 @@ public class TNoticeUser extends BaseBean {
25 25
     //查看时间
26 26
     private Integer readtime;
27 27
 
28
+    //年级id
29
+    private Integer gradeid;
30
+
31
+    //班级id
32
+    private Integer classid;
33
+
34
+    //科目id
35
+    private String subjectid;
36
+
28 37
     //创建时间
29 38
     private Integer createtime;
30 39
 

+ 30
- 14
sapi/src/main/java/com/xhkjedu/sapi/service/notice/NoticeService.java View File

@@ -1,20 +1,14 @@
1 1
 package com.xhkjedu.sapi.service.notice;
2 2
 
3
-import com.xhkjedu.sapi.mapper.notice.NoticeClassMapper;
4
-import com.xhkjedu.sapi.mapper.notice.NoticeMapper;
5
-import com.xhkjedu.sapi.mapper.notice.NoticeSchoolMapper;
6
-import com.xhkjedu.sapi.mapper.notice.NoticeUserMapper;
7
-import com.xhkjedu.sapi.model.system.TSchool;
3
+import com.xhkjedu.sapi.mapper.notice.*;
4
+import com.xhkjedu.sapi.model.notice.TNoticeFile;
8 5
 import com.xhkjedu.sapi.model.notice.TNotice;
9 6
 import com.xhkjedu.utils.N_Utils;
10
-import com.xhkjedu.sapi.vo.gradeclass.ClassVo;
11
-import com.xhkjedu.sapi.vo.notice.NoticeUserVo;
12 7
 import com.xhkjedu.sapi.vo.notice.NoticeVo;
13 8
 import org.springframework.stereotype.Service;
14 9
 
15 10
 import javax.annotation.Resource;
16
-import java.util.ArrayList;
17
-import java.util.List;
11
+import java.util.*;
18 12
 
19 13
 /**
20 14
  * @author ywx
@@ -31,7 +25,7 @@ public class NoticeService {
31 25
     @Resource
32 26
     private NoticeUserMapper noticeUserMapper;
33 27
     @Resource
34
-    private NoticeSchoolMapper noticeSchoolMapper;
28
+    private NoticeFileMapper noticeFileMapper;
35 29
 
36 30
     //添加
37 31
     public Integer save(TNotice model) {
@@ -43,6 +37,15 @@ public class NoticeService {
43 37
         //添加通知对象
44 38
         saveNoticeObj(model);
45 39
 
40
+        //通知附件
41
+        List<TNoticeFile> files = model.getFiles();
42
+        if (N_Utils.isListNotEmpty(files)) {
43
+            Integer noticeid = model.getNoticeid();
44
+            for (TNoticeFile file : files) {
45
+                file.setNoticeid(noticeid);
46
+            }
47
+            noticeFileMapper.insertList(files);
48
+        }
46 49
         return model.getId();
47 50
     }
48 51
 
@@ -66,20 +69,21 @@ public class NoticeService {
66 69
             noticeUserMapper.batchSave(model);
67 70
         }
68 71
 
69
-        if (N_Utils.isListEmpty(model.getSchools())) {//兼容以前添加单个学校模式
72
+        /*if (N_Utils.isListEmpty(model.getSchools())) {//兼容以前添加单个学校模式
70 73
             List<TSchool> schools = new ArrayList<>();
71 74
             TSchool s = new TSchool();
72 75
             s.setSchoolid(model.getSchoolid());
73 76
             schools.add(s);
74 77
             model.setSchools(schools);
75 78
         }
76
-        noticeSchoolMapper.batchSave(model);//通知学校关联信息
79
+        noticeSchoolMapper.batchSave(model);//通知学校关联信息*/
77 80
     }
78 81
 
79 82
     //获取详情
80 83
     public TNotice findById(Integer noticeid) {
81 84
         TNotice notice = noticeMapper.findById(noticeid);
82
-        Integer noticetype = notice.getNoticetype();
85
+        notice.setFiles(noticeFileMapper.listByNoticeId(noticeid));
86
+        /*Integer noticetype = notice.getNoticetype();
83 87
         if (noticetype == 1) {
84 88
             List<ClassVo> classes = noticeMapper.listClass(noticeid);
85 89
             notice.setClasses(classes);
@@ -89,7 +93,7 @@ public class NoticeService {
89 93
         } else {
90 94
             List<TSchool> schools = noticeMapper.listSchool(noticeid);
91 95
             notice.setSchools(schools);
92
-        }
96
+        }*/
93 97
         return notice;
94 98
     }
95 99
 
@@ -129,6 +133,7 @@ public class NoticeService {
129 133
      **/
130 134
     public TNotice reade(Integer noticeid, Integer createid) {
131 135
         TNotice notice = noticeMapper.findById2(noticeid);
136
+        notice.setFiles(noticeFileMapper.listByNoticeId(noticeid));
132 137
         noticeUserMapper.reade(noticeid, createid, N_Utils.getSecondTimestamp());
133 138
         return notice;
134 139
     }
@@ -159,4 +164,15 @@ public class NoticeService {
159 164
     public List<NoticeVo> listNoticeStuWeb(TNotice notice) {
160 165
         return noticeMapper.listNoticeForStuWeb(notice);
161 166
     }
167
+
168
+    /**
169
+     * @Description 通知对象
170
+     * @Date 2023/12/18 16:26
171
+     * @Author YWX
172
+     * @Param [noticeid]
173
+     * @Return java.util.List<java.util.Map>
174
+     **/
175
+    public List<Map> listUser(Integer noticeid) {
176
+        return noticeUserMapper.listByNoticeId(noticeid);
177
+    }
162 178
 }

+ 2
- 2
sapi/src/main/java/com/xhkjedu/sapi/service/research/ResearchService.java View File

@@ -98,10 +98,10 @@ public class ResearchService {
98 98
             notice.setSchoolid(research.getSchoolid());
99 99
             userids.forEach(uid->{
100 100
                 NoticeUserVo nt = new NoticeUserVo();
101
-                nt.setTeacherid(uid);
101
+                nt.setUserid(uid);
102 102
                 teachers.add(nt);
103 103
             });
104
-            notice.setTeachers(teachers);
104
+            notice.setUsers(teachers);
105 105
             noticeService.save(notice);
106 106
         }
107 107
 

+ 9
- 0
sapi/src/main/java/com/xhkjedu/sapi/vo/notice/NoticeUserVo.java View File

@@ -12,4 +12,13 @@ public class NoticeUserVo {
12 12
 
13 13
     //是否查看0未查看1已查看
14 14
     private Integer readed;
15
+
16
+    //年级id
17
+    private Integer gradeid;
18
+
19
+    //班级id
20
+    private Integer classid;
21
+
22
+    //科目id
23
+    private String subjectid;
15 24
 }

+ 8
- 0
sapi/src/main/resources/mapper/notice/NoticeFileMapper.xml View File

@@ -0,0 +1,8 @@
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.sapi.mapper.notice.NoticeFileMapper">
4
+    <!--通知附件列表-->
5
+    <select id="listByNoticeId" resultType="com.xhkjedu.sapi.model.notice.TNoticeFile">
6
+        select * from t_notice_file where noticeid=#{noticeid}
7
+    </select>
8
+</mapper>

+ 1
- 1
sapi/src/main/resources/mapper/notice/NoticeMapper.xml View File

@@ -41,7 +41,7 @@
41 41
     </select>
42 42
     <!--通知用户列表-->
43 43
     <select id="listUser" resultType="com.xhkjedu.sapi.vo.notice.NoticeUserVo">
44
-        select t.userid,tu.username teachername,t.readed
44
+        select t.userid,tu.username,t.readed
45 45
         from t_notice_user t left join t_user tu on t.userid = tu.userid
46 46
         where t.noticeid=#{noticeid}
47 47
     </select>

+ 24
- 3
sapi/src/main/resources/mapper/notice/NoticeUserMapper.xml View File

@@ -3,10 +3,11 @@
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)
6
+        INSERT INTO t_notice_user (noticeid,userid,createtime,schoolid,gradeid,classid,subjectid)
7 7
         VALUES
8
-        <foreach collection ="notice.teachers" item="t" index= "index" separator =",">
9
-            (#{notice.noticeid},#{t.userid},#{notice.createtime},#{notice.schoolid})
8
+        <foreach collection ="notice.users" item="t" index= "index" separator =",">
9
+            (#{notice.noticeid},#{t.userid},#{notice.createtime},#{notice.schoolid}
10
+            ,#{t.gradeid},#{t.classid},#{t.subjectid})
10 11
         </foreach>
11 12
     </insert>
12 13
     <!--查看-->
@@ -14,4 +15,24 @@
14 15
         update t_notice_user nt set nt.readed=1,nt.readtime=#{timestamp}
15 16
         where nt.noticeid=#{noticeid} and nt.userid=#{userid}
16 17
     </update>
18
+    <!--通知对象-->
19
+    <resultMap id="userResult" type="java.util.Map">
20
+        <result property="gradeid" column="gradeid"/>
21
+        <result property="classid" column="classid"/>
22
+        <result property="subjectid" column="subjectid"/>
23
+        <result property="name" column="name"/>
24
+        <collection property="users" ofType="java.util.Map" javaType="java.util.List">
25
+            <result property="userid" column="userid"/>
26
+            <result property="readed" column="readed"/>
27
+            <result property="username" column="username"/>
28
+        </collection>
29
+    </resultMap>
30
+    <select id="listByNoticeId" resultMap="userResult">
31
+        select nu.userid,nu.readed,u.username,nu.gradeid,nu.classid,nu.subjectid
32
+        ,if(nu.classid is not null,(select c.classname from t_class c where c.classid=nu.classid)
33
+            ,(select s.subjectname from t_subject s where s.subjectid=nu.subjectid))name
34
+        from t_notice_user nu left join t_user u on nu.userid = u.userid
35
+        where nu.noticeid=#{noticeid}
36
+        order by convert(u.username using gbk)
37
+    </select>
17 38
 </mapper>

Loading…
Cancel
Save