mirror of https://gitee.com/stylefeng/roses
Merge remote-tracking branch 'origin/group5-msg'
commit
c5e7b318ce
|
@ -43,7 +43,7 @@ public class GunsLogAutoConfiguration {
|
|||
* @date 2020/12/28 22:09
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(SysLogServiceImpl.class)
|
||||
@ConditionalOnMissingBean(SysLogService.class)
|
||||
@ConditionalOnProperty(prefix = SYS_LOG_PREFIX, name = "type", havingValue = "db")
|
||||
public SysLogService sysLogService() {
|
||||
return new SysLogServiceImpl();
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
系统消息模块
|
||||
|
||||
系统消息模块可以发送消息记录,已读未读状态
|
|
@ -0,0 +1 @@
|
|||
系统消息模块的api
|
|
@ -0,0 +1,57 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>kernel-s-message</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>message-api</artifactId>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!--auth模块的api-->
|
||||
<!--记录日志时候,有可能需要记录当前登录用户id-->
|
||||
<!--如果不要记录当前登录用户id时就不用本模块,所以optional=true-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>auth-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!--参数校验模块-->
|
||||
<!--包含带参数校验注解的类-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>validator-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--数据库模块 api-->
|
||||
<!--分页查询需要用到PageResult相关类-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>db-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--web-->
|
||||
<!--LogRecordFactory快速创建http类的日志参数会用到-->
|
||||
<!--如果不要记录当前请求的http接口信息,就不用本模块,所以optional=true-->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,124 @@
|
|||
package cn.stylefeng.roses.kernel.message.api;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.message.api.enums.MessageReadFlagEnum;
|
||||
import cn.stylefeng.roses.kernel.message.api.pojo.MessageResponse;
|
||||
import cn.stylefeng.roses.kernel.message.api.pojo.MessageSendParam;
|
||||
import cn.stylefeng.roses.kernel.message.api.pojo.MessageParam;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统消息相关接口
|
||||
* <p>
|
||||
* 接口可以有多种实现,目前只实现数据库存储方式
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/2 21:21
|
||||
*/
|
||||
public interface MessageApi {
|
||||
|
||||
/**
|
||||
* 发送系统消息
|
||||
*
|
||||
* @param messageSendParam 系统消息参数
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/2 21:21
|
||||
*/
|
||||
void sendMessage(MessageSendParam messageSendParam);
|
||||
|
||||
/**
|
||||
* 更新阅读状态
|
||||
*
|
||||
* @param messageParam 系统消息参数
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/2 22:15
|
||||
*/
|
||||
void updateReadFlag(MessageParam messageParam);
|
||||
|
||||
/**
|
||||
* 全部更新阅读状态
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/2 22:15
|
||||
*/
|
||||
void allMessageReadFlag();
|
||||
|
||||
/**
|
||||
* 批量更新阅读状态
|
||||
*
|
||||
* @param messageIds 消息id字符串,多个用逗号分隔
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/4 21:21
|
||||
*/
|
||||
void batchReadFlagByMessageIds(String messageIds, MessageReadFlagEnum flagEnum);
|
||||
/**
|
||||
* 删除系统消息
|
||||
*
|
||||
* @param messageId 消息id
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/2 21:21
|
||||
*/
|
||||
void deleteByMessageId(Long messageId);
|
||||
|
||||
/**
|
||||
* 批量删除系统消息
|
||||
*
|
||||
* @param messageIds 消息id字符串,多个用逗号分隔
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/2 21:21
|
||||
*/
|
||||
void batchDeleteByMessageIds(String messageIds);
|
||||
|
||||
/**
|
||||
* 查看系统消息
|
||||
*
|
||||
* @param messageParam 查看参数
|
||||
* @return 系统消息
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/2 21:21
|
||||
*/
|
||||
MessageResponse messageDetail(MessageParam messageParam);
|
||||
|
||||
/**
|
||||
* 查询分页系统消息
|
||||
*
|
||||
* @param messageParam 查询参数
|
||||
* @return 查询分页结果
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/2 21:21
|
||||
*/
|
||||
PageResult<MessageResponse> queryPage(MessageParam messageParam);
|
||||
|
||||
/**
|
||||
* 查询系统消息
|
||||
*
|
||||
* @param messageParam 查询参数
|
||||
* @return 系统消息列表
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/2 21:21
|
||||
*/
|
||||
List<MessageResponse> queryList(MessageParam messageParam);
|
||||
|
||||
/**
|
||||
* 查询分页系统消息 当前登录用户
|
||||
*
|
||||
* @param messageParam 查询参数
|
||||
* @return 查询分页结果
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/2 21:21
|
||||
*/
|
||||
PageResult<MessageResponse> queryPageCurrentUser(MessageParam messageParam);
|
||||
|
||||
/**
|
||||
* 查询系统消息 当前登录用户
|
||||
*
|
||||
* @param messageParam 查询参数
|
||||
* @return 系统消息列表
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/2 21:21
|
||||
*/
|
||||
List<MessageResponse> queryListCurrentUser(MessageParam messageParam);
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package cn.stylefeng.roses.kernel.message.api.constants;
|
||||
|
||||
/**
|
||||
* message模块的常量
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/1 20:58
|
||||
*/
|
||||
public interface MessageConstants {
|
||||
|
||||
/**
|
||||
* 消息模块的名称
|
||||
*/
|
||||
String MESSAGE_MODULE_NAME = "kernel-s-message";
|
||||
|
||||
/**
|
||||
* 异常枚举的步进值
|
||||
*/
|
||||
String MESSAGE_EXCEPTION_STEP_CODE = "23";
|
||||
|
||||
/**
|
||||
* 发送所有用户标识
|
||||
*/
|
||||
String RECEIVE_ALL_USER_FLAG = "all";
|
||||
|
||||
/**
|
||||
* 默认查询日志分页
|
||||
*/
|
||||
Integer DEFAULT_BEGIN_PAGE_NO = 1;
|
||||
|
||||
/**
|
||||
* 默认查询日志分页大小
|
||||
*/
|
||||
Integer DEFAULT_PAGE_SIZE = 10;
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package cn.stylefeng.roses.kernel.message.api.context;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.stylefeng.roses.kernel.message.api.MessageApi;
|
||||
|
||||
/**
|
||||
* 消息操作api的获取
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/1 21:13
|
||||
*/
|
||||
public class MessageContext {
|
||||
|
||||
/**
|
||||
* 获取消息操作api
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/1 21:13
|
||||
*/
|
||||
public static MessageApi me() {
|
||||
return SpringUtil.getBean(MessageApi.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package cn.stylefeng.roses.kernel.message.api.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 消息业务类型枚举
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/4 22:26
|
||||
*/
|
||||
@Getter
|
||||
public enum MessageBusinessTypeEnum {
|
||||
|
||||
/**
|
||||
* 已读
|
||||
*/
|
||||
SYS_NOTICE("sys_notice", "系统通知", "/sysNotice/detail");
|
||||
|
||||
private final String code;
|
||||
|
||||
private final String name;
|
||||
|
||||
private final String url;
|
||||
|
||||
|
||||
MessageBusinessTypeEnum(String code, String name, String url) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public static MessageBusinessTypeEnum getByCode(String code) {
|
||||
if (code == null) {
|
||||
return null;
|
||||
}
|
||||
for (MessageBusinessTypeEnum flagEnum : MessageBusinessTypeEnum.values()) {
|
||||
if (flagEnum.getCode().equals(code)) {
|
||||
return flagEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package cn.stylefeng.roses.kernel.message.api.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 消息优先级
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/8 13:26
|
||||
*/
|
||||
@Getter
|
||||
public enum MessageProrityLevelEnum {
|
||||
|
||||
/**
|
||||
* 高
|
||||
*/
|
||||
HIGH("high", "高"),
|
||||
|
||||
/**
|
||||
* 中
|
||||
*/
|
||||
MIDDLE("middle", "中"),
|
||||
|
||||
/**
|
||||
* 低
|
||||
*/
|
||||
LOW("low", "低");
|
||||
|
||||
private final String code;
|
||||
|
||||
private final String name;
|
||||
|
||||
MessageProrityLevelEnum(String code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static String getName(String code) {
|
||||
if (code == null) {
|
||||
return null;
|
||||
}
|
||||
for (MessageProrityLevelEnum flagEnum : MessageProrityLevelEnum.values()) {
|
||||
if (flagEnum.getCode().equals(code)) {
|
||||
return flagEnum.name;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package cn.stylefeng.roses.kernel.message.api.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 消息阅读状态
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/4 22:26
|
||||
*/
|
||||
@Getter
|
||||
public enum MessageReadFlagEnum {
|
||||
|
||||
/**
|
||||
* 未读
|
||||
*/
|
||||
UNREAD(0, "未读"),
|
||||
|
||||
/**
|
||||
* 已读
|
||||
*/
|
||||
READ(1, "已读");
|
||||
|
||||
private final Integer code;
|
||||
|
||||
private final String name;
|
||||
|
||||
MessageReadFlagEnum(Integer code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static String getName(Integer code) {
|
||||
if (code == null) {
|
||||
return null;
|
||||
}
|
||||
for (MessageReadFlagEnum flagEnum : MessageReadFlagEnum.values()) {
|
||||
if (flagEnum.getCode().equals(code)) {
|
||||
return flagEnum.name;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package cn.stylefeng.roses.kernel.message.api.exception;
|
||||
|
||||
import cn.stylefeng.roses.kernel.message.api.constants.MessageConstants;
|
||||
import cn.stylefeng.roses.kernel.rule.abstracts.AbstractExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
|
||||
/**
|
||||
* 消息异常枚举
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/1 20:55
|
||||
*/
|
||||
public class MessageException extends ServiceException {
|
||||
|
||||
public MessageException(AbstractExceptionEnum exception) {
|
||||
super(MessageConstants.MESSAGE_MODULE_NAME, exception);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package cn.stylefeng.roses.kernel.message.api.exception.enums;
|
||||
|
||||
import cn.stylefeng.roses.kernel.message.api.constants.MessageConstants;
|
||||
import cn.stylefeng.roses.kernel.rule.abstracts.AbstractExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 消息异常枚举
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/1 21:14
|
||||
*/
|
||||
@Getter
|
||||
public enum MessageExceptionEnum implements AbstractExceptionEnum {
|
||||
|
||||
/**
|
||||
* 发送系统消息时,传入的参数中receiveUserIds不合法
|
||||
*/
|
||||
ERROR_RECEIVE_USER_IDS(RuleConstants.BUSINESS_ERROR_TYPE_CODE + MessageConstants.MESSAGE_EXCEPTION_STEP_CODE + "01", "接收用户id字符串不合法!");
|
||||
|
||||
/**
|
||||
* 错误编码
|
||||
*/
|
||||
private final String errorCode;
|
||||
|
||||
/**
|
||||
* 提示用户信息
|
||||
*/
|
||||
private final String userTip;
|
||||
|
||||
MessageExceptionEnum(String errorCode, String userTip) {
|
||||
this.errorCode = errorCode;
|
||||
this.userTip = userTip;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
package cn.stylefeng.roses.kernel.message.api.pojo;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统消息的查询参数
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/1 20:23
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class MessageParam extends BaseRequest {
|
||||
|
||||
/**
|
||||
* 消息id
|
||||
*/
|
||||
@NotNull(message = "messageId不能为空", groups = {edit.class, delete.class, detail.class, updateStatus.class})
|
||||
private Long messageId;
|
||||
|
||||
/**
|
||||
* 接收用户id
|
||||
*/
|
||||
private Long receiveUserId;
|
||||
|
||||
/**
|
||||
* 发送用户id
|
||||
*/
|
||||
private Long sendUserId;
|
||||
|
||||
/**
|
||||
* 消息标题
|
||||
*/
|
||||
private String messageTitle;
|
||||
|
||||
/**
|
||||
* 消息的内容
|
||||
*/
|
||||
private String messageContent;
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
private String messageType;
|
||||
|
||||
/**
|
||||
* 消息优先级
|
||||
*/
|
||||
private String priorityLevel;
|
||||
|
||||
/**
|
||||
* 消息发送时间
|
||||
*/
|
||||
private Date messageSendTime;
|
||||
|
||||
/**
|
||||
* 业务id
|
||||
*/
|
||||
private Long businessId;
|
||||
|
||||
/**
|
||||
* 业务类型
|
||||
*/
|
||||
private String businessType;
|
||||
|
||||
/**
|
||||
* 阅读状态:0-未读,1-已读
|
||||
*/
|
||||
@NotNull(message = "阅读状态不能为空", groups = {updateStatus.class})
|
||||
private Integer readFlag;
|
||||
|
||||
/**
|
||||
* 消息id集合
|
||||
*/
|
||||
@NotEmpty(message = "消息id集合不能为空,请检查messageIdList参数", groups = {updateReadFlag.class})
|
||||
private List<Long> messageIdList;
|
||||
|
||||
|
||||
/**
|
||||
* 参数校验分组:修改阅读状态
|
||||
*/
|
||||
public @interface updateReadFlag {
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package cn.stylefeng.roses.kernel.message.api.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 系统消息的查询参数
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/2 21:23
|
||||
*/
|
||||
@Data
|
||||
public class MessageResponse implements Serializable {
|
||||
|
||||
/**
|
||||
* 消息id
|
||||
*/
|
||||
private Long messageId;
|
||||
|
||||
/**
|
||||
* 接收用户id
|
||||
*/
|
||||
private Long receiveUserId;
|
||||
|
||||
/**
|
||||
* 发送用户id
|
||||
*/
|
||||
private Long sendUserId;
|
||||
|
||||
/**
|
||||
* 消息标题
|
||||
*/
|
||||
private String messageTitle;
|
||||
|
||||
/**
|
||||
* 消息的内容
|
||||
*/
|
||||
private String messageContent;
|
||||
|
||||
/**
|
||||
* 消息优先级
|
||||
*/
|
||||
private String priorityLevel;
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
private String messageType;
|
||||
|
||||
/**
|
||||
* 消息发送时间
|
||||
*/
|
||||
private Date messageSendTime;
|
||||
|
||||
/**
|
||||
* 业务id
|
||||
*/
|
||||
private Long businessId;
|
||||
|
||||
/**
|
||||
* 业务类型
|
||||
*/
|
||||
private String businessType;
|
||||
|
||||
/**
|
||||
* 阅读状态:0-未读,1-已读
|
||||
*/
|
||||
private Integer readFlag;
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package cn.stylefeng.roses.kernel.message.api.pojo;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 发送系统消息的参数
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/1 20:23
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class MessageSendParam extends BaseRequest {
|
||||
|
||||
/**
|
||||
* 接收用户id字符串,多个以,分割
|
||||
*/
|
||||
@NotBlank(message = "接收用户ID字符串不能为空", groups = {add.class, edit.class})
|
||||
private String receiveUserIds;
|
||||
|
||||
/**
|
||||
* 消息标题
|
||||
*/
|
||||
@NotBlank(message = "消息标题不能为空", groups = {add.class, edit.class})
|
||||
private String messageTitle;
|
||||
|
||||
/**
|
||||
* 消息的内容
|
||||
*/
|
||||
private String messageContent;
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
private String messageType;
|
||||
|
||||
/**
|
||||
* 消息优先级
|
||||
*/
|
||||
private String priorityLevel;
|
||||
|
||||
/**
|
||||
* 业务id
|
||||
*/
|
||||
@NotNull(message = "业务id不能为空", groups = {add.class, edit.class})
|
||||
private Long businessId;
|
||||
|
||||
/**
|
||||
* 业务类型
|
||||
*/
|
||||
@NotBlank(message = "业务类型不能为空", groups = {add.class, edit.class})
|
||||
private String businessType;
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
系统消息业务模块,包含发送消息,查看消息,消息列表,已读消息,未读消息的业务
|
|
@ -0,0 +1,59 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>kernel-d-log</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>message-business</artifactId>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!--消息api模块-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>message-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--资源api模块-->
|
||||
<!--用在资源控制器,资源扫描上-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>scanner-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--参数校验模块-->
|
||||
<!--用在控制器,参数校验-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>validator-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--数据库sdk-->
|
||||
<!--数据库dao框架-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>db-sdk-mp</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--web模块-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,120 @@
|
|||
package cn.stylefeng.roses.kernel.message.modular.manage.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.stylefeng.roses.kernel.message.api.MessageApi;
|
||||
import cn.stylefeng.roses.kernel.message.api.enums.MessageReadFlagEnum;
|
||||
import cn.stylefeng.roses.kernel.message.api.pojo.MessageParam;
|
||||
import cn.stylefeng.roses.kernel.message.api.pojo.MessageSendParam;
|
||||
import cn.stylefeng.roses.kernel.resource.api.annotation.ApiResource;
|
||||
import cn.stylefeng.roses.kernel.resource.api.annotation.GetResource;
|
||||
import cn.stylefeng.roses.kernel.resource.api.annotation.PostResource;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统消息控制器
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/1 22:30
|
||||
*/
|
||||
@RestController
|
||||
@ApiResource(name = "系统消息控制器")
|
||||
public class SysMessageController {
|
||||
|
||||
/**
|
||||
* 系统消息api
|
||||
*/
|
||||
@Autowired
|
||||
private MessageApi messageApi;
|
||||
|
||||
/**
|
||||
* 发送系统消息
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/8 13:50
|
||||
*/
|
||||
@PostResource(name = "发送系统消息", path = "/sysMessage/sendMessage")
|
||||
public ResponseData sendMessage(@RequestBody @Validated(MessageSendParam.add.class) MessageSendParam messageSendParam) {
|
||||
messageApi.sendMessage(messageSendParam);
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新系统消息状态
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/8 13:50
|
||||
*/
|
||||
@PostResource(name = "批量更新系统消息状态", path = "/sysMessage/batchUpdateReadFlag")
|
||||
public ResponseData batchUpdateReadFlag(@RequestBody @Validated(MessageParam.updateReadFlag.class) MessageParam messageParam) {
|
||||
List<Long> messageIdList = messageParam.getMessageIdList();
|
||||
messageApi.batchReadFlagByMessageIds(StrUtil.join(",", messageIdList), MessageReadFlagEnum.READ);
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统消息全部修改已读
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/8 13:50
|
||||
*/
|
||||
@GetResource(name = "系统消息全部修改已读", path = "/sysMessage/allMessageReadFlag")
|
||||
public ResponseData allMessageReadFlag() {
|
||||
messageApi.allMessageReadFlag();
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除系统消息
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/8 13:50
|
||||
*/
|
||||
@PostResource(name = "删除系统消息", path = "/sysMessage/delete")
|
||||
public ResponseData delete(@RequestBody @Validated(MessageParam.delete.class) MessageParam messageParam) {
|
||||
messageApi.deleteByMessageId(messageParam.getMessageId());
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查看系统消息
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/8 13:50
|
||||
*/
|
||||
@GetResource(name = "查看系统消息", path = "/sysMessage/detail")
|
||||
public ResponseData detail(@Validated(MessageParam.detail.class) MessageParam messageParam) {
|
||||
return new SuccessResponseData(messageApi.messageDetail(messageParam));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询系统消息列表
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/8 13:50
|
||||
*/
|
||||
@GetResource(name = "分页查询系统消息列表", path = "/sysMessage/page")
|
||||
public ResponseData page(MessageParam messageParam) {
|
||||
return new SuccessResponseData(messageApi.queryPageCurrentUser(messageParam));
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统消息列表
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/8 13:50
|
||||
*/
|
||||
@GetResource(name = "系统消息列表", path = "/sysMessage/list")
|
||||
public ResponseData list(MessageParam messageParam) {
|
||||
return new SuccessResponseData(messageApi.queryListCurrentUser(messageParam));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
系统消息记录的sdk,用于将消息记录到数据库中,提供相关消息管理接口
|
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>kernel-s-message</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>message-sdk-db</artifactId>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!--消息模块的api-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>message-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--数据库sdk-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>db-sdk-mp</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<!--发送消息需要用到用户相关的接口-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>system-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,197 @@
|
|||
package cn.stylefeng.roses.kernel.message.db;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.message.api.MessageApi;
|
||||
import cn.stylefeng.roses.kernel.message.api.constants.MessageConstants;
|
||||
import cn.stylefeng.roses.kernel.message.api.enums.MessageReadFlagEnum;
|
||||
import cn.stylefeng.roses.kernel.message.api.exception.MessageException;
|
||||
import cn.stylefeng.roses.kernel.message.api.exception.enums.MessageExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.message.api.pojo.MessageParam;
|
||||
import cn.stylefeng.roses.kernel.message.api.pojo.MessageResponse;
|
||||
import cn.stylefeng.roses.kernel.message.api.pojo.MessageSendParam;
|
||||
import cn.stylefeng.roses.kernel.message.db.entity.SysMessage;
|
||||
import cn.stylefeng.roses.kernel.message.db.service.SysMessageService;
|
||||
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
||||
import cn.stylefeng.roses.kernel.system.UserServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.request.SysUserRequest;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 系统消息,数据库实现
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/2 22:00
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class MessageDbServiceImpl implements MessageApi {
|
||||
|
||||
|
||||
@Resource
|
||||
private UserServiceApi userServiceApi;
|
||||
|
||||
@Resource
|
||||
private SysMessageService sysMessageService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void sendMessage(MessageSendParam messageSendParam) {
|
||||
String receiveUserIds = messageSendParam.getReceiveUserIds();
|
||||
// 获取当前登录人
|
||||
LoginUser loginUser = LoginContext.me().getLoginUser();
|
||||
List<SysMessage> sendMsgList = new ArrayList<>();
|
||||
List<Long> userIds;
|
||||
// 发送所有人判断
|
||||
if (MessageConstants.RECEIVE_ALL_USER_FLAG.equals(receiveUserIds)) {
|
||||
// 查询所有用户
|
||||
userIds = userServiceApi.queryAllUserIdList(new SysUserRequest());
|
||||
|
||||
} else {
|
||||
String[] userIdArr = receiveUserIds.split(",");
|
||||
userIds = Convert.toList(Long.class, userIdArr);
|
||||
}
|
||||
if (userIds == null || userIds.isEmpty()) {
|
||||
throw new MessageException(MessageExceptionEnum.ERROR_RECEIVE_USER_IDS);
|
||||
}
|
||||
|
||||
Set<Long> userIdSet = new HashSet<>(userIds);
|
||||
SysMessage sysMessage = new SysMessage();
|
||||
BeanUtil.copyProperties(messageSendParam, sysMessage);
|
||||
// 初始化默认值
|
||||
sysMessage.setReadFlag(MessageReadFlagEnum.UNREAD.getCode());
|
||||
sysMessage.setSendUserId(loginUser.getUserId());
|
||||
sysMessage.setMessageSendTime(new Date());
|
||||
userIdSet.forEach(userId -> {
|
||||
// 判断用户是否存在
|
||||
if (userServiceApi.userExist(userId)) {
|
||||
sysMessage.setReceiveUserId(userId);
|
||||
sendMsgList.add(sysMessage);
|
||||
}
|
||||
});
|
||||
sysMessageService.saveBatch(sendMsgList);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateReadFlag(MessageParam messageParam) {
|
||||
Long messageId = messageParam.getMessageId();
|
||||
SysMessage sysMessage = sysMessageService.getById(messageId);
|
||||
Optional.ofNullable(sysMessage).ifPresent(msg -> {
|
||||
msg.setReadFlag(messageParam.getReadFlag());
|
||||
sysMessageService.updateById(msg);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void allMessageReadFlag() {
|
||||
// 获取当前登录人
|
||||
LoginUser loginUser = LoginContext.me().getLoginUser();
|
||||
Long userId = loginUser.getUserId();
|
||||
LambdaUpdateWrapper<SysMessage> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.set(SysMessage::getReadFlag, MessageReadFlagEnum.READ.getCode())
|
||||
.eq(SysMessage::getReadFlag, MessageReadFlagEnum.UNREAD.getCode())
|
||||
.eq(SysMessage::getReceiveUserId, userId)
|
||||
.set(SysMessage::getDelFlag, YesOrNotEnum.N.getCode());
|
||||
sysMessageService.update(updateWrapper);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchReadFlagByMessageIds(String messageIds, MessageReadFlagEnum flagEnum) {
|
||||
LambdaUpdateWrapper<SysMessage> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.inSql(SysMessage::getMessageId, messageIds).set(SysMessage::getReadFlag, flagEnum.getCode());
|
||||
sysMessageService.update(updateWrapper);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteByMessageId(Long messageId) {
|
||||
LambdaUpdateWrapper<SysMessage> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
// 修改为逻辑删除
|
||||
updateWrapper.eq(SysMessage::getMessageId, messageId)
|
||||
.set(SysMessage::getDelFlag, YesOrNotEnum.Y.getCode());
|
||||
sysMessageService.update(updateWrapper);
|
||||
// sysMessageService.remove(updateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchDeleteByMessageIds(String messageIds) {
|
||||
LambdaUpdateWrapper<SysMessage> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.inSql(SysMessage::getMessageId, messageIds)
|
||||
.set(SysMessage::getDelFlag, YesOrNotEnum.Y.getCode());
|
||||
sysMessageService.update(updateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageResponse messageDetail(MessageParam messageParam) {
|
||||
SysMessage sysMessage = sysMessageService.getById(messageParam.getMessageId());
|
||||
// 判断消息为未读状态更新为已读
|
||||
Optional.ofNullable(sysMessage).ifPresent(msg -> {
|
||||
if(MessageReadFlagEnum.UNREAD.getCode().equals(sysMessage.getReadFlag())){
|
||||
msg.setReadFlag(MessageReadFlagEnum.READ.getCode());
|
||||
sysMessageService.updateById(msg);
|
||||
}
|
||||
});
|
||||
MessageResponse messageResponse = new MessageResponse();
|
||||
BeanUtil.copyProperties(sysMessage, messageResponse);
|
||||
return messageResponse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<MessageResponse> queryPage(MessageParam messageParam) {
|
||||
PageResult<SysMessage> pageResult = sysMessageService.page(messageParam);
|
||||
PageResult<MessageResponse> result = new PageResult<>();
|
||||
BeanUtil.copyProperties(pageResult, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MessageResponse> queryList(MessageParam messageParam) {
|
||||
List<SysMessage> messageList = sysMessageService.list(messageParam);
|
||||
List<MessageResponse> resultList = messageList.stream().map(msg -> {
|
||||
MessageResponse response = new MessageResponse();
|
||||
BeanUtil.copyProperties(msg, response);
|
||||
return response;
|
||||
}).collect(Collectors.toList());
|
||||
return resultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<MessageResponse> queryPageCurrentUser(MessageParam messageParam) {
|
||||
if (ObjectUtil.isEmpty(messageParam)) {
|
||||
messageParam = new MessageParam();
|
||||
}
|
||||
// 获取当前登录人
|
||||
LoginUser loginUser = LoginContext.me().getLoginUser();
|
||||
messageParam.setReceiveUserId(loginUser.getUserId());
|
||||
return this.queryPage(messageParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MessageResponse> queryListCurrentUser(MessageParam messageParam) {
|
||||
if (ObjectUtil.isEmpty(messageParam)) {
|
||||
messageParam = new MessageParam();
|
||||
}
|
||||
// 获取当前登录人
|
||||
LoginUser loginUser = LoginContext.me().getLoginUser();
|
||||
messageParam.setReceiveUserId(loginUser.getUserId());
|
||||
return this.queryList(messageParam);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package cn.stylefeng.roses.kernel.message.db.entity;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 系统消息
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2020/12/31 20:09
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@TableName("sys_message")
|
||||
public class SysMessage extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "message_id", type = IdType.ASSIGN_ID)
|
||||
private Long messageId;
|
||||
|
||||
/**
|
||||
* 接收用户id
|
||||
*/
|
||||
@TableField(value = "receive_user_id")
|
||||
private Long receiveUserId;
|
||||
|
||||
/**
|
||||
* 发送用户id
|
||||
*/
|
||||
@TableField(value = "send_user_id")
|
||||
private Long sendUserId;
|
||||
|
||||
/**
|
||||
* 消息标题
|
||||
*/
|
||||
@TableField(value = "message_title")
|
||||
private String messageTitle;
|
||||
|
||||
/**
|
||||
* 消息的内容
|
||||
*/
|
||||
@TableField(value = "message_content")
|
||||
private String messageContent;
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
@TableField(value = "message_type")
|
||||
private String messageType;
|
||||
|
||||
/**
|
||||
* 消息优先级
|
||||
*/
|
||||
@TableField(value = "priority_level")
|
||||
private String priorityLevel;
|
||||
|
||||
/**
|
||||
* 消息发送时间
|
||||
*/
|
||||
@TableField(value = "message_send_time")
|
||||
private Date messageSendTime;
|
||||
|
||||
/**
|
||||
* 业务id
|
||||
*/
|
||||
@TableField(value = "business_id")
|
||||
private Long businessId;
|
||||
|
||||
/**
|
||||
* 业务类型
|
||||
*/
|
||||
@TableField(value = "business_type")
|
||||
private String businessType;
|
||||
|
||||
/**
|
||||
* 阅读状态:0-未读,1-已读
|
||||
*/
|
||||
@TableField(value = "read_flag")
|
||||
private Integer readFlag;
|
||||
|
||||
/**
|
||||
* 是否删除:Y-已删除,N-未删除
|
||||
*/
|
||||
@TableField(value = "del_flag", fill = FieldFill.INSERT)
|
||||
private String delFlag;
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package cn.stylefeng.roses.kernel.message.db.mapper;
|
||||
|
||||
import cn.stylefeng.roses.kernel.message.db.entity.SysMessage;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 系统消息 Mapper 接口
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2020/12/31 20:09
|
||||
*/
|
||||
public interface SysMessageMapper extends BaseMapper<SysMessage> {
|
||||
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
<?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="cn.stylefeng.roses.kernel.message.db.mapper.SysMessageMapper">
|
||||
</mapper>
|
|
@ -0,0 +1,34 @@
|
|||
package cn.stylefeng.roses.kernel.message.db.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.message.api.pojo.MessageParam;
|
||||
import cn.stylefeng.roses.kernel.message.db.entity.SysMessage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统消息 service接口
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2020/12/31 20:09
|
||||
*/
|
||||
public interface SysMessageService extends IService<SysMessage> {
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param messageParam 参数
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/2 15:21
|
||||
*/
|
||||
PageResult<SysMessage> page(MessageParam messageParam);
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param messageParam 参数
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/8 15:21
|
||||
*/
|
||||
List<SysMessage> list(MessageParam messageParam);
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package cn.stylefeng.roses.kernel.message.db.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.message.api.pojo.MessageParam;
|
||||
import cn.stylefeng.roses.kernel.message.db.entity.SysMessage;
|
||||
import cn.stylefeng.roses.kernel.message.db.mapper.SysMessageMapper;
|
||||
import cn.stylefeng.roses.kernel.message.db.service.SysMessageService;
|
||||
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统消息 service接口实现类
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2020/12/31 20:09
|
||||
*/
|
||||
@Service
|
||||
public class SysMessageServiceImpl extends ServiceImpl<SysMessageMapper, SysMessage> implements SysMessageService {
|
||||
|
||||
|
||||
@Override
|
||||
public PageResult<SysMessage> page(MessageParam messageParam) {
|
||||
LambdaQueryWrapper<SysMessage> wrapper = createWrapper(messageParam);
|
||||
Page<SysMessage> page = this.page(PageFactory.defaultPage(), wrapper);
|
||||
return PageResultFactory.createPageResult(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysMessage> list(MessageParam messageParam) {
|
||||
LambdaQueryWrapper<SysMessage> wrapper = createWrapper(messageParam);
|
||||
return this.list(wrapper);
|
||||
}
|
||||
/**
|
||||
* 创建wrapper
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/8 14:16
|
||||
*/
|
||||
private LambdaQueryWrapper<SysMessage> createWrapper(MessageParam messageParam) {
|
||||
LambdaQueryWrapper<SysMessage> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
if (ObjectUtil.isNotNull(messageParam)) {
|
||||
|
||||
// 拼接消息标题
|
||||
if (ObjectUtil.isNotEmpty(messageParam.getMessageTitle())) {
|
||||
queryWrapper.like(SysMessage::getMessageTitle, messageParam.getMessageTitle());
|
||||
}
|
||||
|
||||
// 拼接接收人id查询条件
|
||||
if (ObjectUtil.isNotEmpty(messageParam.getReceiveUserId())) {
|
||||
queryWrapper.eq(SysMessage::getReceiveUserId, messageParam.getReceiveUserId());
|
||||
}
|
||||
|
||||
// 拼接消息类型
|
||||
if (ObjectUtil.isNotEmpty(messageParam.getMessageType())) {
|
||||
queryWrapper.eq(SysMessage::getMessageType, messageParam.getMessageType());
|
||||
}
|
||||
|
||||
// 拼接阅读状态
|
||||
if (ObjectUtil.isNotEmpty(messageParam.getReadFlag())) {
|
||||
queryWrapper.eq(SysMessage::getReadFlag, messageParam.getReadFlag());
|
||||
}
|
||||
}
|
||||
// 查询未删除的
|
||||
queryWrapper.ne(SysMessage::getDelFlag, YesOrNotEnum.Y.getCode());
|
||||
|
||||
// 按发送事件倒序
|
||||
queryWrapper.orderByDesc(SysMessage::getMessageSendTime);
|
||||
|
||||
return queryWrapper;
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
系统消息的spring boot自动加载模块
|
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>kernel-s-message</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>message-spring-boot-starter</artifactId>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!--消息管理-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>message-business</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!--消息默认记录到库中-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>message-sdk-db</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,16 @@
|
|||
package cn.stylefeng.roses.kernel.message.starter;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 系统消息的自动配置
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2020/12/31 18:50
|
||||
*/
|
||||
@Configuration
|
||||
public class GunsMessageAutoConfiguration {
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
cn.stylefeng.roses.kernel.message.starter.GunsMessageAutoConfiguration
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>roses-kernel</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>kernel-s-message</artifactId>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>message-api</module>
|
||||
<module>message-business</module>
|
||||
<module>message-sdk-db</module>
|
||||
<module>message-spring-boot-starter</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- 开发规则 -->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>kernel-a-rule</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -258,7 +258,7 @@ CREATE TABLE `sys_log` (
|
|||
`app_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '服务名称,一般为spring.application.name',
|
||||
`request_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '当前用户请求的url',
|
||||
`request_params` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT 'http或方法的请求参数体',
|
||||
`request_result` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT 'http或方法的请求结果',
|
||||
`request_result` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT 'http或方法的请求结果',
|
||||
`server_ip` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '当前服务器的ip',
|
||||
`client_ip` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '客户端的ip',
|
||||
`user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户id',
|
||||
|
@ -945,4 +945,50 @@ CREATE TABLE `sys_user_role` (
|
|||
-- ----------------------------
|
||||
INSERT INTO `sys_user_role` VALUES (1339554696976781379, 1339550467939639299, 1339550467939639303, '2020-12-17 20:57:31', NULL, NULL, NULL);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_message
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_message`;
|
||||
CREATE TABLE `sys_message` (
|
||||
`message_id` bigint(0) NOT NULL COMMENT '主键',
|
||||
`receive_user_id` bigint(0) NULL DEFAULT NULL COMMENT '接收用户id',
|
||||
`send_user_id` bigint(0) NULL DEFAULT NULL COMMENT '发送用户id',
|
||||
`message_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '消息标题',
|
||||
`message_content` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '消息内容',
|
||||
`message_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '消息类型',
|
||||
`priority_level` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '优先级',
|
||||
`message_send_time` datetime(0) NULL DEFAULT NULL COMMENT '消息发送时间',
|
||||
`business_id` bigint(0) NULL DEFAULT NULL COMMENT '业务id',
|
||||
`business_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '业务类型(根据业务id和业务类型可以确定业务数据)',
|
||||
`read_flag` tinyint(0) NULL DEFAULT 0 COMMENT '阅读状态:0-未读,1-已读',
|
||||
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'N' COMMENT '是否删除:Y-被删除,N-未删除',
|
||||
`create_user` bigint(0) NULL DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_user` bigint(0) NULL DEFAULT NULL COMMENT '修改人',
|
||||
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '修改时间',
|
||||
PRIMARY KEY (`message_id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统消息' ROW_FORMAT = Dynamic;
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_notice
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_notice`;
|
||||
CREATE TABLE `sys_notice` (
|
||||
`notice_id` bigint(0) NOT NULL COMMENT '主键',
|
||||
`notice_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '通知标题',
|
||||
`notice_summary` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '通知摘要',
|
||||
`notice_content` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '通知内容',
|
||||
`priority_level` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '优先级',
|
||||
`notice_begin_time` datetime(0) NULL DEFAULT NULL COMMENT '开始时间',
|
||||
`notice_end_time` datetime(0) NULL DEFAULT NULL COMMENT '结束时间',
|
||||
`notice_scope` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '通知范围(用户id字符串)',
|
||||
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'N' COMMENT '是否删除:Y-被删除,N-未删除',
|
||||
`create_user` bigint(0) NULL DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_user` bigint(0) NULL DEFAULT NULL COMMENT '修改人',
|
||||
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '修改时间',
|
||||
PRIMARY KEY (`notice_id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '通知管理' ROW_FORMAT = Dynamic;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
<module>system-business-user</module>
|
||||
<module>system-business-role</module>
|
||||
<module>system-business-menu</module>
|
||||
<module>system-business-notice</module>
|
||||
<module>system-spring-boot-starter</module>
|
||||
</modules>
|
||||
|
||||
|
|
|
@ -58,6 +58,10 @@
|
|||
<artifactId>spring-web</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package cn.stylefeng.roses.kernel.system;
|
||||
|
||||
/**
|
||||
* 通知api
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/8 21:40
|
||||
*/
|
||||
public interface NoticeServiceApi {
|
||||
|
||||
|
||||
}
|
|
@ -1,8 +1,10 @@
|
|||
package cn.stylefeng.roses.kernel.system;
|
||||
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.SysUserDTO;
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.SysUserResponse;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.UserLoginInfoDTO;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.request.SysUserRequest;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@ -92,4 +94,37 @@ public interface UserServiceApi {
|
|||
*/
|
||||
SysUserResponse getUserInfoByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 查询全部用户ID(剔除管理员,和不允许登录)
|
||||
*
|
||||
* @param sysUserRequest 查询参数
|
||||
* @return List<Long> 用户id 集合
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/4 22:09
|
||||
*/
|
||||
List<Long> queryAllUserIdList(SysUserRequest sysUserRequest);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 用户信息
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/4 22:09
|
||||
*/
|
||||
SysUserDTO getUserInfo(Long userId);
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户id 判断用户是否存在
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 用户信息
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/4 22:55
|
||||
*/
|
||||
Boolean userExist(Long userId);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
Copyright [2020] [https://www.stylefeng.cn]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
|
||||
1.请不要删除和修改根目录下的LICENSE文件。
|
||||
2.请不要删除和修改Guns源码头部的版权声明。
|
||||
3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation
|
||||
5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation
|
||||
6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.system.exception.enums;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.abstracts.AbstractExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
|
||||
import cn.stylefeng.roses.kernel.system.constants.SystemConstants;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 通知管理相关异常枚举
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/9 16:11
|
||||
*/
|
||||
@Getter
|
||||
public enum NoticeExceptionEnum implements AbstractExceptionEnum {
|
||||
|
||||
/**
|
||||
* 通知不存在
|
||||
*/
|
||||
NOTICE_NOT_EXIST(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + SystemConstants.SYSTEM_EXCEPTION_STEP_CODE + "91", "通知不存在"),
|
||||
/**
|
||||
* 通知范围不允许修改
|
||||
*/
|
||||
NOTICE_SCOPE_NOT_EDIT(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + SystemConstants.SYSTEM_EXCEPTION_STEP_CODE + "92", "通知范围不允许修改");
|
||||
|
||||
/**
|
||||
* 错误编码
|
||||
*/
|
||||
private final String errorCode;
|
||||
|
||||
/**
|
||||
* 提示用户信息
|
||||
*/
|
||||
private final String userTip;
|
||||
|
||||
NoticeExceptionEnum(String errorCode, String userTip) {
|
||||
this.errorCode = errorCode;
|
||||
this.userTip = userTip;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package cn.stylefeng.roses.kernel.system.pojo.notice;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 系统通知参数
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/8 21:53
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class SysNoticeRequest extends BaseRequest {
|
||||
|
||||
|
||||
/**
|
||||
* 通知id
|
||||
*/
|
||||
@NotNull(message = "noticeId不能为空", groups = {edit.class, delete.class, detail.class})
|
||||
private Long noticeId;
|
||||
|
||||
/**
|
||||
* 通知标题
|
||||
*/
|
||||
@NotBlank(message = "通知标题不能为空", groups = {add.class, edit.class})
|
||||
private String noticeTitle;
|
||||
/**
|
||||
* 通知摘要
|
||||
*/
|
||||
private String noticeSummary;
|
||||
|
||||
/**
|
||||
* 通知优先级
|
||||
*/
|
||||
@NotBlank(message = "通知优先级不能为空", groups = {add.class, edit.class})
|
||||
private String priorityLevel;
|
||||
|
||||
|
||||
/**
|
||||
* 通知开始时间
|
||||
*/
|
||||
@NotNull(message = "通知开始时间不能为空", groups = {add.class, edit.class})
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date noticeBeginTime;
|
||||
|
||||
|
||||
/**
|
||||
* 通知结束时间
|
||||
*/
|
||||
@NotNull(message = "通知开始时间不能为空", groups = {add.class, edit.class})
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date noticeEndTime;
|
||||
|
||||
/**
|
||||
* 通知内容
|
||||
*/
|
||||
private String noticeContent;
|
||||
|
||||
/**
|
||||
* 通知范围
|
||||
*/
|
||||
private String noticeScope;
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package cn.stylefeng.roses.kernel.system.pojo.user;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 系统用户结果
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/4/2 9:19
|
||||
*/
|
||||
@Data
|
||||
public class SysUserDTO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 账号
|
||||
*/
|
||||
private String account;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String realName;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private Long avatar;
|
||||
|
||||
/**
|
||||
* 生日
|
||||
*/
|
||||
private Date birthday;
|
||||
|
||||
/**
|
||||
* 性别(M-男,F-女)
|
||||
*/
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 手机
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
private String tel;
|
||||
|
||||
/**
|
||||
* 用户所属机构
|
||||
*/
|
||||
private Long orgId;
|
||||
|
||||
/**
|
||||
* 用户所属机构的职务
|
||||
*/
|
||||
private Long positionId;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer statusFlag;
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package cn.stylefeng.roses.kernel.system.modular.user.pojo.request;
|
||||
package cn.stylefeng.roses.kernel.system.pojo.user.request;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import cn.stylefeng.roses.kernel.validator.validators.date.DateValue;
|
|
@ -0,0 +1 @@
|
|||
通知模块
|
|
@ -0,0 +1,65 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>kernel-s-system</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>system-business-notice</artifactId>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!--系统管理api模块-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>system-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--通知api模块-->
|
||||
<!--用在通知控制器,通知扫描上-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>scanner-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--参数校验模块-->
|
||||
<!--用在控制器,参数校验-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>validator-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--数据库sdk-->
|
||||
<!--数据库dao框架-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>db-sdk-mp</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--web模块-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>message-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,98 @@
|
|||
package cn.stylefeng.roses.kernel.notice.modular.controller;
|
||||
|
||||
import cn.stylefeng.roses.kernel.notice.modular.service.SysNoticeService;
|
||||
import cn.stylefeng.roses.kernel.resource.api.annotation.ApiResource;
|
||||
import cn.stylefeng.roses.kernel.resource.api.annotation.GetResource;
|
||||
import cn.stylefeng.roses.kernel.resource.api.annotation.PostResource;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.notice.SysNoticeRequest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 通知管理控制器
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/8 19:47
|
||||
*/
|
||||
@RestController
|
||||
@ApiResource(name = "通知管理")
|
||||
public class NoticeController {
|
||||
|
||||
@Autowired
|
||||
private SysNoticeService sysResourceService;
|
||||
|
||||
|
||||
/**
|
||||
* 添加通知管理
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/9 14:44
|
||||
*/
|
||||
@PostResource(name = "添加通知管理", path = "/sysNotice/add")
|
||||
public ResponseData add(@RequestBody @Validated(SysNoticeRequest.add.class) SysNoticeRequest sysNoticeParam) {
|
||||
sysResourceService.add(sysNoticeParam);
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑通知管理
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/9 14:54
|
||||
*/
|
||||
@PostResource(name = "编辑通知管理", path = "/sysNotice/edit")
|
||||
public ResponseData edit(@RequestBody @Validated(SysNoticeRequest.edit.class) SysNoticeRequest sysNoticeParam) {
|
||||
sysResourceService.edit(sysNoticeParam);
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除通知管理
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/9 14:54
|
||||
*/
|
||||
@PostResource(name = "删除通知管理", path = "/sysNotice/delete")
|
||||
public ResponseData delete(@RequestBody @Validated(SysNoticeRequest.delete.class) SysNoticeRequest sysNoticeParam) {
|
||||
sysResourceService.delete(sysNoticeParam);
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看通知管理
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/9 9:49
|
||||
*/
|
||||
@GetResource(name = "查看通知管理", path = "/sysNotice/detail")
|
||||
public ResponseData detail(@Validated(SysNoticeRequest.detail.class) SysNoticeRequest sysNoticeParam) {
|
||||
return new SuccessResponseData(sysResourceService.detail(sysNoticeParam));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询通知管理
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/9 21:23
|
||||
*/
|
||||
@GetResource(name = "查询通知管理", path = "/sysNotice/page")
|
||||
public ResponseData page(SysNoticeRequest sysNoticeParam) {
|
||||
return new SuccessResponseData(sysResourceService.page(sysNoticeParam));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通知管理列表
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/9 14:55
|
||||
*/
|
||||
@GetResource(name = "通知管理列表", path = "/sysNotice/list")
|
||||
public ResponseData list(SysNoticeRequest sysNoticeParam) {
|
||||
return new SuccessResponseData(sysResourceService.list(sysNoticeParam));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package cn.stylefeng.roses.kernel.notice.modular.entity;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 通知表
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/8 22:45
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("sys_notice")
|
||||
public class SysNotice extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 通知id
|
||||
*/
|
||||
@TableId("notice_id")
|
||||
private Long noticeId;
|
||||
|
||||
/**
|
||||
* 通知标题
|
||||
*/
|
||||
@TableField("notice_title")
|
||||
private String noticeTitle;
|
||||
/**
|
||||
* 通知摘要
|
||||
*/
|
||||
@TableField("notice_summary")
|
||||
private String noticeSummary;
|
||||
|
||||
/**
|
||||
* 通知优先级
|
||||
*/
|
||||
@TableField(value = "priority_level")
|
||||
private String priorityLevel;
|
||||
|
||||
|
||||
/**
|
||||
* 通知开始时间
|
||||
*/
|
||||
@TableField(value = "notice_begin_time")
|
||||
private Date noticeBeginTime;
|
||||
|
||||
|
||||
/**
|
||||
* 通知结束时间
|
||||
*/
|
||||
@TableField(value = "notice_end_time")
|
||||
private Date noticeEndTime;
|
||||
|
||||
/**
|
||||
* 通知内容
|
||||
*/
|
||||
@TableField("notice_content")
|
||||
private String noticeContent;
|
||||
|
||||
/**
|
||||
* 通知范围
|
||||
*/
|
||||
@TableField("notice_scope")
|
||||
private String noticeScope;
|
||||
|
||||
/**
|
||||
* 是否删除:Y-已删除,N-未删除
|
||||
*/
|
||||
@TableField(value = "del_flag", fill = FieldFill.INSERT)
|
||||
private String delFlag;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package cn.stylefeng.roses.kernel.notice.modular.mapper;
|
||||
|
||||
import cn.stylefeng.roses.kernel.notice.modular.entity.SysNotice;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 通知表 Mapper 接口
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/8 22:45
|
||||
*/
|
||||
public interface SysNoticeMapper extends BaseMapper<SysNotice> {
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<?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="cn.stylefeng.roses.kernel.notice.modular.mapper.SysNoticeMapper">
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,78 @@
|
|||
package cn.stylefeng.roses.kernel.notice.modular.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.notice.modular.entity.SysNotice;
|
||||
import cn.stylefeng.roses.kernel.system.NoticeServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.notice.SysNoticeRequest;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通知服务类
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/8 19:56
|
||||
*/
|
||||
public interface SysNoticeService extends IService<SysNotice>, NoticeServiceApi {
|
||||
|
||||
/**
|
||||
* 添加系统应用
|
||||
*
|
||||
* @param SysNoticeParam 添加参数
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/9 14:57
|
||||
*/
|
||||
void add(SysNoticeRequest SysNoticeParam);
|
||||
|
||||
/**
|
||||
* 编辑系统应用
|
||||
*
|
||||
* @param SysNoticeParam 编辑参数
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/9 14:58
|
||||
*/
|
||||
void edit(SysNoticeRequest SysNoticeParam);
|
||||
|
||||
|
||||
/**
|
||||
* 删除系统应用
|
||||
*
|
||||
* @param SysNoticeParam 删除参数
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/9 14:57
|
||||
*/
|
||||
void delete(SysNoticeRequest SysNoticeParam);
|
||||
|
||||
/**
|
||||
* 查看系统应用
|
||||
*
|
||||
* @param SysNoticeParam 查看参数
|
||||
* @return 系统应用
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/9 14:56
|
||||
*/
|
||||
SysNotice detail(SysNoticeRequest SysNoticeParam);
|
||||
|
||||
/**
|
||||
* 查询系统应用
|
||||
*
|
||||
* @param SysNoticeParam 查询参数
|
||||
* @return 查询分页结果
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/9 14:56
|
||||
*/
|
||||
PageResult<SysNotice> page(SysNoticeRequest SysNoticeParam);
|
||||
|
||||
/**
|
||||
* 系统应用列表
|
||||
*
|
||||
* @param SysNoticeParam 查询参数
|
||||
* @return 系统应用列表
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/9 14:56
|
||||
*/
|
||||
List<SysNotice> list(SysNoticeRequest SysNoticeParam);
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,167 @@
|
|||
package cn.stylefeng.roses.kernel.notice.modular.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.message.api.MessageApi;
|
||||
import cn.stylefeng.roses.kernel.message.api.enums.MessageBusinessTypeEnum;
|
||||
import cn.stylefeng.roses.kernel.message.api.pojo.MessageSendParam;
|
||||
import cn.stylefeng.roses.kernel.notice.modular.entity.SysNotice;
|
||||
import cn.stylefeng.roses.kernel.notice.modular.mapper.SysNoticeMapper;
|
||||
import cn.stylefeng.roses.kernel.notice.modular.service.SysNoticeService;
|
||||
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import cn.stylefeng.roses.kernel.system.exception.enums.NoticeExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.notice.SysNoticeRequest;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通知表 服务实现类
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/8 22:45
|
||||
*/
|
||||
@Service
|
||||
public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice> implements SysNoticeService {
|
||||
|
||||
|
||||
private static String NOTICE_SCOPE_ALL = "all";
|
||||
|
||||
@Autowired
|
||||
private SysNoticeMapper noticeMapper;
|
||||
/**
|
||||
* 系统消息api
|
||||
*/
|
||||
@Autowired
|
||||
private MessageApi messageApi;
|
||||
|
||||
private void sendMessage(SysNotice sysNotice){
|
||||
MessageSendParam message = new MessageSendParam();
|
||||
// 消息标题
|
||||
message.setMessageTitle(sysNotice.getNoticeTitle());
|
||||
// 消息内容
|
||||
message.setMessageContent(sysNotice.getNoticeSummary());
|
||||
// 消息优先级
|
||||
message.setPriorityLevel(sysNotice.getPriorityLevel());
|
||||
// 消息发送范围
|
||||
message.setReceiveUserIds(sysNotice.getNoticeScope());
|
||||
// 消息业务类型
|
||||
message.setBusinessType(MessageBusinessTypeEnum.SYS_NOTICE.getCode());
|
||||
message.setBusinessId(sysNotice.getNoticeId());
|
||||
messageApi.sendMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(SysNoticeRequest sysNoticeRequest) {
|
||||
SysNotice sysNotice = new SysNotice();
|
||||
BeanUtil.copyProperties(sysNoticeRequest, sysNotice);
|
||||
if(StrUtil.isBlank(sysNotice.getNoticeScope())){
|
||||
sysNotice.setNoticeScope(NOTICE_SCOPE_ALL);
|
||||
}
|
||||
|
||||
// 如果保存成功调用发送消息
|
||||
if(this.save(sysNotice)){
|
||||
sendMessage(sysNotice);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit(SysNoticeRequest sysNoticeRequest) {
|
||||
|
||||
SysNotice sysNotice = this.querySysNotice(sysNoticeRequest);
|
||||
String noticeScope = sysNotice.getNoticeScope();
|
||||
if(StrUtil.isBlank(sysNoticeRequest.getNoticeScope())){
|
||||
sysNoticeRequest.setNoticeScope(NOTICE_SCOPE_ALL);
|
||||
}
|
||||
if(sysNoticeRequest.equals(sysNotice.getNoticeScope())){
|
||||
throw new ServiceException(NoticeExceptionEnum.NOTICE_SCOPE_NOT_EDIT);
|
||||
}
|
||||
BeanUtil.copyProperties(sysNoticeRequest, sysNotice);
|
||||
|
||||
// 通知范围不允许修改
|
||||
sysNotice.setNoticeScope(noticeScope);
|
||||
|
||||
if(this.updateById(sysNotice)){
|
||||
sendMessage(sysNotice);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void delete(SysNoticeRequest sysNoticeRequest) {
|
||||
SysNotice sysNotice = this.querySysNotice(sysNoticeRequest);
|
||||
// 逻辑删除
|
||||
sysNotice.setDelFlag(YesOrNotEnum.Y.getCode());
|
||||
this.updateById(sysNotice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysNotice detail(SysNoticeRequest sysNoticeRequest) {
|
||||
return this.querySysNotice(sysNoticeRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<SysNotice> page(SysNoticeRequest sysNoticeRequest) {
|
||||
LambdaQueryWrapper<SysNotice> wrapper = createWrapper(sysNoticeRequest);
|
||||
Page<SysNotice> page = this.page(PageFactory.defaultPage(), wrapper);
|
||||
return PageResultFactory.createPageResult(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysNotice> list(SysNoticeRequest sysNoticeRequest) {
|
||||
LambdaQueryWrapper<SysNotice> wrapper = createWrapper(sysNoticeRequest);
|
||||
return this.list(wrapper);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取通知管理
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/9 16:56
|
||||
*/
|
||||
private SysNotice querySysNotice(SysNoticeRequest sysNoticeRequest) {
|
||||
SysNotice sysNotice = this.getById(sysNoticeRequest.getNoticeId());
|
||||
if (ObjectUtil.isNull(sysNotice)) {
|
||||
throw new ServiceException(NoticeExceptionEnum.NOTICE_NOT_EXIST);
|
||||
}
|
||||
return sysNotice;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建wrapper
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2020/1/9 16:16
|
||||
*/
|
||||
private LambdaQueryWrapper<SysNotice> createWrapper(SysNoticeRequest sysNoticeRequest) {
|
||||
LambdaQueryWrapper<SysNotice> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(sysNoticeRequest)) {
|
||||
// 根据id查询
|
||||
if (ObjectUtil.isNotEmpty(sysNoticeRequest.getNoticeId())) {
|
||||
queryWrapper.eq(SysNotice::getNoticeId, sysNoticeRequest.getNoticeId());
|
||||
}
|
||||
|
||||
// 根据消息标题模糊查询
|
||||
if (ObjectUtil.isNotEmpty(sysNoticeRequest.getNoticeTitle())) {
|
||||
queryWrapper.like(SysNotice::getNoticeTitle, sysNoticeRequest.getNoticeTitle()).or().like(SysNotice::getNoticeSummary, sysNoticeRequest.getNoticeTitle()).or().like(SysNotice::getNoticeContent, sysNoticeRequest.getNoticeTitle());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 查询未删除状态的
|
||||
queryWrapper.eq(SysNotice::getDelFlag, YesOrNotEnum.N.getCode());
|
||||
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
}
|
|
@ -8,7 +8,7 @@ import cn.stylefeng.roses.kernel.resource.api.annotation.PostResource;
|
|||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.pojo.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserRoleService;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
|
|
@ -9,7 +9,7 @@ import cn.stylefeng.roses.kernel.rule.enums.SexEnum;
|
|||
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
||||
import cn.stylefeng.roses.kernel.system.enums.UserStatusEnum;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUser;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.pojo.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.request.SysUserRequest;
|
||||
|
||||
/**
|
||||
* 用户信息填充,用于创建和修改用户时,添加一些基础信息
|
||||
|
|
|
@ -3,7 +3,7 @@ package cn.stylefeng.roses.kernel.system.modular.user.mapper;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUser;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.pojo.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.pojo.response.SysUserResponse;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package cn.stylefeng.roses.kernel.system.modular.user.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUserDataScope;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.pojo.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.request.SysUserRequest;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package cn.stylefeng.roses.kernel.system.modular.user.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUserRole;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.pojo.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.request.SysUserRequest;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -4,7 +4,7 @@ import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
|||
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
|
||||
import cn.stylefeng.roses.kernel.system.UserServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUser;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.pojo.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.pojo.response.SysUserResponse;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package cn.stylefeng.roses.kernel.system.modular.user.service.impl;
|
|||
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUserDataScope;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.mapper.SysUserDataScopeMapper;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.pojo.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserDataScopeService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
|
|
@ -4,7 +4,7 @@ import cn.stylefeng.roses.kernel.system.exception.SystemModularException;
|
|||
import cn.stylefeng.roses.kernel.system.exception.enums.SysUserExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUserRole;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.mapper.SysUserRoleMapper;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.pojo.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserRoleService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
|
|
@ -28,7 +28,8 @@ import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUserRole;
|
|||
import cn.stylefeng.roses.kernel.system.modular.user.factory.SysUserCreateFactory;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.factory.UserLoginInfoFactory;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.mapper.SysUserMapper;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.pojo.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.SysUserDTO;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.pojo.response.SysUserResponse;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserDataScopeService;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserOrgService;
|
||||
|
@ -54,6 +55,7 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
@ -484,6 +486,58 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Long> queryAllUserIdList(SysUserRequest sysUserRequest) {
|
||||
|
||||
LambdaQueryWrapper<SysUser> wrapper = createWrapper(sysUserRequest);
|
||||
|
||||
// 排除超级管理员
|
||||
// wrapper.ne(SysUser::getSuperAdminFlag, YesOrNotEnum.Y.getCode());
|
||||
|
||||
// 只查询id
|
||||
wrapper.select(SysUser::getUserId);
|
||||
// 查询全部用户ID
|
||||
Function<Object, Long> mapper = id -> Long.valueOf(id.toString());
|
||||
List<Long> userIds = this.listObjs(wrapper, mapper);
|
||||
|
||||
return userIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统用户信息
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/4 22:54
|
||||
*/
|
||||
@Override
|
||||
public SysUserDTO getUserInfo(Long userId) {
|
||||
SysUser sysUser = this.getById(userId);
|
||||
if (ObjectUtil.isNull(sysUser)) {
|
||||
throw new SystemModularException(SysUserExceptionEnum.USER_NOT_EXIST, userId);
|
||||
}
|
||||
SysUserDTO userDTO = new SysUserDTO();
|
||||
BeanUtil.copyProperties(sysUser, userDTO);
|
||||
return userDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean userExist(Long userId) {
|
||||
SysUserRequest userRequest = new SysUserRequest();
|
||||
userRequest.setUserId(userId);
|
||||
LambdaQueryWrapper<SysUser> wrapper = createWrapper(userRequest);
|
||||
|
||||
// 只查询id
|
||||
wrapper.select(SysUser::getUserId);
|
||||
// 查询用户
|
||||
SysUser sysUser = this.getOne(wrapper);
|
||||
if (sysUser == null || sysUser.getUserId() == null) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统用户
|
||||
*
|
||||
|
|
|
@ -59,6 +59,13 @@
|
|||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--通知管理的业务-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>system-business-notice</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
Loading…
Reference in New Issue