zss
昨天 3955c6d7cdc8a3b6f1bd31a249a2c562820adfcb
消息通知完善
已修改8个文件
566 ■■■■■ 文件已修改
src/main/java/com/ruoyi/project/system/controller/SysNoticeController.java 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/project/system/domain/SysNotice.java 96 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/project/system/mapper/SysNoticeMapper.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/project/system/mapper/SysUserMapper.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/project/system/service/ISysNoticeService.java 67 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java 125 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/system/SysNoticeMapper.xml 102 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/system/SysUserMapper.xml 76 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/project/system/controller/SysNoticeController.java
@@ -1,6 +1,10 @@
package com.ruoyi.project.system.controller;
import java.util.List;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.framework.web.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
@@ -22,7 +26,7 @@
/**
 * 公告 信息操作处理
 *
 *
 * @author ruoyi
 */
@RestController
@@ -35,19 +39,25 @@
    /**
     * 获取通知公告列表
     */
    @PreAuthorize("@ss.hasPermi('system:notice:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysNotice notice)
    public R<IPage<SysNotice>> list(SysNotice notice, Page page)
    {
        startPage();
        List<SysNotice> list = noticeService.selectNoticeList(notice);
        return getDataTable(list);
        IPage<SysNotice> list = noticeService.selectNoticeList(notice, page);
        return R.ok(list);
    }
    /**
     * 获取未读数量
     */
    @GetMapping("/getCount")
    public R getCount(Long consigneeId)
    {
        return R.ok(noticeService.getCount(consigneeId));
    }
    /**
     * 根据通知公告编号获取详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:notice:query')")
    @GetMapping(value = "/{noticeId}")
    public AjaxResult getInfo(@PathVariable Long noticeId)
    {
@@ -57,35 +67,36 @@
    /**
     * 新增通知公告
     */
    @PreAuthorize("@ss.hasPermi('system:notice:add')")
    @Log(title = "通知公告", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody SysNotice notice)
    {
        notice.setCreateBy(getUsername());
        return toAjax(noticeService.insertNotice(notice));
    }
    /**
     * 修改通知公告
     */
    @PreAuthorize("@ss.hasPermi('system:notice:edit')")
    @Log(title = "通知公告", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody SysNotice notice)
    {
        notice.setUpdateBy(getUsername());
        return toAjax(noticeService.updateNotice(notice));
    }
    /**
     * 删除通知公告
     */
    @PreAuthorize("@ss.hasPermi('system:notice:remove')")
    @Log(title = "通知公告", businessType = BusinessType.DELETE)
    @DeleteMapping("/{noticeIds}")
    public AjaxResult remove(@PathVariable Long[] noticeIds)
    {
        return toAjax(noticeService.deleteNoticeByIds(noticeIds));
    }
    /**
     * 一键已读
     */
    @PostMapping("/readAll")
    public AjaxResult readAll()
    {
        return toAjax(noticeService.readAll());
    }
}
src/main/java/com/ruoyi/project/system/domain/SysNotice.java
@@ -2,17 +2,25 @@
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.xss.Xss;
import com.ruoyi.framework.web.domain.BaseEntity;
import java.time.LocalDateTime;
/**
 * 通知公告表 sys_notice
 *
 *
 * @author ruoyi
 */
