From 4a5da6eaf50be732b7611b209f8cb0b7a00b9b92 Mon Sep 17 00:00:00 2001 From: liuhanqing <447067298@qq.com> Date: Fri, 1 Jan 2021 22:35:57 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E3=80=90message=E3=80=91=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E6=B6=88=E6=81=AF=E6=A8=A1=E5=9D=97=E5=88=9D=E6=AD=A5?= =?UTF-8?q?=E5=88=92=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel-d-message/README.md | 3 + kernel-d-message/message-api/README.md | 1 + kernel-d-message/message-api/pom.xml | 57 ++++++++++++ .../roses/kernel/message/api/MessageApi.java | 14 +++ .../api/constants/MessageConstants.java | 36 ++++++++ .../message/api/context/MessageContext.java | 24 +++++ .../api/exception/MessageException.java | 19 ++++ .../exception/enums/MessageExceptionEnum.java | 37 ++++++++ .../kernel/message/api/pojo/MessageParam.java | 71 +++++++++++++++ .../message/api/pojo/MessageSendParam.java | 53 +++++++++++ kernel-d-message/message-business/README.md | 1 + kernel-d-message/message-business/pom.xml | 59 +++++++++++++ .../controller/SysMessageController.java | 25 ++++++ kernel-d-message/message-sdk-db/README.md | 1 + kernel-d-message/message-sdk-db/pom.xml | 36 ++++++++ .../kernel/message/db/entity/SysMessage.java | 87 +++++++++++++++++++ .../message/db/mapper/SysMessageMapper.java | 14 +++ .../db/mapper/mapping/SysMessageMapper.xml | 4 + .../message/db/service/SysMessageService.java | 14 +++ .../service/impl/SysMessageServiceImpl.java | 18 ++++ .../message-spring-boot-starter/README.md | 1 + .../message-spring-boot-starter/pom.xml | 38 ++++++++ .../starter/GunsMessageAutoConfiguration.java | 16 ++++ .../main/resources/META-INF/spring.factories | 2 + kernel-d-message/pom.xml | 36 ++++++++ pom.xml | 3 + 26 files changed, 670 insertions(+) create mode 100644 kernel-d-message/README.md create mode 100644 kernel-d-message/message-api/README.md create mode 100644 kernel-d-message/message-api/pom.xml create mode 100644 kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/MessageApi.java create mode 100644 kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/constants/MessageConstants.java create mode 100644 kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/context/MessageContext.java create mode 100644 kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/exception/MessageException.java create mode 100644 kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/exception/enums/MessageExceptionEnum.java create mode 100644 kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageParam.java create mode 100644 kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageSendParam.java create mode 100644 kernel-d-message/message-business/README.md create mode 100644 kernel-d-message/message-business/pom.xml create mode 100644 kernel-d-message/message-business/src/main/java/cn/stylefeng/roses/kernel/message/modular/manage/controller/SysMessageController.java create mode 100644 kernel-d-message/message-sdk-db/README.md create mode 100644 kernel-d-message/message-sdk-db/pom.xml create mode 100644 kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/entity/SysMessage.java create mode 100644 kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/mapper/SysMessageMapper.java create mode 100644 kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/mapper/mapping/SysMessageMapper.xml create mode 100644 kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/SysMessageService.java create mode 100644 kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/impl/SysMessageServiceImpl.java create mode 100644 kernel-d-message/message-spring-boot-starter/README.md create mode 100644 kernel-d-message/message-spring-boot-starter/pom.xml create mode 100644 kernel-d-message/message-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/message/starter/GunsMessageAutoConfiguration.java create mode 100644 kernel-d-message/message-spring-boot-starter/src/main/resources/META-INF/spring.factories create mode 100644 kernel-d-message/pom.xml diff --git a/kernel-d-message/README.md b/kernel-d-message/README.md new file mode 100644 index 000000000..2c1c3db8c --- /dev/null +++ b/kernel-d-message/README.md @@ -0,0 +1,3 @@ +系统消息模块 + +系统消息模块可以发送消息记录,已读未读状态 diff --git a/kernel-d-message/message-api/README.md b/kernel-d-message/message-api/README.md new file mode 100644 index 000000000..1368f2aa3 --- /dev/null +++ b/kernel-d-message/message-api/README.md @@ -0,0 +1 @@ +系统消息模块的api \ No newline at end of file diff --git a/kernel-d-message/message-api/pom.xml b/kernel-d-message/message-api/pom.xml new file mode 100644 index 000000000..17ac09d84 --- /dev/null +++ b/kernel-d-message/message-api/pom.xml @@ -0,0 +1,57 @@ + + + 4.0.0 + + + cn.stylefeng.roses + kernel-d-message + 1.0.0 + ../pom.xml + + + message-api + + jar + + + + + + + + cn.stylefeng.roses + auth-api + 1.0.0 + true + + + + + + cn.stylefeng.roses + validator-api + 1.0.0 + + + + + + cn.stylefeng.roses + db-api + 1.0.0 + + + + + + + javax.servlet + javax.servlet-api + true + + + + + diff --git a/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/MessageApi.java b/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/MessageApi.java new file mode 100644 index 000000000..96109ddd5 --- /dev/null +++ b/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/MessageApi.java @@ -0,0 +1,14 @@ +package cn.stylefeng.roses.kernel.message.api; + +/** + * 系统消息相关接口 + *

+ * 接口可以有多种实现,目前只实现数据库存储方式 + * + * @author liuhanqing + * @date 2021/1/1 20:21 + */ +public interface MessageApi { + + +} \ No newline at end of file diff --git a/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/constants/MessageConstants.java b/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/constants/MessageConstants.java new file mode 100644 index 000000000..c61294c5e --- /dev/null +++ b/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/constants/MessageConstants.java @@ -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-d-message"; + + /** + * 异常枚举的步进值 + */ + String MESSAGE_EXCEPTION_STEP_CODE = "23"; + + /** + * 发送所有用户标识 + */ + String RECEIVE_ALL_USER_FLAG = "all"; + + /** + * 默认查询日志分页 + */ + Integer DEFAULT_BEGIN_PAGE_NO = 1; + + /** + * 默认查询日志分页大小 + */ + Integer DEFAULT_PAGE_SIZE = 10; + +} diff --git a/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/context/MessageContext.java b/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/context/MessageContext.java new file mode 100644 index 000000000..07a3df1ff --- /dev/null +++ b/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/context/MessageContext.java @@ -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); + } + +} diff --git a/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/exception/MessageException.java b/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/exception/MessageException.java new file mode 100644 index 000000000..a98e76b81 --- /dev/null +++ b/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/exception/MessageException.java @@ -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); + } + +} diff --git a/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/exception/enums/MessageExceptionEnum.java b/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/exception/enums/MessageExceptionEnum.java new file mode 100644 index 000000000..8498988cb --- /dev/null +++ b/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/exception/enums/MessageExceptionEnum.java @@ -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; + } + +} diff --git a/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageParam.java b/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageParam.java new file mode 100644 index 000000000..8d28ea806 --- /dev/null +++ b/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageParam.java @@ -0,0 +1,71 @@ +package cn.stylefeng.roses.kernel.message.api.pojo.manage; + +import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotNull; +import java.util.Date; + +/** + * 系统消息的查询参数 + * + * @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}) + private Long messageId; + + /** + * 接收用户id + */ + private Long receiveUserId; + + /** + * 发送用户id + */ + private Long sendUserId; + + /** + * 消息标题 + */ + private String messageTitle; + + /** + * 消息的内容 + */ + private String messageContent; + + /** + * 消息类型 + */ + private String messageType; + + /** + * 消息发送时间 + */ + private Date messageSendTime; + + /** + * 业务id + */ + private Long businessId; + + /** + * 业务类型 + */ + private String businessType; + + /** + * 阅读状态:0-未读,1-已读 + */ + private Integer readFlag; + +} diff --git a/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageSendParam.java b/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageSendParam.java new file mode 100644 index 000000000..6a9b334bf --- /dev/null +++ b/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageSendParam.java @@ -0,0 +1,53 @@ +package cn.stylefeng.roses.kernel.message.api.pojo.manage; + +import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; + +/** + * 发送系统消息的参数 + * + * @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; + + /** + * 业务id + */ + @NotBlank(message = "业务id不能为空", groups = {add.class, edit.class}) + private Long businessId; + + /** + * 业务类型 + */ + @NotBlank(message = "业务类型不能为空", groups = {add.class, edit.class}) + private String businessType; + +} diff --git a/kernel-d-message/message-business/README.md b/kernel-d-message/message-business/README.md new file mode 100644 index 000000000..46ec04adf --- /dev/null +++ b/kernel-d-message/message-business/README.md @@ -0,0 +1 @@ +系统消息业务模块,包含发送消息,查看消息,消息列表,已读消息,未读消息的业务 \ No newline at end of file diff --git a/kernel-d-message/message-business/pom.xml b/kernel-d-message/message-business/pom.xml new file mode 100644 index 000000000..83979a693 --- /dev/null +++ b/kernel-d-message/message-business/pom.xml @@ -0,0 +1,59 @@ + + + 4.0.0 + + + cn.stylefeng.roses + kernel-d-log + 1.0.0 + ../pom.xml + + + message-business + + jar + + + + + + cn.stylefeng.roses + message-api + 1.0.0 + + + + + + cn.stylefeng.roses + scanner-api + 1.0.0 + + + + + + cn.stylefeng.roses + validator-api + 1.0.0 + + + + + + cn.stylefeng.roses + db-sdk-mp + 1.0.0 + + + + + org.springframework.boot + spring-boot-starter-web + + + + + diff --git a/kernel-d-message/message-business/src/main/java/cn/stylefeng/roses/kernel/message/modular/manage/controller/SysMessageController.java b/kernel-d-message/message-business/src/main/java/cn/stylefeng/roses/kernel/message/modular/manage/controller/SysMessageController.java new file mode 100644 index 000000000..5e7a511ee --- /dev/null +++ b/kernel-d-message/message-business/src/main/java/cn/stylefeng/roses/kernel/message/modular/manage/controller/SysMessageController.java @@ -0,0 +1,25 @@ +package cn.stylefeng.roses.kernel.message.modular.manage.controller; + +import cn.stylefeng.roses.kernel.message.api.MessageApi; +import cn.stylefeng.roses.kernel.resource.api.annotation.ApiResource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RestController; + +/** + * 系统消息控制器 + * + * @author liuhanqing + * @date 2021/1/1 22:30 + */ +@RestController +@ApiResource(name = "系统消息控制器") +public class SysMessageController { + + /** + * 系统消息api + */ + @Autowired + private MessageApi messageApi; + + +} diff --git a/kernel-d-message/message-sdk-db/README.md b/kernel-d-message/message-sdk-db/README.md new file mode 100644 index 000000000..4766a8ca2 --- /dev/null +++ b/kernel-d-message/message-sdk-db/README.md @@ -0,0 +1 @@ +系统消息记录的sdk,用于将消息记录到数据库中,提供相关消息管理接口 \ No newline at end of file diff --git a/kernel-d-message/message-sdk-db/pom.xml b/kernel-d-message/message-sdk-db/pom.xml new file mode 100644 index 000000000..b12b29801 --- /dev/null +++ b/kernel-d-message/message-sdk-db/pom.xml @@ -0,0 +1,36 @@ + + + 4.0.0 + + + cn.stylefeng.roses + kernel-d-message + 1.0.0 + ../pom.xml + + + message-sdk-db + + jar + + + + + + cn.stylefeng.roses + message-api + 1.0.0 + + + + + cn.stylefeng.roses + db-sdk-mp + 1.0.0 + + + + + diff --git a/kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/entity/SysMessage.java b/kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/entity/SysMessage.java new file mode 100644 index 000000000..0f39b4a9b --- /dev/null +++ b/kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/entity/SysMessage.java @@ -0,0 +1,87 @@ +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 + */ + @TableId(value = "receive_user_id") + private Long receiveUserId; + + /** + * 发送用户id + */ + @TableId(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 = "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; + +} \ No newline at end of file diff --git a/kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/mapper/SysMessageMapper.java b/kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/mapper/SysMessageMapper.java new file mode 100644 index 000000000..bdc62af3e --- /dev/null +++ b/kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/mapper/SysMessageMapper.java @@ -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 { + +} diff --git a/kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/mapper/mapping/SysMessageMapper.xml b/kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/mapper/mapping/SysMessageMapper.xml new file mode 100644 index 000000000..2767ad7df --- /dev/null +++ b/kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/mapper/mapping/SysMessageMapper.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/SysMessageService.java b/kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/SysMessageService.java new file mode 100644 index 000000000..77ffa6f8f --- /dev/null +++ b/kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/SysMessageService.java @@ -0,0 +1,14 @@ +package cn.stylefeng.roses.kernel.message.db.service; + +import cn.stylefeng.roses.kernel.message.db.entity.SysMessage; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 系统消息 service接口 + * + * @author liuhanqing + * @date 2020/12/31 20:09 + */ +public interface SysMessageService extends IService { + +} diff --git a/kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/impl/SysMessageServiceImpl.java b/kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/impl/SysMessageServiceImpl.java new file mode 100644 index 000000000..6b4520cd4 --- /dev/null +++ b/kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/impl/SysMessageServiceImpl.java @@ -0,0 +1,18 @@ +package cn.stylefeng.roses.kernel.message.db.service.impl; + +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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + * 系统消息 service接口实现类 + * + * @author liuhanqing + * @date 2020/12/31 20:09 + */ +@Service +public class SysMessageServiceImpl extends ServiceImpl implements SysMessageService { + +} diff --git a/kernel-d-message/message-spring-boot-starter/README.md b/kernel-d-message/message-spring-boot-starter/README.md new file mode 100644 index 000000000..c3a12177f --- /dev/null +++ b/kernel-d-message/message-spring-boot-starter/README.md @@ -0,0 +1 @@ +系统消息的spring boot自动加载模块 \ No newline at end of file diff --git a/kernel-d-message/message-spring-boot-starter/pom.xml b/kernel-d-message/message-spring-boot-starter/pom.xml new file mode 100644 index 000000000..cf61944ed --- /dev/null +++ b/kernel-d-message/message-spring-boot-starter/pom.xml @@ -0,0 +1,38 @@ + + + 4.0.0 + + + cn.stylefeng.roses + kernel-d-message + 1.0.0 + ../pom.xml + + + message-spring-boot-starter + + jar + + + + + + + + + + cn.stylefeng.roses + message-sdk-db + 1.0.0 + + + + + + diff --git a/kernel-d-message/message-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/message/starter/GunsMessageAutoConfiguration.java b/kernel-d-message/message-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/message/starter/GunsMessageAutoConfiguration.java new file mode 100644 index 000000000..a2c26e978 --- /dev/null +++ b/kernel-d-message/message-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/message/starter/GunsMessageAutoConfiguration.java @@ -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 { + + + +} \ No newline at end of file diff --git a/kernel-d-message/message-spring-boot-starter/src/main/resources/META-INF/spring.factories b/kernel-d-message/message-spring-boot-starter/src/main/resources/META-INF/spring.factories new file mode 100644 index 000000000..e86c6ccc0 --- /dev/null +++ b/kernel-d-message/message-spring-boot-starter/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ + cn.stylefeng.roses.kernel.message.starter.GunsMessageAutoConfiguration \ No newline at end of file diff --git a/kernel-d-message/pom.xml b/kernel-d-message/pom.xml new file mode 100644 index 000000000..9429be1b9 --- /dev/null +++ b/kernel-d-message/pom.xml @@ -0,0 +1,36 @@ + + + 4.0.0 + + + cn.stylefeng.roses + roses-kernel + 1.0.0 + ../pom.xml + + + kernel-d-message + + pom + + + message-api + message-business + message-sdk-db + message-spring-boot-starter + + + + + + + cn.stylefeng.roses + kernel-a-rule + 1.0.0 + + + + + diff --git a/pom.xml b/pom.xml index fdec697bf..a9d5a5486 100644 --- a/pom.xml +++ b/pom.xml @@ -73,6 +73,9 @@ kernel-s-dict + + kernel-d-message + kernel-s-system From 77a0779bf9c7de5540c45531d525b0cd287befa9 Mon Sep 17 00:00:00 2001 From: liuhanqing <447067298@qq.com> Date: Sat, 2 Jan 2021 23:02:03 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E3=80=90message=E3=80=91=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../roses/kernel/message/api/MessageApi.java | 14 --- .../README.md | 0 .../message-api/README.md | 0 .../message-api/pom.xml | 0 .../roses/kernel/message/api/MessageApi.java | 87 +++++++++++++++++++ .../api/constants/MessageConstants.java | 0 .../message/api/context/MessageContext.java | 0 .../api/exception/MessageException.java | 0 .../exception/enums/MessageExceptionEnum.java | 0 .../kernel/message/api/pojo/MessageParam.java | 2 +- .../message/api/pojo/MessageResponse.java | 67 ++++++++++++++ .../message/api/pojo/MessageSendParam.java | 2 +- .../message-business/README.md | 0 .../message-business/pom.xml | 0 .../controller/SysMessageController.java | 0 .../message-sdk-db/README.md | 0 .../message-sdk-db/pom.xml | 0 .../message/db/MessageDbServiceImpl.java | 63 ++++++++++++++ .../kernel/message/db/entity/SysMessage.java | 0 .../message/db/mapper/SysMessageMapper.java | 0 .../db/mapper/mapping/SysMessageMapper.xml | 0 .../message/db/service/SysMessageService.java | 0 .../service/impl/SysMessageServiceImpl.java | 0 .../message-spring-boot-starter/README.md | 0 .../message-spring-boot-starter/pom.xml | 0 .../starter/GunsMessageAutoConfiguration.java | 0 .../main/resources/META-INF/spring.factories | 0 .../pom.xml | 2 +- pom.xml | 2 +- 29 files changed, 221 insertions(+), 18 deletions(-) delete mode 100644 kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/MessageApi.java rename {kernel-d-message => kernel-s-message}/README.md (100%) rename {kernel-d-message => kernel-s-message}/message-api/README.md (100%) rename {kernel-d-message => kernel-s-message}/message-api/pom.xml (100%) create mode 100644 kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/MessageApi.java rename {kernel-d-message => kernel-s-message}/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/constants/MessageConstants.java (100%) rename {kernel-d-message => kernel-s-message}/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/context/MessageContext.java (100%) rename {kernel-d-message => kernel-s-message}/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/exception/MessageException.java (100%) rename {kernel-d-message => kernel-s-message}/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/exception/enums/MessageExceptionEnum.java (100%) rename {kernel-d-message => kernel-s-message}/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageParam.java (95%) create mode 100644 kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageResponse.java rename {kernel-d-message => kernel-s-message}/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageSendParam.java (95%) rename {kernel-d-message => kernel-s-message}/message-business/README.md (100%) rename {kernel-d-message => kernel-s-message}/message-business/pom.xml (100%) rename {kernel-d-message => kernel-s-message}/message-business/src/main/java/cn/stylefeng/roses/kernel/message/modular/manage/controller/SysMessageController.java (100%) rename {kernel-d-message => kernel-s-message}/message-sdk-db/README.md (100%) rename {kernel-d-message => kernel-s-message}/message-sdk-db/pom.xml (100%) create mode 100644 kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/MessageDbServiceImpl.java rename {kernel-d-message => kernel-s-message}/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/entity/SysMessage.java (100%) rename {kernel-d-message => kernel-s-message}/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/mapper/SysMessageMapper.java (100%) rename {kernel-d-message => kernel-s-message}/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/mapper/mapping/SysMessageMapper.xml (100%) rename {kernel-d-message => kernel-s-message}/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/SysMessageService.java (100%) rename {kernel-d-message => kernel-s-message}/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/impl/SysMessageServiceImpl.java (100%) rename {kernel-d-message => kernel-s-message}/message-spring-boot-starter/README.md (100%) rename {kernel-d-message => kernel-s-message}/message-spring-boot-starter/pom.xml (100%) rename {kernel-d-message => kernel-s-message}/message-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/message/starter/GunsMessageAutoConfiguration.java (100%) rename {kernel-d-message => kernel-s-message}/message-spring-boot-starter/src/main/resources/META-INF/spring.factories (100%) rename {kernel-d-message => kernel-s-message}/pom.xml (95%) diff --git a/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/MessageApi.java b/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/MessageApi.java deleted file mode 100644 index 96109ddd5..000000000 --- a/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/MessageApi.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.stylefeng.roses.kernel.message.api; - -/** - * 系统消息相关接口 - *

- * 接口可以有多种实现,目前只实现数据库存储方式 - * - * @author liuhanqing - * @date 2021/1/1 20:21 - */ -public interface MessageApi { - - -} \ No newline at end of file diff --git a/kernel-d-message/README.md b/kernel-s-message/README.md similarity index 100% rename from kernel-d-message/README.md rename to kernel-s-message/README.md diff --git a/kernel-d-message/message-api/README.md b/kernel-s-message/message-api/README.md similarity index 100% rename from kernel-d-message/message-api/README.md rename to kernel-s-message/message-api/README.md diff --git a/kernel-d-message/message-api/pom.xml b/kernel-s-message/message-api/pom.xml similarity index 100% rename from kernel-d-message/message-api/pom.xml rename to kernel-s-message/message-api/pom.xml diff --git a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/MessageApi.java b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/MessageApi.java new file mode 100644 index 000000000..3687e057f --- /dev/null +++ b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/MessageApi.java @@ -0,0 +1,87 @@ +package cn.stylefeng.roses.kernel.message.api; + +import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult; +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; + +/** + * 系统消息相关接口 + *

+ * 接口可以有多种实现,目前只实现数据库存储方式 + * + * @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); + + /** + * 删除系统消息 + * + * @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 batchDeleteByMessageId(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 queryMessagePage(MessageParam messageParam); + + /** + * 查询系统消息 + * + * @param messageParam 查询参数 + * @return 系统消息列表 + * @author liuhanqing + * @date 2021/1/2 21:21 + */ + List queryMessageList(MessageParam messageParam); + +} \ No newline at end of file diff --git a/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/constants/MessageConstants.java b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/constants/MessageConstants.java similarity index 100% rename from kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/constants/MessageConstants.java rename to kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/constants/MessageConstants.java diff --git a/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/context/MessageContext.java b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/context/MessageContext.java similarity index 100% rename from kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/context/MessageContext.java rename to kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/context/MessageContext.java diff --git a/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/exception/MessageException.java b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/exception/MessageException.java similarity index 100% rename from kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/exception/MessageException.java rename to kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/exception/MessageException.java diff --git a/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/exception/enums/MessageExceptionEnum.java b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/exception/enums/MessageExceptionEnum.java similarity index 100% rename from kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/exception/enums/MessageExceptionEnum.java rename to kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/exception/enums/MessageExceptionEnum.java diff --git a/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageParam.java b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageParam.java similarity index 95% rename from kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageParam.java rename to kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageParam.java index 8d28ea806..60d62f4d1 100644 --- a/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageParam.java +++ b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageParam.java @@ -1,4 +1,4 @@ -package cn.stylefeng.roses.kernel.message.api.pojo.manage; +package cn.stylefeng.roses.kernel.message.api.pojo; import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest; import lombok.Data; diff --git a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageResponse.java b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageResponse.java new file mode 100644 index 000000000..2d6c01f2d --- /dev/null +++ b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageResponse.java @@ -0,0 +1,67 @@ +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 messageType; + + /** + * 消息发送时间 + */ + private Date messageSendTime; + + /** + * 业务id + */ + private Long businessId; + + /** + * 业务类型 + */ + private String businessType; + + /** + * 阅读状态:0-未读,1-已读 + */ + private Integer readFlag; + +} diff --git a/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageSendParam.java b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageSendParam.java similarity index 95% rename from kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageSendParam.java rename to kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageSendParam.java index 6a9b334bf..a044b4320 100644 --- a/kernel-d-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageSendParam.java +++ b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageSendParam.java @@ -1,4 +1,4 @@ -package cn.stylefeng.roses.kernel.message.api.pojo.manage; +package cn.stylefeng.roses.kernel.message.api.pojo; import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest; import lombok.Data; diff --git a/kernel-d-message/message-business/README.md b/kernel-s-message/message-business/README.md similarity index 100% rename from kernel-d-message/message-business/README.md rename to kernel-s-message/message-business/README.md diff --git a/kernel-d-message/message-business/pom.xml b/kernel-s-message/message-business/pom.xml similarity index 100% rename from kernel-d-message/message-business/pom.xml rename to kernel-s-message/message-business/pom.xml diff --git a/kernel-d-message/message-business/src/main/java/cn/stylefeng/roses/kernel/message/modular/manage/controller/SysMessageController.java b/kernel-s-message/message-business/src/main/java/cn/stylefeng/roses/kernel/message/modular/manage/controller/SysMessageController.java similarity index 100% rename from kernel-d-message/message-business/src/main/java/cn/stylefeng/roses/kernel/message/modular/manage/controller/SysMessageController.java rename to kernel-s-message/message-business/src/main/java/cn/stylefeng/roses/kernel/message/modular/manage/controller/SysMessageController.java diff --git a/kernel-d-message/message-sdk-db/README.md b/kernel-s-message/message-sdk-db/README.md similarity index 100% rename from kernel-d-message/message-sdk-db/README.md rename to kernel-s-message/message-sdk-db/README.md diff --git a/kernel-d-message/message-sdk-db/pom.xml b/kernel-s-message/message-sdk-db/pom.xml similarity index 100% rename from kernel-d-message/message-sdk-db/pom.xml rename to kernel-s-message/message-sdk-db/pom.xml diff --git a/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/MessageDbServiceImpl.java b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/MessageDbServiceImpl.java new file mode 100644 index 000000000..380e501fc --- /dev/null +++ b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/MessageDbServiceImpl.java @@ -0,0 +1,63 @@ +package cn.stylefeng.roses.kernel.message.db; + +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.pojo.MessageParam; +import cn.stylefeng.roses.kernel.message.api.pojo.MessageResponse; +import cn.stylefeng.roses.kernel.message.api.pojo.MessageSendParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 系统消息,数据库实现 + * + * @author liuhanqing + * @date 2021/1/2 22:00 + */ +@Slf4j +@Service +public class MessageDbServiceImpl implements MessageApi { + + @Override + public void sendMessage(MessageSendParam messageSendParam) { + String receiveUserIds = messageSendParam.getReceiveUserIds(); + // 发送所有人判断 + if (MessageConstants.RECEIVE_ALL_USER_FLAG.equals(receiveUserIds)) { + + } + + } + + @Override + public void updateReadFlag(MessageParam messageParam) { + + } + + @Override + public void deleteByMessageId(Long messageId) { + + } + + @Override + public void batchDeleteByMessageId(String messageIds) { + + } + + @Override + public MessageResponse messageDetail(MessageParam messageParam) { + return null; + } + + @Override + public PageResult queryMessagePage(MessageParam messageParam) { + return null; + } + + @Override + public List queryMessageList(MessageParam messageParam) { + return null; + } +} diff --git a/kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/entity/SysMessage.java b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/entity/SysMessage.java similarity index 100% rename from kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/entity/SysMessage.java rename to kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/entity/SysMessage.java diff --git a/kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/mapper/SysMessageMapper.java b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/mapper/SysMessageMapper.java similarity index 100% rename from kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/mapper/SysMessageMapper.java rename to kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/mapper/SysMessageMapper.java diff --git a/kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/mapper/mapping/SysMessageMapper.xml b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/mapper/mapping/SysMessageMapper.xml similarity index 100% rename from kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/mapper/mapping/SysMessageMapper.xml rename to kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/mapper/mapping/SysMessageMapper.xml diff --git a/kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/SysMessageService.java b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/SysMessageService.java similarity index 100% rename from kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/SysMessageService.java rename to kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/SysMessageService.java diff --git a/kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/impl/SysMessageServiceImpl.java b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/impl/SysMessageServiceImpl.java similarity index 100% rename from kernel-d-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/impl/SysMessageServiceImpl.java rename to kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/impl/SysMessageServiceImpl.java diff --git a/kernel-d-message/message-spring-boot-starter/README.md b/kernel-s-message/message-spring-boot-starter/README.md similarity index 100% rename from kernel-d-message/message-spring-boot-starter/README.md rename to kernel-s-message/message-spring-boot-starter/README.md diff --git a/kernel-d-message/message-spring-boot-starter/pom.xml b/kernel-s-message/message-spring-boot-starter/pom.xml similarity index 100% rename from kernel-d-message/message-spring-boot-starter/pom.xml rename to kernel-s-message/message-spring-boot-starter/pom.xml diff --git a/kernel-d-message/message-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/message/starter/GunsMessageAutoConfiguration.java b/kernel-s-message/message-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/message/starter/GunsMessageAutoConfiguration.java similarity index 100% rename from kernel-d-message/message-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/message/starter/GunsMessageAutoConfiguration.java rename to kernel-s-message/message-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/message/starter/GunsMessageAutoConfiguration.java diff --git a/kernel-d-message/message-spring-boot-starter/src/main/resources/META-INF/spring.factories b/kernel-s-message/message-spring-boot-starter/src/main/resources/META-INF/spring.factories similarity index 100% rename from kernel-d-message/message-spring-boot-starter/src/main/resources/META-INF/spring.factories rename to kernel-s-message/message-spring-boot-starter/src/main/resources/META-INF/spring.factories diff --git a/kernel-d-message/pom.xml b/kernel-s-message/pom.xml similarity index 95% rename from kernel-d-message/pom.xml rename to kernel-s-message/pom.xml index 9429be1b9..728ea6b52 100644 --- a/kernel-d-message/pom.xml +++ b/kernel-s-message/pom.xml @@ -11,7 +11,7 @@ ../pom.xml - kernel-d-message + kernel-s-message pom diff --git a/pom.xml b/pom.xml index a9d5a5486..1c04eed85 100644 --- a/pom.xml +++ b/pom.xml @@ -74,7 +74,7 @@ kernel-s-dict - kernel-d-message + kernel-s-message kernel-s-system From 6a9c28487fdc1f710d0d90bc8e496903805131c1 Mon Sep 17 00:00:00 2001 From: liuhanqing <447067298@qq.com> Date: Mon, 4 Jan 2021 23:24:39 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E3=80=90message=E3=80=91=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E6=B6=88=E6=81=AF=E6=A8=A1=E5=9D=97=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel-s-message/message-api/pom.xml | 2 +- .../roses/kernel/message/api/MessageApi.java | 11 ++- .../api/constants/MessageConstants.java | 2 +- .../api/enums/MessageReadFlagEnum.java | 33 ++++++++ .../kernel/message/api/pojo/MessageParam.java | 5 ++ .../message/api/pojo/MessageResponse.java | 5 ++ .../message/api/pojo/MessageSendParam.java | 5 ++ kernel-s-message/message-sdk-db/pom.xml | 8 +- .../message/db/MessageDbServiceImpl.java | 56 ++++++++++++- .../kernel/message/db/entity/SysMessage.java | 6 ++ .../message-spring-boot-starter/pom.xml | 2 +- .../roses/kernel/system/UserServiceApi.java | 35 ++++++++ .../kernel/system/pojo/user/SysUserDTO.java | 81 +++++++++++++++++++ .../pojo/user}/request/SysUserRequest.java | 2 +- .../user/controller/SysUserController.java | 2 +- .../user/factory/SysUserCreateFactory.java | 2 +- .../modular/user/mapper/SysUserMapper.java | 2 +- .../user/service/SysUserDataScopeService.java | 2 +- .../user/service/SysUserRoleService.java | 2 +- .../modular/user/service/SysUserService.java | 2 +- .../impl/SysUserDataScopeServiceImpl.java | 2 +- .../service/impl/SysUserRoleServiceImpl.java | 2 +- .../user/service/impl/SysUserServiceImpl.java | 56 ++++++++++++- 23 files changed, 308 insertions(+), 17 deletions(-) create mode 100644 kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageReadFlagEnum.java create mode 100644 kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/user/SysUserDTO.java rename kernel-s-system/{system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/pojo => system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/user}/request/SysUserRequest.java (98%) diff --git a/kernel-s-message/message-api/pom.xml b/kernel-s-message/message-api/pom.xml index 17ac09d84..33e993129 100644 --- a/kernel-s-message/message-api/pom.xml +++ b/kernel-s-message/message-api/pom.xml @@ -6,7 +6,7 @@ cn.stylefeng.roses - kernel-d-message + kernel-s-message 1.0.0 ../pom.xml diff --git a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/MessageApi.java b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/MessageApi.java index 3687e057f..449792c94 100644 --- a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/MessageApi.java +++ b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/MessageApi.java @@ -1,6 +1,7 @@ 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; @@ -36,6 +37,14 @@ public interface MessageApi { */ void updateReadFlag(MessageParam messageParam); + /** + * 批量更新阅读状态 + * + * @param messageIds 消息id字符串,多个用逗号分隔 + * @author liuhanqing + * @date 2021/1/4 21:21 + */ + void batchReadFlagByMessageIds(String messageIds, MessageReadFlagEnum flagEnum); /** * 删除系统消息 * @@ -52,7 +61,7 @@ public interface MessageApi { * @author liuhanqing * @date 2021/1/2 21:21 */ - void batchDeleteByMessageId(String messageIds); + void batchDeleteByMessageIds(String messageIds); /** * 查看系统消息 diff --git a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/constants/MessageConstants.java b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/constants/MessageConstants.java index c61294c5e..4957afc24 100644 --- a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/constants/MessageConstants.java +++ b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/constants/MessageConstants.java @@ -11,7 +11,7 @@ public interface MessageConstants { /** * 消息模块的名称 */ - String MESSAGE_MODULE_NAME = "kernel-d-message"; + String MESSAGE_MODULE_NAME = "kernel-s-message"; /** * 异常枚举的步进值 diff --git a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageReadFlagEnum.java b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageReadFlagEnum.java new file mode 100644 index 000000000..ef2d7c12a --- /dev/null +++ b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageReadFlagEnum.java @@ -0,0 +1,33 @@ +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; + } + +} diff --git a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageParam.java b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageParam.java index 60d62f4d1..11c0d93f9 100644 --- a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageParam.java +++ b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageParam.java @@ -48,6 +48,11 @@ public class MessageParam extends BaseRequest { */ private String messageType; + /** + * 消息优先级 + */ + private String priorityLevel; + /** * 消息发送时间 */ diff --git a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageResponse.java b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageResponse.java index 2d6c01f2d..795470203 100644 --- a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageResponse.java +++ b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageResponse.java @@ -39,6 +39,11 @@ public class MessageResponse implements Serializable { */ private String messageContent; + /** + * 消息优先级 + */ + private String priorityLevel; + /** * 消息类型 */ diff --git a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageSendParam.java b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageSendParam.java index a044b4320..36e5dd642 100644 --- a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageSendParam.java +++ b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageSendParam.java @@ -38,6 +38,11 @@ public class MessageSendParam extends BaseRequest { */ private String messageType; + /** + * 消息优先级 + */ + private String priorityLevel; + /** * 业务id */ diff --git a/kernel-s-message/message-sdk-db/pom.xml b/kernel-s-message/message-sdk-db/pom.xml index b12b29801..0b8c4ebf3 100644 --- a/kernel-s-message/message-sdk-db/pom.xml +++ b/kernel-s-message/message-sdk-db/pom.xml @@ -6,7 +6,7 @@ cn.stylefeng.roses - kernel-d-message + kernel-s-message 1.0.0 ../pom.xml @@ -30,6 +30,12 @@ db-sdk-mp 1.0.0 + + + cn.stylefeng.roses + system-api + 1.0.0 + diff --git a/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/MessageDbServiceImpl.java b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/MessageDbServiceImpl.java index 380e501fc..fd3dbbdd3 100644 --- a/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/MessageDbServiceImpl.java +++ b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/MessageDbServiceImpl.java @@ -1,15 +1,27 @@ package cn.stylefeng.roses.kernel.message.db; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.convert.Convert; +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.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.system.UserServiceApi; +import cn.stylefeng.roses.kernel.system.exception.SystemModularException; +import cn.stylefeng.roses.kernel.system.pojo.user.request.SysUserRequest; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import java.util.List; +import javax.annotation.Resource; +import java.util.*; /** * 系统消息,数据库实现 @@ -21,13 +33,48 @@ import java.util.List; @Service public class MessageDbServiceImpl implements MessageApi { + + @Resource + private UserServiceApi userServiceApi; + + @Resource + private SysMessageService sysMessageService; + @Override public void sendMessage(MessageSendParam messageSendParam) { String receiveUserIds = messageSendParam.getReceiveUserIds(); + // 获取当前登录人 + LoginUser loginUser = LoginContext.me().getLoginUser(); + List sendMsgList = new ArrayList<>(); + List userIds = new ArrayList<>(); // 发送所有人判断 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 SystemModularException(MessageExceptionEnum.ERROR_RECEIVE_USER_IDS, receiveUserIds); + } + + Set 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); } @@ -36,13 +83,18 @@ public class MessageDbServiceImpl implements MessageApi { } + @Override + public void batchReadFlagByMessageIds(String messageIds, MessageReadFlagEnum flagEnum) { + + } + @Override public void deleteByMessageId(Long messageId) { } @Override - public void batchDeleteByMessageId(String messageIds) { + public void batchDeleteByMessageIds(String messageIds) { } diff --git a/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/entity/SysMessage.java b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/entity/SysMessage.java index 0f39b4a9b..a4da591ae 100644 --- a/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/entity/SysMessage.java +++ b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/entity/SysMessage.java @@ -54,6 +54,12 @@ public class SysMessage extends BaseEntity { @TableField(value = "message_type") private String messageType; + /** + * 消息优先级 + */ + @TableField(value = "priority_level") + private String priorityLevel; + /** * 消息发送时间 */ diff --git a/kernel-s-message/message-spring-boot-starter/pom.xml b/kernel-s-message/message-spring-boot-starter/pom.xml index cf61944ed..8ac9a1d90 100644 --- a/kernel-s-message/message-spring-boot-starter/pom.xml +++ b/kernel-s-message/message-spring-boot-starter/pom.xml @@ -6,7 +6,7 @@ cn.stylefeng.roses - kernel-d-message + kernel-s-message 1.0.0 ../pom.xml diff --git a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/UserServiceApi.java b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/UserServiceApi.java index ea878834b..1ffdc89e8 100644 --- a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/UserServiceApi.java +++ b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/UserServiceApi.java @@ -1,6 +1,8 @@ package cn.stylefeng.roses.kernel.system; +import cn.stylefeng.roses.kernel.system.pojo.user.SysUserDTO; 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; @@ -73,4 +75,37 @@ public interface UserServiceApi { */ List getUserBindDataScope(Long userId); + /** + * 查询全部用户ID(剔除管理员,和不允许登录) + * + * @param sysUserRequest 查询参数 + * @return List 用户id 集合 + * @author liuhanqing + * @date 2021/1/4 22:09 + */ + List 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); + } diff --git a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/user/SysUserDTO.java b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/user/SysUserDTO.java new file mode 100644 index 000000000..33e04cc77 --- /dev/null +++ b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/user/SysUserDTO.java @@ -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; + +} diff --git a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/pojo/request/SysUserRequest.java b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/user/request/SysUserRequest.java similarity index 98% rename from kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/pojo/request/SysUserRequest.java rename to kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/user/request/SysUserRequest.java index c347ed54e..a2a5e885d 100644 --- a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/pojo/request/SysUserRequest.java +++ b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/user/request/SysUserRequest.java @@ -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; diff --git a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/controller/SysUserController.java b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/controller/SysUserController.java index e6c55e5c5..763c34fa4 100644 --- a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/controller/SysUserController.java +++ b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/controller/SysUserController.java @@ -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; diff --git a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/factory/SysUserCreateFactory.java b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/factory/SysUserCreateFactory.java index 068a5e12f..998782767 100644 --- a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/factory/SysUserCreateFactory.java +++ b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/factory/SysUserCreateFactory.java @@ -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; /** * 用户信息填充,用于创建和修改用户时,添加一些基础信息 diff --git a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/mapper/SysUserMapper.java b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/mapper/SysUserMapper.java index b963fb854..af9e93af2 100644 --- a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/mapper/SysUserMapper.java +++ b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/mapper/SysUserMapper.java @@ -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; diff --git a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/SysUserDataScopeService.java b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/SysUserDataScopeService.java index 9080566f2..d8d94ce20 100644 --- a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/SysUserDataScopeService.java +++ b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/SysUserDataScopeService.java @@ -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; diff --git a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/SysUserRoleService.java b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/SysUserRoleService.java index 3a6635dde..c0f2552cc 100644 --- a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/SysUserRoleService.java +++ b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/SysUserRoleService.java @@ -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; diff --git a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/SysUserService.java b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/SysUserService.java index f3495d7d3..d4fd6c569 100644 --- a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/SysUserService.java +++ b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/SysUserService.java @@ -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; diff --git a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserDataScopeServiceImpl.java b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserDataScopeServiceImpl.java index 5c544c363..f62493b0d 100644 --- a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserDataScopeServiceImpl.java +++ b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserDataScopeServiceImpl.java @@ -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; diff --git a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserRoleServiceImpl.java b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserRoleServiceImpl.java index e4c025cdf..25e8bbc00 100644 --- a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserRoleServiceImpl.java +++ b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserRoleServiceImpl.java @@ -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; diff --git a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserServiceImpl.java b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserServiceImpl.java index 4947dbb39..f471bf8fe 100644 --- a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserServiceImpl.java +++ b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserServiceImpl.java @@ -26,7 +26,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; @@ -52,6 +53,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; /** @@ -451,6 +453,58 @@ public class SysUserServiceImpl extends ServiceImpl impl return sysUserDataScopeService.getUserDataScopeIdList(userId); } + + @Override + public List queryAllUserIdList(SysUserRequest sysUserRequest) { + + LambdaQueryWrapper wrapper = createWrapper(sysUserRequest); + + // 排除超级管理员 + wrapper.ne(SysUser::getSuperAdminFlag, YesOrNotEnum.Y.getCode()); + + // 只查询id + wrapper.select(SysUser::getUserId); + // 查询全部用户ID + Function mapper = id -> Long.valueOf(id.toString()); + List 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 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; + } + /** * 获取系统用户 * From 3cedc75acbe96abac6e615c5183c0932b3331836 Mon Sep 17 00:00:00 2001 From: liuhanqing <447067298@qq.com> Date: Thu, 7 Jan 2021 20:48:32 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E3=80=90message=E3=80=91=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel-s-system/_sql/system.sql | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/kernel-s-system/_sql/system.sql b/kernel-s-system/_sql/system.sql index 85f481ba8..d49693ac7 100644 --- a/kernel-s-system/_sql/system.sql +++ b/kernel-s-system/_sql/system.sql @@ -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', @@ -820,4 +820,28 @@ 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; + SET FOREIGN_KEY_CHECKS = 1; From c48f973e6b663babaaea8a9ad74fab404f9c9207 Mon Sep 17 00:00:00 2001 From: hansson <447067298@qq.com> Date: Fri, 8 Jan 2021 14:25:11 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E3=80=90message=E3=80=91=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E6=B6=88=E6=81=AF=E5=90=8E=E5=8F=B0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../log/starter/GunsLogAutoConfiguration.java | 2 +- .../roses/kernel/message/api/MessageApi.java | 34 ++++++- .../api/enums/MessageProrityLevelEnum.java | 50 ++++++++++ .../api/enums/MessageReadFlagEnum.java | 16 +++- .../kernel/message/api/pojo/MessageParam.java | 3 +- .../controller/SysMessageController.java | 78 +++++++++++++++ .../message/db/MessageDbServiceImpl.java | 96 +++++++++++++++++-- .../message/db/service/SysMessageService.java | 20 ++++ .../service/impl/SysMessageServiceImpl.java | 62 ++++++++++++ 9 files changed, 345 insertions(+), 16 deletions(-) create mode 100644 kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageProrityLevelEnum.java diff --git a/kernel-d-log/log-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/log/starter/GunsLogAutoConfiguration.java b/kernel-d-log/log-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/log/starter/GunsLogAutoConfiguration.java index 8a08c5d1c..d8263abaa 100644 --- a/kernel-d-log/log-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/log/starter/GunsLogAutoConfiguration.java +++ b/kernel-d-log/log-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/log/starter/GunsLogAutoConfiguration.java @@ -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(); diff --git a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/MessageApi.java b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/MessageApi.java index 449792c94..19d57848e 100644 --- a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/MessageApi.java +++ b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/MessageApi.java @@ -37,6 +37,14 @@ public interface MessageApi { */ void updateReadFlag(MessageParam messageParam); + /** + * 全部更新阅读状态 + * + * @author liuhanqing + * @date 2021/1/2 22:15 + */ + void allMessageReadFlag(); + /** * 批量更新阅读状态 * @@ -74,14 +82,14 @@ public interface MessageApi { MessageResponse messageDetail(MessageParam messageParam); /** - * 查询系统消息 + * 查询分页系统消息 * * @param messageParam 查询参数 * @return 查询分页结果 * @author liuhanqing * @date 2021/1/2 21:21 */ - PageResult queryMessagePage(MessageParam messageParam); + PageResult queryPage(MessageParam messageParam); /** * 查询系统消息 @@ -91,6 +99,26 @@ public interface MessageApi { * @author liuhanqing * @date 2021/1/2 21:21 */ - List queryMessageList(MessageParam messageParam); + List queryList(MessageParam messageParam); + + /** + * 查询分页系统消息 当前登录用户 + * + * @param messageParam 查询参数 + * @return 查询分页结果 + * @author liuhanqing + * @date 2021/1/2 21:21 + */ + PageResult queryPageCurrentUser(MessageParam messageParam); + + /** + * 查询系统消息 当前登录用户 + * + * @param messageParam 查询参数 + * @return 系统消息列表 + * @author liuhanqing + * @date 2021/1/2 21:21 + */ + List queryListCurrentUser(MessageParam messageParam); } \ No newline at end of file diff --git a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageProrityLevelEnum.java b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageProrityLevelEnum.java new file mode 100644 index 000000000..496bcda88 --- /dev/null +++ b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageProrityLevelEnum.java @@ -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 String code; + + private 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; + } + +} diff --git a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageReadFlagEnum.java b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageReadFlagEnum.java index ef2d7c12a..2dde36dd8 100644 --- a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageReadFlagEnum.java +++ b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageReadFlagEnum.java @@ -21,13 +21,25 @@ public enum MessageReadFlagEnum { */ READ(1, "已读"); - private final Integer code; + private Integer code; - private final String name; + private 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; + } + } diff --git a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageParam.java b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageParam.java index 11c0d93f9..0c38416d2 100644 --- a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageParam.java +++ b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageParam.java @@ -20,7 +20,7 @@ public class MessageParam extends BaseRequest { /** * 消息id */ - @NotNull(message = "messageId不能为空", groups = {edit.class, delete.class, detail.class}) + @NotNull(message = "messageId不能为空", groups = {edit.class, delete.class, detail.class, updateStatus.class}) private Long messageId; /** @@ -71,6 +71,7 @@ public class MessageParam extends BaseRequest { /** * 阅读状态:0-未读,1-已读 */ + @NotNull(message = "阅读状态不能为空", groups = {updateStatus.class}) private Integer readFlag; } diff --git a/kernel-s-message/message-business/src/main/java/cn/stylefeng/roses/kernel/message/modular/manage/controller/SysMessageController.java b/kernel-s-message/message-business/src/main/java/cn/stylefeng/roses/kernel/message/modular/manage/controller/SysMessageController.java index 5e7a511ee..13adb1e07 100644 --- a/kernel-s-message/message-business/src/main/java/cn/stylefeng/roses/kernel/message/modular/manage/controller/SysMessageController.java +++ b/kernel-s-message/message-business/src/main/java/cn/stylefeng/roses/kernel/message/modular/manage/controller/SysMessageController.java @@ -1,8 +1,16 @@ package cn.stylefeng.roses.kernel.message.modular.manage.controller; import cn.stylefeng.roses.kernel.message.api.MessageApi; +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; /** @@ -21,5 +29,75 @@ public class SysMessageController { @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 + */ + @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)); + } } diff --git a/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/MessageDbServiceImpl.java b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/MessageDbServiceImpl.java index fd3dbbdd3..3a1e2df31 100644 --- a/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/MessageDbServiceImpl.java +++ b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/MessageDbServiceImpl.java @@ -2,6 +2,7 @@ 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; @@ -14,11 +15,14 @@ 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.exception.SystemModularException; 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.*; @@ -41,12 +45,13 @@ public class MessageDbServiceImpl implements MessageApi { private SysMessageService sysMessageService; @Override + @Transactional(rollbackFor = Exception.class) public void sendMessage(MessageSendParam messageSendParam) { String receiveUserIds = messageSendParam.getReceiveUserIds(); // 获取当前登录人 LoginUser loginUser = LoginContext.me().getLoginUser(); List sendMsgList = new ArrayList<>(); - List userIds = new ArrayList<>(); + List userIds; // 发送所有人判断 if (MessageConstants.RECEIVE_ALL_USER_FLAG.equals(receiveUserIds)) { // 查询所有用户 @@ -69,7 +74,7 @@ public class MessageDbServiceImpl implements MessageApi { sysMessage.setMessageSendTime(new Date()); userIdSet.forEach(userId -> { // 判断用户是否存在 - if(userServiceApi.userExist(userId)){ + if (userServiceApi.userExist(userId)) { sysMessage.setReceiveUserId(userId); sendMsgList.add(sysMessage); } @@ -79,37 +84,110 @@ public class MessageDbServiceImpl implements MessageApi { } @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 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 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 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 updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.inSql(SysMessage::getMessageId, messageIds) + .set(SysMessage::getDelFlag, YesOrNotEnum.Y.getCode()); + sysMessageService.update(updateWrapper); } @Override public MessageResponse messageDetail(MessageParam messageParam) { - return null; + 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 queryMessagePage(MessageParam messageParam) { - return null; + public PageResult queryPage(MessageParam messageParam) { + PageResult pageResult = sysMessageService.page(messageParam); + PageResult result = new PageResult<>(); + BeanUtil.copyProperties(pageResult, result); + return result; } @Override - public List queryMessageList(MessageParam messageParam) { - return null; + public List queryList(MessageParam messageParam) { + List messageList = sysMessageService.list(messageParam); + List resultList = new ArrayList<>(); + BeanUtil.copyProperties(messageList, resultList); + return resultList; + } + + @Override + public PageResult 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 queryListCurrentUser(MessageParam messageParam) { + if (ObjectUtil.isEmpty(messageParam)) { + messageParam = new MessageParam(); + } + // 获取当前登录人 + LoginUser loginUser = LoginContext.me().getLoginUser(); + messageParam.setReceiveUserId(loginUser.getUserId()); + return this.queryList(messageParam); } } diff --git a/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/SysMessageService.java b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/SysMessageService.java index 77ffa6f8f..3319e77cb 100644 --- a/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/SysMessageService.java +++ b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/SysMessageService.java @@ -1,8 +1,12 @@ 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接口 * @@ -10,5 +14,21 @@ import com.baomidou.mybatisplus.extension.service.IService; * @date 2020/12/31 20:09 */ public interface SysMessageService extends IService { + /** + * 分页查询 + * + * @param messageParam 参数 + * @author liuhanqing + * @date 2021/1/2 15:21 + */ + PageResult page(MessageParam messageParam); + /** + * 列表查询 + * + * @param messageParam 参数 + * @author liuhanqing + * @date 2021/1/8 15:21 + */ + List list(MessageParam messageParam); } diff --git a/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/impl/SysMessageServiceImpl.java b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/impl/SysMessageServiceImpl.java index 6b4520cd4..a77299cf7 100644 --- a/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/impl/SysMessageServiceImpl.java +++ b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/impl/SysMessageServiceImpl.java @@ -1,11 +1,21 @@ 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接口实现类 * @@ -15,4 +25,56 @@ import org.springframework.stereotype.Service; @Service public class SysMessageServiceImpl extends ServiceImpl implements SysMessageService { + + @Override + public PageResult page(MessageParam messageParam) { + LambdaQueryWrapper wrapper = createWrapper(messageParam); + Page page = this.page(PageFactory.defaultPage(), wrapper); + return PageResultFactory.createPageResult(page); + } + + @Override + public List list(MessageParam messageParam) { + LambdaQueryWrapper wrapper = createWrapper(messageParam); + return this.list(wrapper); + } + /** + * 创建wrapper + * + * @author liuhanqing + * @date 2021/1/8 14:16 + */ + private LambdaQueryWrapper createWrapper(MessageParam messageParam) { + LambdaQueryWrapper 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; + } } From e19a0d582cdee6d13482848002ff17ac61cd4d2b Mon Sep 17 00:00:00 2001 From: hansson <447067298@qq.com> Date: Fri, 8 Jan 2021 15:04:55 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E3=80=90message=E3=80=91=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=89=B9=E9=87=8F=E6=9B=B4=E6=96=B0=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kernel/message/api/pojo/MessageParam.java | 15 +++++++++++++++ .../controller/SysMessageController.java | 19 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageParam.java b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageParam.java index 0c38416d2..65512251f 100644 --- a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageParam.java +++ b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageParam.java @@ -4,8 +4,10 @@ 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; /** * 系统消息的查询参数 @@ -74,4 +76,17 @@ public class MessageParam extends BaseRequest { @NotNull(message = "阅读状态不能为空", groups = {updateStatus.class}) private Integer readFlag; + /** + * 消息id集合 + */ + @NotEmpty(message = "消息id集合不能为空,请检查messageIdList参数", groups = {updateReadFlag.class}) + private List messageIdList; + + + /** + * 参数校验分组:修改阅读状态 + */ + public @interface updateReadFlag { + } + } diff --git a/kernel-s-message/message-business/src/main/java/cn/stylefeng/roses/kernel/message/modular/manage/controller/SysMessageController.java b/kernel-s-message/message-business/src/main/java/cn/stylefeng/roses/kernel/message/modular/manage/controller/SysMessageController.java index 13adb1e07..259b667a1 100644 --- a/kernel-s-message/message-business/src/main/java/cn/stylefeng/roses/kernel/message/modular/manage/controller/SysMessageController.java +++ b/kernel-s-message/message-business/src/main/java/cn/stylefeng/roses/kernel/message/modular/manage/controller/SysMessageController.java @@ -1,11 +1,14 @@ 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.request.BaseRequest; 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; @@ -13,6 +16,9 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; +import java.util.List; +import java.util.Optional; + /** * 系统消息控制器 * @@ -41,6 +47,19 @@ public class SysMessageController { return new SuccessResponseData(); } + /** + * 批量更新系统消息状态 + * + * @author liuhanqing + * @date 2021/1/8 13:50 + */ + @PostResource(name = "批量更新系统消息状态", path = "/sysMessage/batchUpdateReadFlag") + public ResponseData sendMessage(@RequestBody @Validated(MessageParam.updateReadFlag.class) MessageParam messageParam) { + List messageIdList = messageParam.getMessageIdList(); + messageApi.batchReadFlagByMessageIds(StrUtil.join(",", messageIdList), MessageReadFlagEnum.READ); + return new SuccessResponseData(); + } + /** * 系统消息全部修改已读 * From 17fedc40f3bb15c8dac3edd156293b43f4177f40 Mon Sep 17 00:00:00 2001 From: liuhanqing <447067298@qq.com> Date: Fri, 8 Jan 2021 19:37:43 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E3=80=90message=E3=80=91=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E6=B6=88=E6=81=AF=E6=8E=A5=E5=8F=A3=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/enums/MessageBusinessTypeEnum.java | 40 +++++++++++++++++++ .../message/api/pojo/MessageSendParam.java | 3 +- .../controller/SysMessageController.java | 4 +- .../message/db/MessageDbServiceImpl.java | 2 +- .../kernel/message/db/entity/SysMessage.java | 4 +- .../message-spring-boot-starter/pom.xml | 6 +-- .../user/service/impl/SysUserServiceImpl.java | 2 +- 7 files changed, 50 insertions(+), 11 deletions(-) create mode 100644 kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageBusinessTypeEnum.java diff --git a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageBusinessTypeEnum.java b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageBusinessTypeEnum.java new file mode 100644 index 000000000..198c5340c --- /dev/null +++ b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageBusinessTypeEnum.java @@ -0,0 +1,40 @@ +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", "系统通知"); + + private String code; + + private String name; + + MessageBusinessTypeEnum(String code, String name) { + this.code = code; + this.name = name; + } + + public static String getName(String code) { + if (code == null) { + return null; + } + for (MessageBusinessTypeEnum flagEnum : MessageBusinessTypeEnum.values()) { + if (flagEnum.getCode().equals(code)) { + return flagEnum.name; + } + } + return null; + } + +} diff --git a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageSendParam.java b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageSendParam.java index 36e5dd642..77f971280 100644 --- a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageSendParam.java +++ b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/pojo/MessageSendParam.java @@ -5,6 +5,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; /** * 发送系统消息的参数 @@ -46,7 +47,7 @@ public class MessageSendParam extends BaseRequest { /** * 业务id */ - @NotBlank(message = "业务id不能为空", groups = {add.class, edit.class}) + @NotNull(message = "业务id不能为空", groups = {add.class, edit.class}) private Long businessId; /** diff --git a/kernel-s-message/message-business/src/main/java/cn/stylefeng/roses/kernel/message/modular/manage/controller/SysMessageController.java b/kernel-s-message/message-business/src/main/java/cn/stylefeng/roses/kernel/message/modular/manage/controller/SysMessageController.java index 259b667a1..8e2d78ce8 100644 --- a/kernel-s-message/message-business/src/main/java/cn/stylefeng/roses/kernel/message/modular/manage/controller/SysMessageController.java +++ b/kernel-s-message/message-business/src/main/java/cn/stylefeng/roses/kernel/message/modular/manage/controller/SysMessageController.java @@ -8,7 +8,6 @@ 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.request.BaseRequest; 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; @@ -17,7 +16,6 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import java.util.List; -import java.util.Optional; /** * 系统消息控制器 @@ -54,7 +52,7 @@ public class SysMessageController { * @date 2021/1/8 13:50 */ @PostResource(name = "批量更新系统消息状态", path = "/sysMessage/batchUpdateReadFlag") - public ResponseData sendMessage(@RequestBody @Validated(MessageParam.updateReadFlag.class) MessageParam messageParam) { + public ResponseData batchUpdateReadFlag(@RequestBody @Validated(MessageParam.updateReadFlag.class) MessageParam messageParam) { List messageIdList = messageParam.getMessageIdList(); messageApi.batchReadFlagByMessageIds(StrUtil.join(",", messageIdList), MessageReadFlagEnum.READ); return new SuccessResponseData(); diff --git a/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/MessageDbServiceImpl.java b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/MessageDbServiceImpl.java index 3a1e2df31..d5b412532 100644 --- a/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/MessageDbServiceImpl.java +++ b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/MessageDbServiceImpl.java @@ -62,7 +62,7 @@ public class MessageDbServiceImpl implements MessageApi { userIds = Convert.toList(Long.class, userIdArr); } if (userIds == null || userIds.isEmpty()) { - throw new SystemModularException(MessageExceptionEnum.ERROR_RECEIVE_USER_IDS, receiveUserIds); + throw new SystemModularException(MessageExceptionEnum.ERROR_RECEIVE_USER_IDS, "传入接收用户id字符串不合法:" + receiveUserIds); } Set userIdSet = new HashSet<>(userIds); diff --git a/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/entity/SysMessage.java b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/entity/SysMessage.java index a4da591ae..1a8d4d5fe 100644 --- a/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/entity/SysMessage.java +++ b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/entity/SysMessage.java @@ -27,13 +27,13 @@ public class SysMessage extends BaseEntity { /** * 接收用户id */ - @TableId(value = "receive_user_id") + @TableField(value = "receive_user_id") private Long receiveUserId; /** * 发送用户id */ - @TableId(value = "send_user_id") + @TableField(value = "send_user_id") private Long sendUserId; /** diff --git a/kernel-s-message/message-spring-boot-starter/pom.xml b/kernel-s-message/message-spring-boot-starter/pom.xml index 8ac9a1d90..4f3ad1332 100644 --- a/kernel-s-message/message-spring-boot-starter/pom.xml +++ b/kernel-s-message/message-spring-boot-starter/pom.xml @@ -18,11 +18,11 @@ - + diff --git a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserServiceImpl.java b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserServiceImpl.java index 8e2afff8d..c94f9da6b 100644 --- a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserServiceImpl.java +++ b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/service/impl/SysUserServiceImpl.java @@ -469,7 +469,7 @@ public class SysUserServiceImpl extends ServiceImpl impl LambdaQueryWrapper wrapper = createWrapper(sysUserRequest); // 排除超级管理员 - wrapper.ne(SysUser::getSuperAdminFlag, YesOrNotEnum.Y.getCode()); +// wrapper.ne(SysUser::getSuperAdminFlag, YesOrNotEnum.Y.getCode()); // 只查询id wrapper.select(SysUser::getUserId); From 1056a418262d499f07eb04a148ac4dd1f53d3682 Mon Sep 17 00:00:00 2001 From: liuhanqing <447067298@qq.com> Date: Fri, 8 Jan 2021 21:12:33 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E3=80=90message=E3=80=91=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E6=B6=88=E6=81=AF=E6=8E=A5=E5=8F=A3=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/enums/MessageBusinessTypeEnum.java | 18 +++++++++++------- .../api/enums/MessageProrityLevelEnum.java | 4 ++-- .../message/api/enums/MessageReadFlagEnum.java | 4 ++-- .../message/db/MessageDbServiceImpl.java | 12 ++++++++---- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageBusinessTypeEnum.java b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageBusinessTypeEnum.java index 198c5340c..44107700e 100644 --- a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageBusinessTypeEnum.java +++ b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageBusinessTypeEnum.java @@ -3,7 +3,7 @@ package cn.stylefeng.roses.kernel.message.api.enums; import lombok.Getter; /** - * 消息阅读状态 + * 消息业务类型枚举 * * @author liuhanqing * @date 2021/1/4 22:26 @@ -14,24 +14,28 @@ public enum MessageBusinessTypeEnum { /** * 已读 */ - SYS_NOTICE("sys_notice", "系统通知"); + SYS_NOTICE("sys_notice", "系统通知", "/sysNotice/detail"); - private String code; + private final String code; - private String name; + private final String name; - MessageBusinessTypeEnum(String code, String name) { + private final String url; + + + MessageBusinessTypeEnum(String code, String name, String url) { this.code = code; this.name = name; + this.url = url; } - public static String getName(String code) { + public static MessageBusinessTypeEnum getByCode(String code) { if (code == null) { return null; } for (MessageBusinessTypeEnum flagEnum : MessageBusinessTypeEnum.values()) { if (flagEnum.getCode().equals(code)) { - return flagEnum.name; + return flagEnum; } } return null; diff --git a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageProrityLevelEnum.java b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageProrityLevelEnum.java index 496bcda88..e25f0b0c3 100644 --- a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageProrityLevelEnum.java +++ b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageProrityLevelEnum.java @@ -26,9 +26,9 @@ public enum MessageProrityLevelEnum { */ LOW("low", "低"); - private String code; + private final String code; - private String name; + private final String name; MessageProrityLevelEnum(String code, String name) { this.code = code; diff --git a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageReadFlagEnum.java b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageReadFlagEnum.java index 2dde36dd8..1c5f988cd 100644 --- a/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageReadFlagEnum.java +++ b/kernel-s-message/message-api/src/main/java/cn/stylefeng/roses/kernel/message/api/enums/MessageReadFlagEnum.java @@ -21,9 +21,9 @@ public enum MessageReadFlagEnum { */ READ(1, "已读"); - private Integer code; + private final Integer code; - private String name; + private final String name; MessageReadFlagEnum(Integer code, String name) { this.code = code; diff --git a/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/MessageDbServiceImpl.java b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/MessageDbServiceImpl.java index d5b412532..b844904a2 100644 --- a/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/MessageDbServiceImpl.java +++ b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/MessageDbServiceImpl.java @@ -9,6 +9,7 @@ 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; @@ -17,7 +18,6 @@ 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.exception.SystemModularException; import cn.stylefeng.roses.kernel.system.pojo.user.request.SysUserRequest; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import lombok.extern.slf4j.Slf4j; @@ -26,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.*; +import java.util.stream.Collectors; /** * 系统消息,数据库实现 @@ -62,7 +63,7 @@ public class MessageDbServiceImpl implements MessageApi { userIds = Convert.toList(Long.class, userIdArr); } if (userIds == null || userIds.isEmpty()) { - throw new SystemModularException(MessageExceptionEnum.ERROR_RECEIVE_USER_IDS, "传入接收用户id字符串不合法:" + receiveUserIds); + throw new MessageException(MessageExceptionEnum.ERROR_RECEIVE_USER_IDS); } Set userIdSet = new HashSet<>(userIds); @@ -164,8 +165,11 @@ public class MessageDbServiceImpl implements MessageApi { @Override public List queryList(MessageParam messageParam) { List messageList = sysMessageService.list(messageParam); - List resultList = new ArrayList<>(); - BeanUtil.copyProperties(messageList, resultList); + List resultList = messageList.stream().map(msg -> { + MessageResponse response = new MessageResponse(); + BeanUtil.copyProperties(msg, response); + return response; + }).collect(Collectors.toList()); return resultList; } From 0addfa1138ce83834aa0cae25e4c37b7f8acfb0e Mon Sep 17 00:00:00 2001 From: liuhanqing <447067298@qq.com> Date: Sat, 9 Jan 2021 17:35:28 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E3=80=90notice=E3=80=91=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E7=AE=A1=E7=90=86=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel-s-system/pom.xml | 1 + kernel-s-system/system-api/pom.xml | 4 + .../roses/kernel/system/NoticeServiceApi.java | 12 ++ .../exception/enums/NoticeExceptionEnum.java | 65 +++++++ .../system/pojo/notice/SysNoticeRequest.java | 71 ++++++++ .../system-business-notice/README.md | 1 + .../system-business-notice/pom.xml | 65 +++++++ .../modular/controller/NoticeController.java | 98 ++++++++++ .../notice/modular/entity/SysNotice.java | 80 +++++++++ .../modular/mapper/SysNoticeMapper.java | 14 ++ .../mapper/mapping/SysNoticeMapper.xml | 5 + .../modular/service/SysNoticeService.java | 78 ++++++++ .../service/impl/SysNoticeServiceImpl.java | 167 ++++++++++++++++++ .../system-spring-boot-starter/pom.xml | 7 + 14 files changed, 668 insertions(+) create mode 100644 kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/NoticeServiceApi.java create mode 100644 kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/exception/enums/NoticeExceptionEnum.java create mode 100644 kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/notice/SysNoticeRequest.java create mode 100644 kernel-s-system/system-business-notice/README.md create mode 100644 kernel-s-system/system-business-notice/pom.xml create mode 100644 kernel-s-system/system-business-notice/src/main/java/cn/stylefeng/roses/kernel/notice/modular/controller/NoticeController.java create mode 100644 kernel-s-system/system-business-notice/src/main/java/cn/stylefeng/roses/kernel/notice/modular/entity/SysNotice.java create mode 100644 kernel-s-system/system-business-notice/src/main/java/cn/stylefeng/roses/kernel/notice/modular/mapper/SysNoticeMapper.java create mode 100644 kernel-s-system/system-business-notice/src/main/java/cn/stylefeng/roses/kernel/notice/modular/mapper/mapping/SysNoticeMapper.xml create mode 100644 kernel-s-system/system-business-notice/src/main/java/cn/stylefeng/roses/kernel/notice/modular/service/SysNoticeService.java create mode 100644 kernel-s-system/system-business-notice/src/main/java/cn/stylefeng/roses/kernel/notice/modular/service/impl/SysNoticeServiceImpl.java diff --git a/kernel-s-system/pom.xml b/kernel-s-system/pom.xml index d47291dbc..9445f242e 100644 --- a/kernel-s-system/pom.xml +++ b/kernel-s-system/pom.xml @@ -23,6 +23,7 @@ system-business-user system-business-role system-business-menu + system-business-notice system-spring-boot-starter diff --git a/kernel-s-system/system-api/pom.xml b/kernel-s-system/system-api/pom.xml index 33a288f60..cedd8e5d4 100644 --- a/kernel-s-system/system-api/pom.xml +++ b/kernel-s-system/system-api/pom.xml @@ -58,6 +58,10 @@ spring-web provided + + com.fasterxml.jackson.core + jackson-annotations + diff --git a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/NoticeServiceApi.java b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/NoticeServiceApi.java new file mode 100644 index 000000000..ee1c4152a --- /dev/null +++ b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/NoticeServiceApi.java @@ -0,0 +1,12 @@ +package cn.stylefeng.roses.kernel.system; + +/** + * 通知api + * + * @author liuhanqing + * @date 2021/1/8 21:40 + */ +public interface NoticeServiceApi { + + +} diff --git a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/exception/enums/NoticeExceptionEnum.java b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/exception/enums/NoticeExceptionEnum.java new file mode 100644 index 000000000..ba676b901 --- /dev/null +++ b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/exception/enums/NoticeExceptionEnum.java @@ -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; + } + +} diff --git a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/notice/SysNoticeRequest.java b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/notice/SysNoticeRequest.java new file mode 100644 index 000000000..9c49ac063 --- /dev/null +++ b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/pojo/notice/SysNoticeRequest.java @@ -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; + +} diff --git a/kernel-s-system/system-business-notice/README.md b/kernel-s-system/system-business-notice/README.md new file mode 100644 index 000000000..fbfca6830 --- /dev/null +++ b/kernel-s-system/system-business-notice/README.md @@ -0,0 +1 @@ +通知模块 \ No newline at end of file diff --git a/kernel-s-system/system-business-notice/pom.xml b/kernel-s-system/system-business-notice/pom.xml new file mode 100644 index 000000000..ac0f09390 --- /dev/null +++ b/kernel-s-system/system-business-notice/pom.xml @@ -0,0 +1,65 @@ + + + 4.0.0 + + + cn.stylefeng.roses + kernel-s-system + 1.0.0 + ../pom.xml + + + system-business-notice + + jar + + + + + + cn.stylefeng.roses + system-api + 1.0.0 + + + + + + cn.stylefeng.roses + scanner-api + 1.0.0 + + + + + + cn.stylefeng.roses + validator-api + 1.0.0 + + + + + + cn.stylefeng.roses + db-sdk-mp + 1.0.0 + + + + + org.springframework.boot + spring-boot-starter-web + + + cn.stylefeng.roses + message-api + 1.0.0 + compile + + + + + diff --git a/kernel-s-system/system-business-notice/src/main/java/cn/stylefeng/roses/kernel/notice/modular/controller/NoticeController.java b/kernel-s-system/system-business-notice/src/main/java/cn/stylefeng/roses/kernel/notice/modular/controller/NoticeController.java new file mode 100644 index 000000000..15ea384f0 --- /dev/null +++ b/kernel-s-system/system-business-notice/src/main/java/cn/stylefeng/roses/kernel/notice/modular/controller/NoticeController.java @@ -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)); + } +} \ No newline at end of file diff --git a/kernel-s-system/system-business-notice/src/main/java/cn/stylefeng/roses/kernel/notice/modular/entity/SysNotice.java b/kernel-s-system/system-business-notice/src/main/java/cn/stylefeng/roses/kernel/notice/modular/entity/SysNotice.java new file mode 100644 index 000000000..f8a157b40 --- /dev/null +++ b/kernel-s-system/system-business-notice/src/main/java/cn/stylefeng/roses/kernel/notice/modular/entity/SysNotice.java @@ -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; + + +} diff --git a/kernel-s-system/system-business-notice/src/main/java/cn/stylefeng/roses/kernel/notice/modular/mapper/SysNoticeMapper.java b/kernel-s-system/system-business-notice/src/main/java/cn/stylefeng/roses/kernel/notice/modular/mapper/SysNoticeMapper.java new file mode 100644 index 000000000..cb5e4f7ad --- /dev/null +++ b/kernel-s-system/system-business-notice/src/main/java/cn/stylefeng/roses/kernel/notice/modular/mapper/SysNoticeMapper.java @@ -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 { + +} \ No newline at end of file diff --git a/kernel-s-system/system-business-notice/src/main/java/cn/stylefeng/roses/kernel/notice/modular/mapper/mapping/SysNoticeMapper.xml b/kernel-s-system/system-business-notice/src/main/java/cn/stylefeng/roses/kernel/notice/modular/mapper/mapping/SysNoticeMapper.xml new file mode 100644 index 000000000..5173b12ca --- /dev/null +++ b/kernel-s-system/system-business-notice/src/main/java/cn/stylefeng/roses/kernel/notice/modular/mapper/mapping/SysNoticeMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/kernel-s-system/system-business-notice/src/main/java/cn/stylefeng/roses/kernel/notice/modular/service/SysNoticeService.java b/kernel-s-system/system-business-notice/src/main/java/cn/stylefeng/roses/kernel/notice/modular/service/SysNoticeService.java new file mode 100644 index 000000000..5e6cc2b08 --- /dev/null +++ b/kernel-s-system/system-business-notice/src/main/java/cn/stylefeng/roses/kernel/notice/modular/service/SysNoticeService.java @@ -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, 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 page(SysNoticeRequest SysNoticeParam); + + /** + * 系统应用列表 + * + * @param SysNoticeParam 查询参数 + * @return 系统应用列表 + * @author liuhanqing + * @date 2021/1/9 14:56 + */ + List list(SysNoticeRequest SysNoticeParam); + + +} \ No newline at end of file diff --git a/kernel-s-system/system-business-notice/src/main/java/cn/stylefeng/roses/kernel/notice/modular/service/impl/SysNoticeServiceImpl.java b/kernel-s-system/system-business-notice/src/main/java/cn/stylefeng/roses/kernel/notice/modular/service/impl/SysNoticeServiceImpl.java new file mode 100644 index 000000000..5c130d442 --- /dev/null +++ b/kernel-s-system/system-business-notice/src/main/java/cn/stylefeng/roses/kernel/notice/modular/service/impl/SysNoticeServiceImpl.java @@ -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 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 page(SysNoticeRequest sysNoticeRequest) { + LambdaQueryWrapper wrapper = createWrapper(sysNoticeRequest); + Page page = this.page(PageFactory.defaultPage(), wrapper); + return PageResultFactory.createPageResult(page); + } + + @Override + public List list(SysNoticeRequest sysNoticeRequest) { + LambdaQueryWrapper 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 createWrapper(SysNoticeRequest sysNoticeRequest) { + LambdaQueryWrapper 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; + } + +} \ No newline at end of file diff --git a/kernel-s-system/system-spring-boot-starter/pom.xml b/kernel-s-system/system-spring-boot-starter/pom.xml index 6e2cd0128..12dddae75 100644 --- a/kernel-s-system/system-spring-boot-starter/pom.xml +++ b/kernel-s-system/system-spring-boot-starter/pom.xml @@ -59,6 +59,13 @@ 1.0.0 + + + cn.stylefeng.roses + system-business-notice + 1.0.0 + + From 95d3765359b1dedda1ccccc4ff7835833ded08f2 Mon Sep 17 00:00:00 2001 From: liuhanqing <447067298@qq.com> Date: Sun, 10 Jan 2021 11:58:36 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E3=80=90message=E3=80=91=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E7=AE=A1=E7=90=86=E6=95=B0=E6=8D=AE=E5=BA=93=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel-s-system/_sql/system.sql | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/kernel-s-system/_sql/system.sql b/kernel-s-system/_sql/system.sql index c455f4ebe..023c7710e 100644 --- a/kernel-s-system/_sql/system.sql +++ b/kernel-s-system/_sql/system.sql @@ -865,4 +865,26 @@ CREATE TABLE `sys_message` ( 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;