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
 
17
 
18
 import javax.annotation.Resource;
18
 import javax.annotation.Resource;
19
 import java.util.List;
19
 import java.util.List;
20
+import java.util.Map;
20
 
21
 
21
 /**
22
 /**
22
 * @author ywx
23
 * @author ywx
148
         PageResult pageResult = PageUtil.getPageResult(new PageInfo(list));
149
         PageResult pageResult = PageUtil.getPageResult(new PageInfo(list));
149
         return new ResultVo(0,"获取学生通知列表成功",pageResult);
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
 
2
 
3
 import com.xhkjedu.base.TkMapper;
3
 import com.xhkjedu.base.TkMapper;
4
 import com.xhkjedu.sapi.model.notice.TNoticeFile;
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
  * @Description
10
  * @Description
9
  * Date 2023/12/18 14:08
12
  * Date 2023/12/18 14:08
10
  **/
13
  **/
11
 public interface NoticeFileMapper extends TkMapper<TNoticeFile> {
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
 import com.xhkjedu.sapi.model.notice.TNoticeUser;
5
 import com.xhkjedu.sapi.model.notice.TNoticeUser;
6
 import org.apache.ibatis.annotations.Param;
6
 import org.apache.ibatis.annotations.Param;
7
 
7
 
8
+import java.util.List;
9
+import java.util.Map;
10
+
8
 public interface NoticeUserMapper extends TkMapper<TNoticeUser> {
11
 public interface NoticeUserMapper extends TkMapper<TNoticeUser> {
9
     /**
12
     /**
10
      * 批量添加
13
      * 批量添加
24
      **/
27
      **/
25
     Integer reade(@Param("noticeid") Integer noticeid, @Param("userid") Integer userid
28
     Integer reade(@Param("noticeid") Integer noticeid, @Param("userid") Integer userid
26
             , @Param("timestamp") int timestamp);
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
     private Integer nfid;
14
     private Integer nfid;
15
 
15
 
16
     //通知id
16
     //通知id
17
-    private String noticeid;
17
+    private Integer noticeid;
18
 
18
 
19
     //资源名称
19
     //资源名称
20
     private String resourcename;
20
     private String resourcename;

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

25
     //查看时间
25
     //查看时间
26
     private Integer readtime;
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
     private Integer createtime;
38
     private Integer createtime;
30
 
39
 

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

1
 package com.xhkjedu.sapi.service.notice;
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
 import com.xhkjedu.sapi.model.notice.TNotice;
5
 import com.xhkjedu.sapi.model.notice.TNotice;
9
 import com.xhkjedu.utils.N_Utils;
6
 import com.xhkjedu.utils.N_Utils;
10
-import com.xhkjedu.sapi.vo.gradeclass.ClassVo;
11
-import com.xhkjedu.sapi.vo.notice.NoticeUserVo;
12
 import com.xhkjedu.sapi.vo.notice.NoticeVo;
7
 import com.xhkjedu.sapi.vo.notice.NoticeVo;
13
 import org.springframework.stereotype.Service;
8
 import org.springframework.stereotype.Service;
14
 
9
 
15
 import javax.annotation.Resource;
10
 import javax.annotation.Resource;
16
-import java.util.ArrayList;
17
-import java.util.List;
11
+import java.util.*;
18
 
12
 
19
 /**
13
 /**
20
  * @author ywx
14
  * @author ywx
31
     @Resource
25
     @Resource
32
     private NoticeUserMapper noticeUserMapper;
26
     private NoticeUserMapper noticeUserMapper;
33
     @Resource
27
     @Resource
34
-    private NoticeSchoolMapper noticeSchoolMapper;
28
+    private NoticeFileMapper noticeFileMapper;
35
 
29
 
36
     //添加
30
     //添加
37
     public Integer save(TNotice model) {
31
     public Integer save(TNotice model) {
43
         //添加通知对象
37
         //添加通知对象
44
         saveNoticeObj(model);
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
         return model.getId();
49
         return model.getId();
47
     }
50
     }
48
 
51
 
66
             noticeUserMapper.batchSave(model);
69
             noticeUserMapper.batchSave(model);
67
         }
70
         }
68
 
71
 
69
-        if (N_Utils.isListEmpty(model.getSchools())) {//兼容以前添加单个学校模式
72
+        /*if (N_Utils.isListEmpty(model.getSchools())) {//兼容以前添加单个学校模式
70
             List<TSchool> schools = new ArrayList<>();
73
             List<TSchool> schools = new ArrayList<>();
71
             TSchool s = new TSchool();
74
             TSchool s = new TSchool();
72
             s.setSchoolid(model.getSchoolid());
75
             s.setSchoolid(model.getSchoolid());
73
             schools.add(s);
76
             schools.add(s);
74
             model.setSchools(schools);
77
             model.setSchools(schools);
75
         }
78
         }
76
-        noticeSchoolMapper.batchSave(model);//通知学校关联信息
79
+        noticeSchoolMapper.batchSave(model);//通知学校关联信息*/
77
     }
80
     }
78
 
81
 
79
     //获取详情
82
     //获取详情
80
     public TNotice findById(Integer noticeid) {
83
     public TNotice findById(Integer noticeid) {
81
         TNotice notice = noticeMapper.findById(noticeid);
84
         TNotice notice = noticeMapper.findById(noticeid);
82
-        Integer noticetype = notice.getNoticetype();
85
+        notice.setFiles(noticeFileMapper.listByNoticeId(noticeid));
86
+        /*Integer noticetype = notice.getNoticetype();
83
         if (noticetype == 1) {
87
         if (noticetype == 1) {
84
             List<ClassVo> classes = noticeMapper.listClass(noticeid);
88
             List<ClassVo> classes = noticeMapper.listClass(noticeid);
85
             notice.setClasses(classes);
89
             notice.setClasses(classes);
89
         } else {
93
         } else {
90
             List<TSchool> schools = noticeMapper.listSchool(noticeid);
94
             List<TSchool> schools = noticeMapper.listSchool(noticeid);
91
             notice.setSchools(schools);
95
             notice.setSchools(schools);
92
-        }
96
+        }*/
93
         return notice;
97
         return notice;
94
     }
98
     }
95
 
99
 
129
      **/
133
      **/
130
     public TNotice reade(Integer noticeid, Integer createid) {
134
     public TNotice reade(Integer noticeid, Integer createid) {
131
         TNotice notice = noticeMapper.findById2(noticeid);
135
         TNotice notice = noticeMapper.findById2(noticeid);
136
+        notice.setFiles(noticeFileMapper.listByNoticeId(noticeid));
132
         noticeUserMapper.reade(noticeid, createid, N_Utils.getSecondTimestamp());
137
         noticeUserMapper.reade(noticeid, createid, N_Utils.getSecondTimestamp());
133
         return notice;
138
         return notice;
134
     }
139
     }
159
     public List<NoticeVo> listNoticeStuWeb(TNotice notice) {
164
     public List<NoticeVo> listNoticeStuWeb(TNotice notice) {
160
         return noticeMapper.listNoticeForStuWeb(notice);
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
             notice.setSchoolid(research.getSchoolid());
98
             notice.setSchoolid(research.getSchoolid());
99
             userids.forEach(uid->{
99
             userids.forEach(uid->{
100
                 NoticeUserVo nt = new NoticeUserVo();
100
                 NoticeUserVo nt = new NoticeUserVo();
101
-                nt.setTeacherid(uid);
101
+                nt.setUserid(uid);
102
                 teachers.add(nt);
102
                 teachers.add(nt);
103
             });
103
             });
104
-            notice.setTeachers(teachers);
104
+            notice.setUsers(teachers);
105
             noticeService.save(notice);
105
             noticeService.save(notice);
106
         }
106
         }
107
 
107
 

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

12
 
12
 
13
     //是否查看0未查看1已查看
13
     //是否查看0未查看1已查看
14
     private Integer readed;
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

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

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

3
 <mapper namespace="com.xhkjedu.sapi.mapper.notice.NoticeUserMapper">
3
 <mapper namespace="com.xhkjedu.sapi.mapper.notice.NoticeUserMapper">
4
     <!--批量添加-->
4
     <!--批量添加-->
5
     <insert id="batchSave" parameterType="com.xhkjedu.sapi.model.notice.TNotice">
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
         VALUES
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
         </foreach>
11
         </foreach>
11
     </insert>
12
     </insert>
12
     <!--查看-->
13
     <!--查看-->
14
         update t_notice_user nt set nt.readed=1,nt.readtime=#{timestamp}
15
         update t_notice_user nt set nt.readed=1,nt.readtime=#{timestamp}
15
         where nt.noticeid=#{noticeid} and nt.userid=#{userid}
16
         where nt.noticeid=#{noticeid} and nt.userid=#{userid}
16
     </update>
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
 </mapper>
38
 </mapper>

Loading…
Cancel
Save