public class SysNotice extends BaseEntity
@Data
public class SysNotice
{
    private static final long serialVersionUID = 1L;
@@ -31,72 +39,40 @@
    /** 公告状态(0正常 1关闭) */
    private String status;
    public Long getNoticeId()
    {
        return noticeId;
    }
    /** 发送人id */
    private Long senderId;
    public void setNoticeId(Long noticeId)
    {
        this.noticeId = noticeId;
    }
    /** 收件人id */
    private Long consigneeId;
    public void setNoticeTitle(String noticeTitle)
    {
        this.noticeTitle = noticeTitle;
    }
    /** 跳转路径 */
    private String jumpPath;
    @Xss(message = "公告标题不能包含脚本字符")
    @NotBlank(message = "公告标题不能为空")
    @Size(min = 0, max = 50, message = "公告标题不能超过50个字符")
    public String getNoticeTitle()
    {
        return noticeTitle;
    }
    /** 创建者 */
    @TableField(fill = FieldFill.INSERT)
    private String createBy;
    public void setNoticeType(String noticeType)
    {
        this.noticeType = noticeType;
    }
    /** 创建时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;
    public String getNoticeType()
    {
        return noticeType;
    }
    /** 更新者 */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String updateBy;
    public void setNoticeContent(String noticeContent)
    {
        this.noticeContent = noticeContent;
    }
    /** 更新时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;
    public String getNoticeContent()
    {
        return noticeContent;
    }
    /** 备注 */
    private String remark;
    public void setStatus(String status)
    {
        this.status = status;
    }
    /**
     * 租户id
     */
    private Long tenantId;
    public String getStatus()
    {
        return status;
    }
    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("noticeId", getNoticeId())
            .append("noticeTitle", getNoticeTitle())
            .append("noticeType", getNoticeType())
            .append("noticeContent", getNoticeContent())
            .append("status", getStatus())
            .append("createBy", getCreateBy())
            .append("createTime", getCreateTime())
            .append("updateBy", getUpdateBy())
            .append("updateTime", getUpdateTime())
            .append("remark", getRemark())
            .toString();
    }
}
src/main/java/com/ruoyi/project/system/mapper/SysNoticeMapper.java
@@ -1,18 +1,25 @@
package com.ruoyi.project.system.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.project.system.domain.SysNotice;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
 * 通知公告表 数据层
 *
 *
 * @author ruoyi
 */
public interface SysNoticeMapper
@Mapper
public interface SysNoticeMapper extends BaseMapper<SysNotice>
{
    /**
     * 查询公告信息
     *
     *
     * @param noticeId 公告ID
     * @return 公告信息
     */
@@ -20,15 +27,15 @@
    /**
     * 查询公告列表
     *
     *
     * @param notice 公告信息
     * @return 公告集合
     */
    public List<SysNotice> selectNoticeList(SysNotice notice);
    public IPage<SysNotice> selectNoticeList(@Param("c") SysNotice notice, Page page);
    /**
     * 新增公告
     *
     *
     * @param notice 公告信息
     * @return 结果
     */
@@ -36,7 +43,7 @@
    /**
     * 修改公告
     *
     *
     * @param notice 公告信息
     * @return 结果
     */
@@ -44,7 +51,7 @@
    /**
     * 批量删除公告
     *
     *
     * @param noticeId 公告ID
     * @return 结果
     */
@@ -52,9 +59,9 @@
    /**
     * 批量删除公告信息
     *
     *
     * @param noticeIds 需要删除的公告ID
     * @return 结果
     */
    public int deleteNoticeByIds(Long[] noticeIds);
}
}
src/main/java/com/ruoyi/project/system/mapper/SysUserMapper.java
@@ -4,6 +4,7 @@
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.ruoyi.project.system.domain.SysUser;
@@ -11,14 +12,15 @@
/**
 * 用户表 数据层
 *
 *
 * @author ruoyi
 */
