Browse Source

王志扬

12417 3 years ago
parent
commit
e7866e102b

+ 0 - 69
master/src/main/java/com/ruoyi/project/system/service/ISysUserNoticeService.java

@@ -1,69 +0,0 @@
-package com.ruoyi.project.system.service;
-
-import java.util.List;
-import com.ruoyi.project.system.domain.SysUserNotice;
-
-/**
- * 用户通知关联Service接口
- * 
- * @author ruoyi
- * @date 2021-10-13
- */
-public interface ISysUserNoticeService 
-{
-    /**
-     * 查询用户通知关联
-     * 
-     * @param id 用户通知关联ID
-     * @return 用户通知关联
-     */
-    public SysUserNotice selectSysUserNoticeById(Long id);
-
-    /**
-     * 查询用户通知关联列表
-     * 
-     * @param sysUserNotice 用户通知关联
-     * @return 用户通知关联集合
-     */
-    public List<SysUserNotice> selectSysUserNoticeList(SysUserNotice sysUserNotice);
-
-    /**
-     * 查询用户通知关联列表
-     *
-     * @param userId 用户编号
-     * @return 用户通知关联集合
-     */
-    public List<SysUserNotice> selectSysUserNoticeListByUserId(Long userId);
-
-    /**
-     * 新增用户通知关联
-     * 
-     * @param sysUserNotice 用户通知关联
-     * @return 结果
-     */
-    public int insertSysUserNotice(SysUserNotice sysUserNotice);
-
-    /**
-     * 修改用户通知关联
-     * 
-     * @param sysUserNotice 用户通知关联
-     * @return 结果
-     */
-    public int updateSysUserNotice(SysUserNotice sysUserNotice);
-
-    /**
-     * 批量删除用户通知关联
-     * 
-     * @param ids 需要删除的用户通知关联ID
-     * @return 结果
-     */
-    public int deleteSysUserNoticeByIds(Long[] ids);
-
-    /**
-     * 删除用户通知关联信息
-     * 
-     * @param id 用户通知关联ID
-     * @return 结果
-     */
-    public int deleteSysUserNoticeById(Long id);
-}

+ 14 - 0
master/src/main/resources/mybatis/system/SysNoticeMapper.xml

@@ -15,6 +15,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateBy"       column="update_by"       />
         <result property="updateTime"     column="update_time"     />
         <result property="remark"         column="remark"          />
+        <!--<result property="readFlag"       column="read_flag"       />-->
     </resultMap>
 
     <sql id="selectNoticeVo">
@@ -91,4 +92,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </foreach>
     </delete>
 
+
+    <!--设置公告已读公告-->
+    <update id="">
+        update sys_notice
+        <set>
+            <if test="readFlag != null and readFlag != ''">read_flag = #{readFlag},</if>
+        </set>
+        where notice_id = 1
+    </update>
+
+
+
+
 </mapper>

+ 13 - 7
ui/src/api/system/notice.js

@@ -17,25 +17,31 @@ export function getNotice(noticeId) {
   })
 }
 
-//新增已读记录
-export function insertReadHis(data) {
+// 新增已读记录
+export function insertReadHis(noticeId) {
   return request({
-    url: '/system/noticeUser/add',
+    url: '/system/userNotice/' +noticeId,
+    method: 'get',
+  })
+}
+
+// 查询用户公告关联记录
+export function listReadHis(noticeId) {
+  return request({
+    url: '/system/userNotice/listReadHis/'+noticeId ,
     method: 'post',
     data: data
   })
 }
 
 // 根据用户id查询用户公告关联记录
-export function getNoticeUser(userId) {
+export function listByUserId() {
   return request({
-    url: '/system/noticeUser/' + userId,
+    url: '/system/userNotice/listByUserId/' ,
     method: 'get'
   })
 }
 
-
-
 // 新增公告
 export function addNotice(data) {
   return request({

+ 19 - 4
ui/src/views/system/notice/index.vue

@@ -229,7 +229,15 @@
 </template>
 
 <script>
-import {listNotice, getNotice, delNotice, addNotice, updateNotice, insertReadHis} from "@/api/system/notice";
+import {
+  listNotice,
+  getNotice,
+  delNotice,
+  addNotice,
+  updateNotice,
+  insertReadHis,
+  listByUserId
+} from "@/api/system/notice";
 import Editor from '@/components/Editor';
 
 export default {
@@ -298,6 +306,10 @@ export default {
     });
   },
   methods: {
+
+    //查询公告是否已读
+
+
     /** 查询公告列表 */
     getList() {
       this.loading = true;
@@ -367,6 +379,7 @@ export default {
     },
     /** 查看 **/
     handleSelect(row) {
+      debugger;
       this.reset();
       const noticeId = row.noticeId || this.ids
       getNotice(noticeId).then(response => {
@@ -375,9 +388,11 @@ export default {
         this.check= true;
         this.title = this.$t('查看') + " " + this.$t('公告');
       });
-
-      insertReadHis(row.noticeId,userId);
-
+      //点击查询,判断是否已有该条数据若已有则不添加,没有则向关联表添加一条数据
+      insertReadHis(row.noticeId).then(response => {
+        this.msgSuccess(this.$t('已读'));
+        this.getList();
+      });
     },
     /** 提交按钮 */
     submitForm: function() {