Explorar el Código

修改通知公告,增加人员及设置已读未读;前端还没写

qinyan hace 3 meses
padre
commit
df943a9541

+ 40 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java

@@ -1,6 +1,9 @@
 package com.ruoyi.web.controller.system;
 
 import java.util.List;
+
+import com.ruoyi.system.domain.SysNoticeUser;
+import com.ruoyi.system.service.ISysNoticeUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
@@ -31,6 +34,8 @@ public class SysNoticeController extends BaseController
 {
     @Autowired
     private ISysNoticeService noticeService;
+    @Autowired
+    private ISysNoticeUserService noticeUserService;
 
     /**
      * 获取通知公告列表
@@ -88,4 +93,39 @@ public class SysNoticeController extends BaseController
     {
         return toAjax(noticeService.deleteNoticeByIds(noticeIds));
     }
+
+    /**
+     * 修改通知公告
+     */
+    @PreAuthorize("@ss.hasPermi('system:notice:choose')")
+    @Log(title = "选择人员", businessType = BusinessType.UPDATE)
+    @PostMapping("/choose")
+    public AjaxResult choose(@Validated @RequestBody SysNotice notice)
+    {
+        return toAjax(noticeService.choose(notice));
+    }
+
+    /**
+     * 移除人员
+     */
+    @PreAuthorize("@ss.hasPermi('system:notice:choose')")
+    @Log(title = "移除人员", businessType = BusinessType.UPDATE)
+    @GetMapping("/removeUser/{noticeUserId}")
+    public AjaxResult removeUser(@PathVariable Long noticeUserId)
+    {
+        return toAjax(noticeUserService.deleteNoticeUserById(noticeUserId));
+    }
+
+    /*
+        标记为已读
+     */
+    @PreAuthorize("@ss.hasPermi('system:notice:choose')")
+    @Log(title = "标记为已读", businessType = BusinessType.UPDATE)
+    @PostMapping("/setIsRead")
+    public AjaxResult setIsRead(@Validated @RequestBody SysNoticeUser notice)
+    {
+        notice.setStatus("1");//已读
+
+        return toAjax(noticeUserService.updateNoticeUser(notice));
+    }
 }

+ 10 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNotice.java

@@ -37,6 +37,16 @@ public class SysNotice extends BaseEntity
     /** 公告状态(0正常 1关闭) */
     private String status;
 
+    private String userIds;
+
+    public String getUserIds() {
+        return userIds;
+    }
+
+    public void setUserIds(String userIds) {
+        this.userIds = userIds;
+    }
+
     public Long getNoticeId()
     {
         return noticeId;

+ 67 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNoticeUser.java

@@ -0,0 +1,67 @@
+package com.ruoyi.system.domain;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.ruoyi.common.annotation.DataChange;
+import com.ruoyi.common.core.domain.BaseEntity;
+import com.ruoyi.common.xss.Xss;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Size;
+
+/**
+ * 通知公告用户表 sys_notice_user
+ *
+ * @author ruoyi
+ */
+public class SysNoticeUser extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 公告用户ID */
+    @TableId
+    private Long noticeUserId;
+
+    /** 公告id */
+    private Long noticeId;
+
+    /** 用户id) */
+    private Long userId;
+
+
+    /** 公告状态(0正常 1关闭) */
+    private String status;
+
+    public Long getNoticeUserId() {
+        return noticeUserId;
+    }
+
+    public void setNoticeUserId(Long noticeUserId) {
+        this.noticeUserId = noticeUserId;
+    }
+
+    public Long getNoticeId() {
+        return noticeId;
+    }
+
+    public void setNoticeId(Long noticeId) {
+        this.noticeId = noticeId;
+    }
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+}

+ 63 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysNoticeUserMapper.java