@Mapper
public interface SysUserMapper
{
    /**
     * 根据条件分页查询用户列表
     *
     *
     * @param sysUser 用户信息
     * @return 用户信息集合信息
     */
@@ -26,7 +28,7 @@
    /**
     * 根据条件分页查询已配用户角色列表
     *
     *
     * @param user 用户信息
     * @return 用户信息集合信息
     */
@@ -34,7 +36,7 @@
    /**
     * 根据条件分页查询未分配用户角色列表
     *
     *
     * @param user 用户信息
     * @return 用户信息集合信息
     */
@@ -42,7 +44,7 @@
    /**
     * 通过用户名查询用户
     *
     *
     * @param userName 用户名
     * @return 用户对象信息
     */
@@ -58,7 +60,7 @@
    /**
     * 通过用户ID查询用户
     *
     *
     * @param userId 用户ID
     * @return 用户对象信息
     */
@@ -74,7 +76,7 @@
    /**
     * 新增用户信息
     *
     *
     * @param user 用户信息
     * @return 结果
     */
@@ -82,7 +84,7 @@
    /**
     * 修改用户信息
     *
     *
     * @param user 用户信息
     * @return 结果
     */
@@ -90,7 +92,7 @@
    /**
     * 修改用户头像
     *
     *
     * @param userName 用户名
     * @param avatar 头像地址
     * @return 结果
@@ -99,7 +101,7 @@
    /**
     * 重置用户密码
     *
     *
     * @param userName 用户名
     * @param password 密码
     * @return 结果
@@ -108,7 +110,7 @@
    /**
     * 通过用户ID删除用户
     *
     *
     * @param userId 用户ID
     * @return 结果
     */
@@ -116,7 +118,7 @@
    /**
     * 批量删除用户信息
     *
     *
     * @param userIds 需要删除的用户ID
     * @return 结果
     */
@@ -124,7 +126,7 @@
    /**
     * 校验用户名称是否唯一
     *
     *
     * @param userName 用户名称
     * @return 结果
     */
@@ -149,4 +151,8 @@
    List<SysUser> selectList(List<Long> registrantIds);
    List<SysUser> selectUsersByIds(@Param("userIds") List<Long> userIds);
    List<Long> getUserByRole(@Param("role") String role);
    List<Long> getUserByPerms(@Param("perms") List<String> perms);
}
src/main/java/com/ruoyi/project/system/service/ISysNoticeService.java
@@ -1,18 +1,22 @@
package com.ruoyi.project.system.service;
import java.util.List;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.project.system.domain.SysNotice;
/**
 * 公告 服务层
 *
 *
 * @author ruoyi
 */
public interface ISysNoticeService
public interface ISysNoticeService extends IService<SysNotice>
{
    /**
     * 查询公告信息
     *
     *
     * @param noticeId 公告ID
     * @return 公告信息
     */
@@ -20,15 +24,15 @@
    /**
     * 查询公告列表
     *
     *
     * @param notice 公告信息
     * @return 公告集合
     */
    public List<SysNotice> selectNoticeList(SysNotice notice);
    public IPage<SysNotice> selectNoticeList(SysNotice notice, Page page);
    /**
     * 新增公告
     *
     *
     * @param notice 公告信息
     * @return 结果
     */
@@ -36,7 +40,7 @@
    /**
     * 修改公告
     *
     *
     * @param notice 公告信息
     * @return 结果
     */
@@ -44,17 +48,60 @@
    /**
     * 删除公告信息
     *
     *
     * @param noticeId 公告ID
     * @return 结果
     */
    public int deleteNoticeById(Long noticeId);
    /**
     * 批量删除公告信息
     *
     *
     * @param noticeIds 需要删除的公告ID
     * @return 结果
     */
    public int deleteNoticeByIds(Long[] noticeIds);
    Long getCount(Long consigneeId);
    int readAll();
    /**
     * 通过角色 发送提醒
     * @param title 标题
     * @param message 内容
     * @param needPushRoles 发送的角色
     * @param jumpPath 跳转地址
     */
    void simpleNoticeByRoles(final String title, final String message, final List<String> needPushRoles,
                                      final String jumpPath);
    /**
     * 通过权限 发送提醒
     * @param title 标题
     * @param message 消息
     * @param needPerms 发送的权限者 已包含上级
     * @param jumpPath 跳转地址
     */
    void simpleNoticeByPerms(final String title, final String message, final List<String> needPerms,
                                      final String jumpPath);
    /**
     * 通过指定人发送提醒
     * @param title 标题
     * @param message 消息
     * @param jumpPath 跳转地址
     */
    void simpleNoticeByUser(final String title, final String message, Long consigneeId,
                             final String jumpPath);
    /**
     * 通过所有人 发送提醒
     * @param title 标题
     * @param message 消息
     * @param jumpPath 跳转地址
     */
    void simpleNoticeAll(final String title, final String message, final String jumpPath);
    void insertBatch(final List<SysNotice> notices);
}
src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java
@@ -1,7 +1,20 @@
package com.ruoyi.project.system.service.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.xiaoymin.knife4j.core.util.StrUtil;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.project.system.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import com.ruoyi.project.system.domain.SysNotice;
import com.ruoyi.project.system.mapper.SysNoticeMapper;
@@ -9,18 +22,25 @@
/**
 * 公告 服务层实现
 *
 *
 * @author ruoyi
 */
