فهرست منبع

fix 消息通知

Administrator 1 سال پیش
والد
کامیت
c61105d5c2

+ 13 - 19
ruoyi-admin/src/main/java/com/ruoyi/web/controller/notice/ZxNoticeController.java

@@ -1,6 +1,7 @@
 package com.ruoyi.web.controller.notice;
 
 import javax.servlet.http.HttpServletResponse;
+
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.system.domain.notice.ZxNotice;
 import com.ruoyi.system.service.IZxNoticeService;
@@ -28,18 +29,16 @@ import java.util.List;
  */
 @RestController
 @RequestMapping("/zxNotice/notice")
-public class ZxNoticeController extends BaseController
-{
+public class ZxNoticeController extends BaseController {
     @Autowired
     private IZxNoticeService zxNoticeService;
 
-/**
- * 查询政协通知公告列表
- */
-@PreAuthorize("@ss.hasPermi('zxNotice:notice:list')")
-@GetMapping("/list")
-    public TableDataInfo list(ZxNotice zxNotice)
-    {
+    /**
+     * 查询政协通知公告列表
+     */
+    @PreAuthorize("@ss.hasPermi('zxNotice:notice:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(ZxNotice zxNotice) {
         startPage();
         List<ZxNotice> list = zxNoticeService.selectZxNoticeList(zxNotice);
         return getDataTable(list);
@@ -51,8 +50,7 @@ public class ZxNoticeController extends BaseController
     @PreAuthorize("@ss.hasPermi('zxNotice:notice:export')")
     @Log(title = "政协通知公告", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, ZxNotice zxNotice)
-    {
+    public void export(HttpServletResponse response, ZxNotice zxNotice) {
         List<ZxNotice> list = zxNoticeService.selectZxNoticeList(zxNotice);
         ExcelUtil<ZxNotice> util = new ExcelUtil<ZxNotice>(ZxNotice.class);
         util.exportExcel(response, list, "政协通知公告数据");
@@ -63,8 +61,7 @@ public class ZxNoticeController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('zxNotice:notice:query')")
     @GetMapping(value = "/{zxNoticeId}")
-    public AjaxResult getInfo(@PathVariable("zxNoticeId") Long zxNoticeId)
-    {
+    public AjaxResult getInfo(@PathVariable("zxNoticeId") Long zxNoticeId) {
         return success(zxNoticeService.selectZxNoticeByZxNoticeId(zxNoticeId));
     }
 
@@ -74,8 +71,7 @@ public class ZxNoticeController extends BaseController
     @PreAuthorize("@ss.hasPermi('zxNotice:notice:add')")
     @Log(title = "政协通知公告", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody ZxNotice zxNotice)
-    {
+    public AjaxResult add(@RequestBody ZxNotice zxNotice) {
         return toAjax(zxNoticeService.insertZxNotice(zxNotice));
     }
 
@@ -85,8 +81,7 @@ public class ZxNoticeController extends BaseController
     @PreAuthorize("@ss.hasPermi('zxNotice:notice:edit')")
     @Log(title = "政协通知公告", businessType = BusinessType.UPDATE)
     @PostMapping("/put")
-    public AjaxResult edit(@RequestBody ZxNotice zxNotice)
-    {
+    public AjaxResult edit(@RequestBody ZxNotice zxNotice) {
         return toAjax(zxNoticeService.updateZxNotice(zxNotice));
     }
 
@@ -96,8 +91,7 @@ public class ZxNoticeController extends BaseController
     @PreAuthorize("@ss.hasPermi('zxNotice:notice:remove')")
     @Log(title = "政协通知公告", businessType = BusinessType.DELETE)
     @GetMapping("/delete/{zxNoticeIds}")
-    public AjaxResult remove(@PathVariable Long[] zxNoticeIds)
-    {
+    public AjaxResult remove(@PathVariable Long[] zxNoticeIds) {
         return toAjax(zxNoticeService.deleteZxNoticeByZxNoticeIds(zxNoticeIds));
     }
 }

+ 8 - 1
ruoyi-system/src/main/java/com/ruoyi/system/mapper/ZxNoticeMapper.java

@@ -76,7 +76,14 @@ public interface ZxNoticeMapper
      * @return 结果
      */
     public int batchZxUserNotice(List<ZxUserNotice> zxUserNoticeList);
-    
+    /**
+     * 新增用户与政协通知公告关联
+     *
+     * @param zxUserNotice 用户与政协通知公告关联列表
+     * @return 结果
+     */
+    public int insterZxUserNotice(ZxUserNotice zxUserNotice);
+
 
     /**
      * 通过政协通知公告主键删除用户与政协通知公告关联信息

+ 11 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ZxNoticeServiceImpl.java

@@ -1,6 +1,8 @@
 package com.ruoyi.system.service.impl;
 
+import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.system.domain.notice.ZxNotice;
 import com.ruoyi.system.domain.notice.ZxUserNotice;
 import com.ruoyi.system.service.IZxNoticeService;
@@ -33,7 +35,15 @@ public class ZxNoticeServiceImpl implements IZxNoticeService
     @Override
     public ZxNotice selectZxNoticeByZxNoticeId(Long zxNoticeId)
     {
-        return zxNoticeMapper.selectZxNoticeByZxNoticeId(zxNoticeId);
+        //记录是谁看的
+        ZxUserNotice zxUserNotice = new ZxUserNotice();
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        ZxNotice zxNotice = zxNoticeMapper.selectZxNoticeByZxNoticeId(zxNoticeId);
+        zxUserNotice.setUserId(user.getUserId());
+        zxUserNotice.setUserName(user.getUserName());
+        zxUserNotice.setZxNoticeId(zxNoticeId);
+        zxNoticeMapper.insterZxUserNotice(zxUserNotice);
+        return zxNotice;
     }
 
     /**

+ 39 - 15
ruoyi-system/src/main/resources/mapper/system/ZxNoticeMapper.xml

@@ -40,22 +40,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </sql>
 
     <select id="selectZxNoticeList" parameterType="ZxNotice" resultMap="ZxNoticeResult">
-        select a.zx_notice_id, a.notice_title, a.notice_type, a.notice_content, a.status, a.issuer, a.issuer_dept, a.issuer_dept_id, a.issuer_time, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,
-        IFNULL( b.zx_notice_type, 'N' ) as type
-        from zx_notice a
-        left join zx_user_notice b on b.zx_notice_id = a.zx_notice_id
-        where a.zx_notice_id = #{zxNoticeId}
-        <where>  
-            <if test="noticeTitle != null  and noticeTitle != ''"> and a.notice_title = #{noticeTitle}</if>
+        <where>
+            select * from ( select a.zx_notice_id, a.notice_title, a.notice_type, a.notice_content, a.status, a.issuer,
+            a.issuer_dept, a.issuer_dept_id, a.issuer_time, a.create_by, a.create_time, a.update_by, a.update_time,
+            a.remark,
+            IFNULL( b.zx_notice_type, 'N' ) as type
+            from zx_notice a
+            left join zx_user_notice b on b.zx_notice_id = a.zx_notice_id
+            where a.zx_notice_id = #{zxNoticeId}and a.notice_title = #{noticeTitle}<if test="noticeTitle != null  and noticeTitle != ''"></if>
             <if test="noticeType != null  and noticeType != ''"> and a.notice_type = #{noticeType}</if>
-            <if test="noticeContent != null  and noticeContent != ''"> and a.notice_content = #{noticeContent}</if>
+            <if test="noticeContent != null  and noticeContent != ''">and a.notice_content =#{noticeContent}</if>
             <if test="status != null  and status != ''"> and a.status = #{status}</if>
             <if test="issuer != null  and issuer != ''"> and a.issuer = #{issuer}</if>
-            <if test="issuerDept != null  and issuerDept != ''"> and a.issuer_dept = #{issuerDept}</if>
-            <if test="issuerDeptId != null "> and a.issuer_dept_id = #{issuerDeptId}</if>
-            <if test="issuerTime != null "> and a.issuer_time = #{issuerTime}</if>
+            <if test="issuerDept != null  and issuerDept != ''">and a.issuer_dept =#{issuerDept}</if>
+            <if test="issuerDeptId != null ">and a.issuer_dept_id= #{issuerDeptId}</if>
+            <if test="issuerTime != null ">and a.issuer_time =#{issuerTime}</if>
+
+        </where>
+        ) s
+        <where>
+            <if test="type != null and type != ''">and s.type =#{type}</if>
         </where>
-        order by issuer_time DESC
+        order by s.issuer_time DESC
     </select>
     
     <select id="selectZxNoticeByZxNoticeId" parameterType="Long" resultMap="ZxNoticeZxUserNoticeResult">
@@ -78,10 +84,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="issuerDeptId != null">issuer_dept_id,</if>
             <if test="issuerTime != null">issuer_time,</if>
             <if test="createBy != null">create_by,</if>
-            <if test="createTime != null">create_time,</if>
             <if test="updateBy != null">update_by,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="remark != null">remark,</if>
+            create_time
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="noticeTitle != null and noticeTitle != ''">#{noticeTitle},</if>
@@ -93,10 +99,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="issuerDeptId != null">#{issuerDeptId},</if>
             <if test="issuerTime != null">#{issuerTime},</if>
             <if test="createBy != null">#{createBy},</if>
-            <if test="createTime != null">#{createTime},</if>
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="remark != null">#{remark},</if>
+            sysdate()
          </trim>
     </insert>
 
@@ -145,7 +151,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <insert id="batchZxUserNotice">
         insert into zx_user_notice( user_id, user_name, zx_notice_id, create_time) values
 		<foreach item="item" index="index" collection="list" separator=",">
-            ( #{item.userId}, #{item.userName}, #{item.zxNoticeId}, #{item.createTime})
+            ( #{item.userId}, #{item.userName}, #{item.zxNoticeId}, sysdate())
         </foreach>
     </insert>
+
+    <insert id="insterZxUserNotice" parameterType="zxUserNotice">
+        insert into zx_user_notice
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="userId != null and userId != ''">user_id,</if>
+            <if test="userName != null and userName != ''">user_name,</if>
+            <if test="zxNoticeId != null">zx_notice_id,</if>
+            <if test="zxNoticeType != null">zx_notice_type,</if>
+            create_time
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="userId != null and userId != ''">#{userId},</if>
+            <if test="userName != null and userName != ''">#{userName},</if>
+            <if test="zxNoticeId != null">#{zxNoticeId},</if>
+            <if test="zxNoticeType != null">#{zxNoticeType},</if>
+            sysdate()
+        </trim>
+    </insert>
 </mapper>