@@ -0,0 +1,63 @@
+package com.ruoyi.system.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.system.domain.SysNotice;
+import com.ruoyi.system.domain.SysNoticeUser;
+
+import java.util.List;
+
+/**
+ * 通知公告表 数据层
+ *
+ * @author ruoyi
+ */
+public interface SysNoticeUserMapper extends BaseMapper<SysNoticeUser>
+{
+    /**
+     * 查询公告信息
+     *
+     * @param noticeUserId 公告ID
+     * @return 公告信息
+     */
+    public SysNoticeUser selectNoticeUserById(Long noticeUserId);
+
+    /**
+     * 查询公告列表
+     *
+     * @param noticeUser 公告信息
+     * @return 公告集合
+     */
+    public List<SysNoticeUser> selectNoticeUserList(SysNoticeUser noticeUser);
+
+    /**
+     * 新增公告
+     *
+     * @param noticeUser 公告信息
+     * @return 结果
+     */
+    public int insertNoticeUser(SysNoticeUser noticeUser);
+
+    /**
+     * 修改公告
+     *
+     * @param noticeUser 公告信息
+     * @return 结果
+     */
+    public int updateNoticeUser(SysNoticeUser noticeUser);
+
+    /**
+     * 批量删除公告
+     *
+     * @param noticeUserId 公告ID
+     * @return 结果
+     */
+    public int deleteNoticeUserById(Long noticeUserId);
+
+    /**
+     * 批量删除公告信息
+     *
+     * @param noticeUserIds 需要删除的公告ID
+     * @return 结果
+     */
+    public int deleteNoticeUserByIds(Long[] noticeUserIds);
+}

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java

@@ -57,4 +57,6 @@ public interface ISysNoticeService
      * @return 结果
      */
     public int deleteNoticeByIds(Long[] noticeIds);
+
+    int choose(SysNotice notice);
 }

+ 62 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysNoticeUserService.java

@@ -0,0 +1,62 @@
+package com.ruoyi.system.service;
+
+import com.ruoyi.system.domain.SysNotice;
+import com.ruoyi.system.domain.SysNoticeUser;
+
+import java.util.List;
+
+/**
+ * 公告 服务层
+ * 
+ * @author ruoyi
+ */
+public interface ISysNoticeUserService
+{
+    /**
+     * 查询公告信息
+     * 
+     * @param noticeUserId 公告ID
+     * @return 公告信息
+     */
+    public SysNoticeUser selectNoticeUserById(Long noticeUserId);
+
+    /**
+     * 查询公告列表
+     * 
+     * @param sysNoticeUser 公告信息
+     * @return 公告集合
+     */
+    public List<SysNoticeUser> selectNoticeList(SysNoticeUser sysNoticeUser);
+
+    /**
+     * 新增公告
+     * 
+     * @param sysNoticeUser 公告信息
+     * @return 结果
+     */
+    public int insertNoticeUser(SysNoticeUser sysNoticeUser);
+
+    /**
+     * 修改公告
+     * 
+     * @param sysNoticeUser 公告信息
+     * @return 结果
+     */
+    public int updateNoticeUser(SysNoticeUser sysNoticeUser);
+
+    /**
+     * 删除公告信息
+     * 
+     * @param noticeUserId 公告ID
+     * @return 结果
+     */
+    public int deleteNoticeUserById(Long noticeUserId);
+    
+    /**
+     * 批量删除公告信息
+     * 
+     * @param noticeUserIds 需要删除的公告ID
+     * @return 结果
+     */
+    public int deleteNoticeUserByIds(Long[] noticeUserIds);
+}

+ 17 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java