@Service
public class SysNoticeServiceImpl implements ISysNoticeService
{
public class SysNoticeServiceImpl  extends ServiceImpl<SysNoticeMapper, SysNotice> implements ISysNoticeService {
    @Autowired
    private SysNoticeMapper noticeMapper;
    @Autowired
    private SysUserMapper userMapper;
    @Autowired
    @Lazy
    private ISysNoticeService sysNoticeService;
    /**
     * 查询公告信息
     *
     *
     * @param noticeId 公告ID
     * @return 公告信息
     */
@@ -32,19 +52,18 @@
    /**
     * 查询公告列表
     *
     *
     * @param notice 公告信息
     * @return 公告集合
     */
    @Override
    public List<SysNotice> selectNoticeList(SysNotice notice)
    {
        return noticeMapper.selectNoticeList(notice);
    public IPage<SysNotice> selectNoticeList(SysNotice notice, Page page) {
        return noticeMapper.selectNoticeList(notice, page);
    }
    /**
     * 新增公告
     *
     *
     * @param notice 公告信息
     * @return 结果
     */
@@ -56,7 +75,7 @@
    /**
     * 修改公告
     *
     *
     * @param notice 公告信息
     * @return 结果
     */
@@ -68,7 +87,7 @@
    /**
     * 删除公告对象
     *
     *
     * @param noticeId 公告ID
     * @return 结果
     */
@@ -80,7 +99,7 @@
    /**
     * 批量删除公告信息
     *
     *
     * @param noticeIds 需要删除的公告ID
     * @return 结果
     */
@@ -89,4 +108,86 @@
    {
        return noticeMapper.deleteNoticeByIds(noticeIds);
    }
    @Override
    public Long getCount(Long consigneeId) {
        return noticeMapper.selectCount(Wrappers.<SysNotice>lambdaQuery()
                .eq(SysNotice::getStatus, "0")
                .eq(SysNotice::getConsigneeId, consigneeId));
    }
    @Override
    public int readAll() {
        Long userId = SecurityUtils.getUserId();
        return noticeMapper.update(null, Wrappers.<SysNotice>lambdaUpdate()
                .eq(SysNotice::getConsigneeId, userId)
                .eq(SysNotice::getStatus, "0")
                .set(SysNotice::getStatus, "1"));
    }
    @Override
    public void simpleNoticeByRoles(final String title, String message, List<String> needPushRoles,
                                             final String jumpPath) {
        Long userId = SecurityUtils.getUserId();
        if (StrUtil.isBlank(message) || CollectionUtils.isEmpty(needPushRoles)) {
            return;
        }
        List<String> rolesWithAdmin = new ArrayList<>(needPushRoles);
        rolesWithAdmin.add("管理员");
        List<SysNotice> collect = rolesWithAdmin.stream()
                .flatMap(it -> userMapper.getUserByRole(it).stream())
                .map(it -> convertSysNotice(title, message, it, jumpPath, userId))
                .collect(Collectors.toList());
        sysNoticeService.insertBatch(collect);
    }
    @Override
    public void simpleNoticeByPerms(String title, String message, List<String> needPerms,
                                             String jumpPath) {
        Long userId = SecurityUtils.getLoginUser().getUserId();
        if (StrUtil.isBlank(message) || CollectionUtils.isEmpty(needPerms)) {
            return;
        }
        List<SysNotice> collect = userMapper.getUserByPerms(needPerms).stream().map(it -> convertSysNotice(title, message, it, jumpPath,  userId)).collect(Collectors.toList());
        sysNoticeService.insertBatch(collect);
    }
    @Override
    public void simpleNoticeByUser(String title, String message, Long consigneeId,
                                    String jumpPath) {
        Long userId = SecurityUtils.getLoginUser().getUserId();
        SysNotice sysNotice = convertSysNotice(title, message, consigneeId, jumpPath, userId);
        sysNoticeService.save(sysNotice);
    }
    @Override
    public void simpleNoticeAll(String title, String message, String jumpPath) {
        Long userId = SecurityUtils.getLoginUser().getUserId();
        List<SysNotice> collect = userMapper.selectList(null).stream().map(it -> convertSysNotice(title, message, it.getUserId(), jumpPath,  userId)).collect(Collectors.toList());
        sysNoticeService.saveBatch(collect);
    }
    @Override
    public void insertBatch(List<SysNotice> noticesList) {
        if(CollectionUtils.isEmpty(noticesList)){
            return;
        }
        // 排除掉自己
        Long userId = SecurityUtils.getUserId();
        List<SysNotice> noticesListNew = noticesList.stream().filter(Objects::nonNull).filter(it -> !Objects.equals(it.getConsigneeId(), userId)).collect(Collectors.toList());
        sysNoticeService.saveBatch(noticesListNew);
    }
    private SysNotice convertSysNotice(String title,String message,Long consigneeId,String jumpPath,Long currentUserId) {
        SysNotice sysNotice = new SysNotice();
        sysNotice.setNoticeType("1");
        sysNotice.setNoticeTitle(title);//标题
        sysNotice.setNoticeContent(message);
        sysNotice.setStatus("0");
        sysNotice.setConsigneeId(consigneeId);
        sysNotice.setSenderId(currentUserId);
        sysNotice.setJumpPath(jumpPath);
        return sysNotice;
    }
}
src/main/resources/mapper/system/SysNoticeMapper.xml
@@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.project.system.mapper.SysNoticeMapper">
    <resultMap type="com.ruoyi.project.system.domain.SysNotice" id="SysNoticeResult">
        <result property="noticeId"       column="notice_id"       />
        <result property="noticeTitle"    column="notice_title"    />
@@ -16,54 +16,86 @@
        <result property="updateTime"     column="update_time"     />
        <result property="remark"         column="remark"          />
    </resultMap>
    <sql id="selectNoticeVo">
        select notice_id, notice_title, notice_type, cast(notice_content as char) as notice_content, status, create_by, create_time, update_by, update_time, remark
        from sys_notice
        select notice_id,
               notice_title,
               notice_type,
               notice_content,
               status,
               create_by,
               create_time,
               update_by,
               update_time,
               remark,
               sender_id,
               consignee_id,
               jump_path,
               tenant_id
        from sys_notice
    </sql>
    <select id="selectNoticeById" parameterType="Long" resultMap="SysNoticeResult">
        <include refid="selectNoticeVo"/>
        where notice_id = #{noticeId}
    </select>
    <select id="selectNoticeList" parameterType="com.ruoyi.project.system.domain.SysNotice" resultMap="SysNoticeResult">
        <include refid="selectNoticeVo"/>
        <where>
            <if test="noticeTitle != null and noticeTitle != ''">
                AND notice_title like concat('%', #{noticeTitle}, '%')
            </if>
            <if test="noticeType != null and noticeType != ''">
                AND notice_type = #{noticeType}
            </if>
            <if test="createBy != null and createBy != ''">
                AND create_by like concat('%', #{createBy}, '%')
            </if>
            <if test="c.noticeTitle != null and c.noticeTitle != ''">
                AND notice_title like concat('%', #{c.noticeTitle}, '%')
            </if>
            <if test="c.noticeType != null and c.noticeType != ''">
                AND notice_type = #{c.noticeType}
            </if>
            <if test="c.createBy != null and c.createBy != ''">
                AND create_by like concat('%', #{c.createBy}, '%')
            </if>
            <if test="c.senderId != null and c.senderId != ''">
                AND sender_id = #{c.senderId}
            </if>
            <if test="c.consigneeId != null and c.consigneeId != ''">
                AND consignee_id = #{c.consigneeId}
            </if>
            <if test="c.status != null and c.status != ''">
                AND status = #{c.status}
            </if>
        </where>
        order by create_time desc
    </select>
    <insert id="insertNotice" parameterType="com.ruoyi.project.system.domain.SysNotice">
        insert into sys_notice (
            <if test="noticeTitle != null and noticeTitle != '' ">notice_title, </if>
            <if test="noticeType != null and noticeType != '' ">notice_type, </if>
            <if test="noticeContent != null and noticeContent != '' ">notice_content, </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>
        <if test="noticeTitle != null and noticeTitle != '' ">notice_title, </if>
        <if test="noticeType != null and noticeType != '' ">notice_type, </if>
        <if test="noticeContent != null and noticeContent != '' ">notice_content, </if>
        <if test="status != null and status != '' ">status, </if>
        <if test="remark != null and remark != ''">remark,</if>
        <if test="senderId != null and senderId != ''">sender_id,</if>
        <if test="consigneeId != null and consigneeId != ''">consignee_id,</if>
        <if test="jumpPath != null and jumpPath != ''">jump_path,</if>
        <if test="createBy != null and createBy != ''">create_by,</if>
        <if test="tenantId != null and tenantId != ''">tenant_id,</if>
             create_time
         )values(
            <if test="noticeTitle != null and noticeTitle != ''">#{noticeTitle}, </if>
            <if test="noticeType != null and noticeType != ''">#{noticeType}, </if>
            <if test="noticeContent != null and noticeContent != ''">#{noticeContent}, </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>
        <if test="noticeTitle != null and noticeTitle != ''">#{noticeTitle}, </if>
        <if test="noticeType != null and noticeType != ''">#{noticeType}, </if>
        <if test="noticeContent != null and noticeContent != ''">#{noticeContent}, </if>
        <if test="status != null and status != ''">#{status}, </if>
        <if test="remark != null and remark != ''">#{remark},</if>
        <if test="senderId != null and senderId != ''">#{senderId},</if>
        <if test="consigneeId != null and consigneeId != ''">#{consigneeId},</if>
        <if test="jumpPath != null and jumpPath != ''">#{jumpPath},</if>
        <if test="pathParms != null and pathParms != ''">#{queryParms},</if>
        <if test="createBy != null and createBy != ''">#{createBy},</if>
        <if test="tenantId != null and tenantId != ''">#{tenantId},</if>
             sysdate()
        )
    </insert>
    <update id="updateNotice" parameterType="com.ruoyi.project.system.domain.SysNotice">
        update sys_notice
        update sys_notice
        <set>
            <if test="noticeTitle != null and noticeTitle != ''">notice_title = #{noticeTitle}, </if>
            <if test="noticeType != null and noticeType != ''">notice_type = #{noticeType}, </if>
@@ -74,16 +106,16 @@
        </set>
        where notice_id = #{noticeId}
    </update>
    <delete id="deleteNoticeById" parameterType="Long">
        delete from sys_notice where notice_id = #{noticeId}
    </delete>
    <delete id="deleteNoticeByIds" parameterType="Long">
        delete from sys_notice where notice_id in
        delete from sys_notice where notice_id in
        <foreach item="noticeId" collection="array" open="(" separator="," close=")">
            #{noticeId}
        </foreach>
    </delete>
</mapper>
</mapper>
src/main/resources/mapper/system/SysUserMapper.xml
@@ -27,7 +27,7 @@
        <association property="dept"    javaType="com.ruoyi.project.system.domain.SysDept"         resultMap="deptResult" />
        <collection  property="roles"   javaType="java.util.List"  resultMap="RoleResult" />
    </resultMap>
    <resultMap id="deptResult" type="com.ruoyi.project.system.domain.SysDept">
        <id     property="deptId"    column="dept_id"     />
        <result property="parentId"  column="parent_id"   />
@@ -37,7 +37,7 @@
        <result property="leader"    column="leader"      />
        <result property="status"    column="dept_status" />
    </resultMap>
    <resultMap id="RoleResult" type="com.ruoyi.project.system.domain.SysRole">
        <id     property="roleId"       column="role_id"        />
        <result property="roleName"     column="role_name"      />
@@ -46,7 +46,7 @@
        <result property="dataScope"    column="data_scope"     />
        <result property="status"       column="role_status"    />
    </resultMap>
    <sql id="selectUserVo">
        select u.user_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
        r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status,u.tenant_id
@@ -54,7 +54,7 @@
            left join sys_user_role ur on u.user_id = ur.user_id
            left join sys_role r on r.role_id = ur.role_id
    </sql>
    <select id="selectUserList" parameterType="com.ruoyi.project.system.domain.SysUser" resultMap="SysUserResult">
        select u.user_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,T2.dept_names from sys_user u
        left join
@@ -97,7 +97,7 @@
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>
    <select id="selectAllocatedList" parameterType="com.ruoyi.project.system.domain.SysUser" resultMap="SysUserResult">
        select distinct u.user_id,  u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
        from sys_user u
@@ -113,7 +113,7 @@
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>
    <select id="selectUnallocatedList" parameterType="com.ruoyi.project.system.domain.SysUser" resultMap="SysUserResult">
        select distinct u.user_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
        from sys_user u
@@ -130,25 +130,25 @@
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>
    <select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
        <include refid="selectUserVo"/>
        where u.user_name = #{userName} and u.del_flag = '0'
    </select>
    <select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
        <include refid="selectUserVo"/>
        where u.user_id = #{userId}
    </select>
    <select id="checkUserNameUnique" parameterType="String" resultMap="SysUserResult">
        select user_id, user_name from sys_user where user_name = #{userName} and del_flag = '0' limit 1
    </select>
    <select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
        select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1
    </select>
    <select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
        select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1
    </select>
@@ -220,7 +220,7 @@
             sysdate()
         )
    </insert>
    <update id="updateUser" parameterType="com.ruoyi.project.system.domain.SysUser">
         update sys_user
         <set>
@@ -240,28 +240,64 @@
         </set>
         where user_id = #{userId}
    </update>
    <update id="updateUserStatus" parameterType="com.ruoyi.project.system.domain.SysUser">
         update sys_user set status = #{status} where user_id = #{userId}
    </update>
    <update id="updateUserAvatar" parameterType="com.ruoyi.project.system.domain.SysUser">
         update sys_user set avatar = #{avatar} where user_name = #{userName}
    </update>
    <update id="resetUserPwd" parameterType="com.ruoyi.project.system.domain.SysUser">
         update sys_user set password = #{password} where user_name = #{userName}
    </update>
    <delete id="deleteUserById" parameterType="Long">
         update sys_user set del_flag = '2' where user_id = #{userId}
     </delete>
     <delete id="deleteUserByIds" parameterType="Long">
         update sys_user set del_flag = '2' where user_id in
         <foreach collection="array" item="userId" open="(" separator="," close=")">
             #{userId}
        </foreach>
        </foreach>
     </delete>
</mapper>
    <select id="getUserByRole" resultType="java.lang.Long">
        select distinct su.user_id
        from sys_user su
                 left join sys_user_role sur on su.user_id = sur.user_id
                 left join sys_role sr on sur.role_id = sr.role_id
        where role_name like concat('%', #{role}, '%')
          and sr.del_flag = '0'
          and sr.status = '0'
          and su.status = '0'
          and su.del_flag = '0'
    </select>
    <select id="getUserByPerms" resultType="java.lang.Long">
        select distinct t5.user_id
        from sys_role_menu t1
        left join sys_menu t2 on t1.menu_id = t2.menu_id
        left join sys_role t3 on t1.role_id = t3.role_id
        inner join sys_user_role t4 on t4.role_id = t3.role_id
        inner join sys_user t5 on t5.user_id = t4.user_id
        where t3.del_flag = '0'
        and t2.perms is not null
        and t2.perms &lt;&gt; ''
        and t5.del_flag = '0'
        and t5.status = '0'
        and t3.status = '0'
        <if test="perms != null and perms.size() > 0">
            AND (
            <foreach collection="perms" item="p" separator=" OR ">
                t2.perms = #{p}
                OR t2.perms = (split_part(#{p}, ':', 1) || ':' || split_part(#{p}, ':', 2) || ':*')
                OR t2.perms = (split_part(#{p}, ':', 1) || ':*:*')
            </foreach>
            OR t2.perms = '*:*:*'
            )
        </if>
    </select>
</mapper>