From 3955c6d7cdc8a3b6f1bd31a249a2c562820adfcb Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期一, 12 一月 2026 13:08:24 +0800
Subject: [PATCH] 消息通知完善
---
src/main/java/com/ruoyi/project/system/domain/SysNotice.java | 96 +++------
src/main/java/com/ruoyi/project/system/mapper/SysUserMapper.java | 32 +-
src/main/java/com/ruoyi/project/system/mapper/SysNoticeMapper.java | 27 +-
src/main/resources/mapper/system/SysNoticeMapper.xml | 102 ++++++---
src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java | 125 +++++++++++-
src/main/resources/mapper/system/SysUserMapper.xml | 76 +++++--
src/main/java/com/ruoyi/project/system/service/ISysNoticeService.java | 67 +++++-
src/main/java/com/ruoyi/project/system/controller/SysNoticeController.java | 41 ++-
8 files changed, 391 insertions(+), 175 deletions(-)
diff --git a/src/main/java/com/ruoyi/project/system/controller/SysNoticeController.java b/src/main/java/com/ruoyi/project/system/controller/SysNoticeController.java
index 0050920..75176f0 100644
--- a/src/main/java/com/ruoyi/project/system/controller/SysNoticeController.java
+++ b/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());
+ }
}
diff --git a/src/main/java/com/ruoyi/project/system/domain/SysNotice.java b/src/main/java/com/ruoyi/project/system/domain/SysNotice.java
index 635e691..a7e696f 100644
--- a/src/main/java/com/ruoyi/project/system/domain/SysNotice.java
+++ b/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姝e父 1鍏抽棴锛� */
private String status;
- public Long getNoticeId()
- {
- return noticeId;
- }
+ /** 鍙戦�佷汉id */
+ private Long senderId;
- public void setNoticeId(Long noticeId)
- {
- this.noticeId = noticeId;
- }
+ /** 鏀朵欢浜篿d */
+ 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();
- }
}
diff --git a/src/main/java/com/ruoyi/project/system/mapper/SysNoticeMapper.java b/src/main/java/com/ruoyi/project/system/mapper/SysNoticeMapper.java
index 3a9370f..77099c4 100644
--- a/src/main/java/com/ruoyi/project/system/mapper/SysNoticeMapper.java
+++ b/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);
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/ruoyi/project/system/mapper/SysUserMapper.java b/src/main/java/com/ruoyi/project/system/mapper/SysUserMapper.java
index 5b0f56d..d2fbcc2 100644
--- a/src/main/java/com/ruoyi/project/system/mapper/SysUserMapper.java
+++ b/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);
}
diff --git a/src/main/java/com/ruoyi/project/system/service/ISysNoticeService.java b/src/main/java/com/ruoyi/project/system/service/ISysNoticeService.java
index 98bd890..8415fba 100644
--- a/src/main/java/com/ruoyi/project/system/service/ISysNoticeService.java
+++ b/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);
}
diff --git a/src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java b/src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java
index 2b0191d..f600e91 100644
--- a/src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java
+++ b/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;
+ }
}
diff --git a/src/main/resources/mapper/system/SysNoticeMapper.xml b/src/main/resources/mapper/system/SysNoticeMapper.xml
index e152622..f1aba88 100644
--- a/src/main/resources/mapper/system/SysNoticeMapper.xml
+++ b/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>
\ No newline at end of file
+
+</mapper>
diff --git a/src/main/resources/mapper/system/SysUserMapper.xml b/src/main/resources/mapper/system/SysUserMapper.xml
index 5c94ed9..441fd9a 100644
--- a/src/main/resources/mapper/system/SysUserMapper.xml
+++ b/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>
\ No newline at end of file
+
+ <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 <> ''
+ 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>
--
Gitblit v1.9.3