@@ -4,6 +4,8 @@ import java.util.List;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.system.domain.SysNoticeUser;
+import com.ruoyi.system.mapper.SysNoticeUserMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.system.domain.SysNotice;
@@ -20,6 +22,8 @@ public class SysNoticeServiceImpl  extends ServiceImpl<SysNoticeMapper, SysNotic
 {
     @Autowired
     private SysNoticeMapper noticeMapper;
+    @Autowired
+    private SysNoticeUserMapper noticeUserMapper;
 
     /**
      * 查询公告信息
@@ -94,4 +98,17 @@ public class SysNoticeServiceImpl  extends ServiceImpl<SysNoticeMapper, SysNotic
     {
         return noticeMapper.deleteNoticeByIds(noticeIds);
     }
+
+    @Override
+    public int choose(SysNotice notice) {
+        String userIds[]= notice.getUserIds().split(",");
+        for(String userId:userIds){
+            SysNoticeUser noticeUser=new SysNoticeUser();
+            noticeUser.setNoticeId(notice.getNoticeId());
+            noticeUser.setUserId(Long.parseLong(userId));
+            noticeUser.setStatus("0");//未读
+            noticeUserMapper.insert(noticeUser);
+        }
+        return 1;
+    }
 }

+ 98 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeUserServiceImpl.java

@@ -0,0 +1,98 @@
+package com.ruoyi.system.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.system.domain.SysNotice;
+import com.ruoyi.system.domain.SysNoticeUser;
+import com.ruoyi.system.mapper.SysNoticeUserMapper;
+import com.ruoyi.system.service.ISysNoticeService;
+import com.ruoyi.system.service.ISysNoticeUserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 公告 服务层实现
+ *
+ * @author ruoyi
+ */
+@Service
+public class SysNoticeUserServiceImpl extends ServiceImpl<SysNoticeUserMapper, SysNoticeUser> implements ISysNoticeUserService
+{
+    @Autowired
+    private SysNoticeUserMapper noticeUserMapper;
+
+    /**
+     * 查询公告信息
+     *
+     * @param noticeId 公告ID
+     * @return 公告信息
+     */
+    @Override
+    public SysNoticeUser selectNoticeUserById(Long noticeId)
+    {
+        return noticeUserMapper.selectById(noticeId);
+    }
+
+    /**
+     * 查询公告列表
+     *
+     * @param notice 公告信息
+     * @return 公告集合
+     */
+    @Override
+    public List<SysNoticeUser> selectNoticeList(SysNoticeUser notice)
+    {
+        return noticeUserMapper.selectNoticeUserList(notice);
+    }
+
+    /**
+     * 新增公告
+     *
+     * @param notice 公告信息
+     * @return 结果
+     */
+    @Override
+    public int insertNoticeUser(SysNoticeUser notice)
+    {
+        return noticeUserMapper.insertNoticeUser(notice);
+    }
+
+
+    /**
+     * 修改公告
+     *
+     * @param notice 公告信息
+     * @return 结果
+     */
+    @Override
+    public int updateNoticeUser(SysNoticeUser notice)
+    {
+        return noticeUserMapper.updateById(notice);
+
+    }
+
+    /**
+     * 删除公告对象
+     *
+     * @param noticeId 公告ID
+     * @return 结果
+     */
+    @Override
+    public int deleteNoticeUserById(Long noticeId)
+    {
+        return noticeUserMapper.deleteNoticeUserById(noticeId);
+    }
+
+    /**
+     * 批量删除公告信息
+     *
+     * @param noticeIds 需要删除的公告ID
+     * @return 结果
+     */
+    @Override
+    public int deleteNoticeUserByIds(Long[] noticeIds)
+    {
+        return noticeUserMapper.deleteNoticeUserByIds(noticeIds);
+    }
+}

+ 85 - 0
ruoyi-system/src/main/resources/mapper/system/SysNoticeUserMapper.xml

@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.system.mapper.SysNoticeUserMapper">
+    
+    <resultMap type="SysNoticeUser" id="SysNoticeUserResult">
+        <result property="noticeUserId"       column="notice_user_id"       />
+        <result property="noticeId"    column="notice_id"    />
+        <result property="userId"     column="user_id"     />
+        <result property="status"         column="status"          />
+        <result property="createBy"       column="create_by"       />
+        <result property="createTime"     column="create_time"     />
+        <result property="updateBy"       column="update_by"       />
+        <result property="updateTime"     column="update_time"     />
+        <result property="remark"         column="remark"          />
+    </resultMap>
+    
+    <sql id="selectNoticeUserVo">
+        select notice_id, notice_user_id, user_id, status, create_by, create_time, update_by, update_time, remark
+		from sys_notice
+    </sql>
+    
+    <select id="selectNoticeUserById" parameterType="Long" resultMap="SysNoticeUserResult">
+        <include refid="selectNoticeUserVo"/>
+        where notice_user_id = #{noticeUserId}
+    </select>
+    
+    <select id="selectNoticeUserList" parameterType="SysNoticeUser" resultMap="SysNoticeUserResult">
+        <include refid="selectNoticeUserVo"/>
+        <where>
+			<if test="noticeId != null and noticeId != ''">
+				AND notice_id = #{noticeId}
+			</if>
+			<if test="userId != null and userId != ''">
+				AND user_id = #{userId}
+			</if>
+		</where>
+    </select>
+    
+    <insert id="insertNoticeUser" parameterType="SysNoticeUser">
+        insert into sys_notice_user (
+			<if test="noticeId != null and noticeId != '' ">notice_id, </if>
+			<if test="noticeUserId != null and noticeUserId != '' ">notice_user_id, </if>
+			<if test="userId != null and userId != '' ">user_id, </if>
+			<if test="status != null and status != '' ">status, </if>
+			<if test="remark != null and remark != ''">remark,</if>
+ 			<if test="createBy != null and createBy != ''">create_by,</if>
+ 			create_time
+ 		)values(
+			<if test="noticeId != null and noticeId != ''">#{noticeId}, </if>
+			<if test="noticeUserId != null and noticeUserId != ''">#{noticeUserId}, </if>
+			<if test="userId != null and userId != ''">#{userId}, </if>
+			<if test="status != null and status != ''">#{status}, </if>
+			<if test="remark != null and remark != ''">#{remark},</if>
+ 			<if test="createBy != null and createBy != ''">#{createBy},</if>
+ 			sysdate()
+		)
+    </insert>
+	 
+    <update id="updateNoticeUser" parameterType="SysNoticeUser">
+        update sys_notice_user
+        <set>
+            <if test="noticeId != null and noticeId != ''">notice_id = #{noticeId}, </if>
+            <if test="noticeUserId != null and noticeUserId != ''">notice_user_id = #{noticeUserId}, </if>
+            <if test="userId != null">user_id = #{userId}, </if>
+            <if test="status != null and status != ''">status = #{status}, </if>
+            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
+ 			update_time = sysdate()
+        </set>
+        where notice_id = #{noticeId}
+    </update>
+	
+    <delete id="deleteNoticeUserById" parameterType="Long">
+        delete from sys_notice_user where notice_user_id = #{noticeUserId}
+    </delete>
+    
+    <delete id="deleteNoticeUserByIds" parameterType="Long">
+        delete from sys_notice_user where notice_user_id in
+        <foreach item="noticeUserId" collection="array" open="(" separator="," close=")">
+            #{noticeUserId}
+        </foreach>
+    </delete>
+    
+</mapper>

+ 15 - 1
ruoyi-vue/src/router/index.js

@@ -157,7 +157,21 @@ export const dynamicRoutes = [
         meta: { title: '修改生成配置', activeMenu: '/tool/gen' }
       }
     ]
-  }
+  },
+  {
+    path: '/care/notice-user',
+    component: Layout,
+    hidden: true,
+    permissions: ['system:notice:choose'],
+    children: [
+      {
+        path: 'choose/:id(\\d+)',
+        component: () => import('@/views/system/notice/notice_user'),
+        name: 'noticeUser',
+        meta: { title: '用户', activeMenu: '/care/notice' }
+      }
+    ]
+  },
 ]
 
 const router = createRouter({

+ 8 - 1
ruoyi-vue/src/views/system/notice/index.vue

@@ -96,6 +96,7 @@
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
             <template #default="scope">
                <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:notice:edit']">修改</el-button>
+              <el-button link type="primary" icon="Edit" @click="handleChoose(scope.row)" v-hasPermi="['system:notice:choose']">人员选择</el-button>
                <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:notice:remove']" >删除</el-button>
             </template>
          </el-table-column>
@@ -160,6 +161,7 @@
             </div>
          </template>
       </el-dialog>
+
    </div>
 </template>
 
@@ -178,7 +180,7 @@ const single = ref(true);
 const multiple = ref(true);
 const total = ref(0);
 const title = ref("");
-
+const router = useRouter();
 const data = reactive({
   form: {},
   queryParams: {
@@ -253,6 +255,11 @@ function handleUpdate(row) {
     title.value = "修改公告";
   });
 }
+
+function handleChoose(row) {
+  router.push({path: "/care/notice_user/choose/"+row.noticeId});
+}
+
 /** 提交按钮 */
 function submitForm() {
   proxy.$refs["noticeRef"].validate(valid => {

+ 11 - 0
ruoyi-vue/src/views/system/notice/notice_user.vue

@@ -0,0 +1,11 @@
+<script setup name="noticeUser">
+
+</script>
+
+<template>
+
+</template>
+
+<style scoped lang="scss">
+
+</style>