mirror of https://gitee.com/stylefeng/roses
【8.0.5】【message】删除message模块
parent
1d1bb0e0bf
commit
6f94500659
|
@ -71,14 +71,6 @@
|
|||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--系统消息业务模块的api-->
|
||||
<!--获取当前登录用户的ws-url-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>message-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--jwt模块的api-->
|
||||
<!--token用的jwt token-->
|
||||
<dependency>
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
系统消息模块
|
||||
|
||||
系统消息模块可以发送消息记录,已读未读状态
|
|
@ -1 +0,0 @@
|
|||
系统消息模块的api
|
|
@ -1,65 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>kernel-s-message</artifactId>
|
||||
<version>8.1.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>message-api</artifactId>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!--auth模块的api-->
|
||||
<!--记录日志时候,有可能需要记录当前登录用户id-->
|
||||
<!--如果不要记录当前登录用户id时就不用本模块,所以optional=true-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>auth-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!--参数校验模块-->
|
||||
<!--包含带参数校验注解的类-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>validator-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--数据库模块 api-->
|
||||
<!--分页查询需要用到PageResult相关类-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>db-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--系统管理api模块-->
|
||||
<!--用来做id转化-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>system-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--web-->
|
||||
<!--LogRecordFactory快速创建http类的日志参数会用到-->
|
||||
<!--如果不要记录当前请求的http接口信息,就不用本模块,所以optional=true-->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,168 +0,0 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [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
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
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.request.MessageRequest;
|
||||
import cn.stylefeng.roses.kernel.message.api.pojo.request.MessageSendRequest;
|
||||
import cn.stylefeng.roses.kernel.message.api.pojo.response.MessageResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统消息相关接口
|
||||
* <p>
|
||||
* 接口可以有多种实现,目前只实现数据库存储方式
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/2 21:21
|
||||
*/
|
||||
public interface MessageApi {
|
||||
|
||||
/**
|
||||
* 发送系统消息
|
||||
*
|
||||
* @param messageSendRequest 系统消息参数
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/2 21:21
|
||||
*/
|
||||
void sendMessage(MessageSendRequest messageSendRequest);
|
||||
|
||||
/**
|
||||
* 更新阅读状态
|
||||
*
|
||||
* @param messageRequest 系统消息参数
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/2 22:15
|
||||
*/
|
||||
void updateReadFlag(MessageRequest messageRequest);
|
||||
|
||||
/**
|
||||
* 全部更新阅读状态
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/2 22:15
|
||||
*/
|
||||
void allMessageReadFlag();
|
||||
|
||||
/**
|
||||
* 批量更新阅读状态
|
||||
*
|
||||
* @param messageIds 消息id字符串,多个用逗号分隔
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/4 21:21
|
||||
*/
|
||||
void batchReadFlagByMessageIds(String messageIds, MessageReadFlagEnum flagEnum);
|
||||
|
||||
/**
|
||||
* 删除系统消息
|
||||
*
|
||||
* @param messageId 消息id
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/2 21:21
|
||||
*/
|
||||
void deleteByMessageId(Long messageId);
|
||||
|
||||
/**
|
||||
* 批量删除系统消息
|
||||
*
|
||||
* @param messageIds 消息id字符串,多个用逗号分隔
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/2 21:21
|
||||
*/
|
||||
void batchDeleteByMessageIds(String messageIds);
|
||||
|
||||
/**
|
||||
* 查看系统消息
|
||||
*
|
||||
* @param messageRequest 查看参数
|
||||
* @return 系统消息
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/2 21:21
|
||||
*/
|
||||
MessageResponse messageDetail(MessageRequest messageRequest);
|
||||
|
||||
/**
|
||||
* 查询分页系统消息
|
||||
*
|
||||
* @param messageRequest 查询参数
|
||||
* @return 查询分页结果
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/2 21:21
|
||||
*/
|
||||
PageResult<MessageResponse> queryPage(MessageRequest messageRequest);
|
||||
|
||||
/**
|
||||
* 查询系统消息
|
||||
*
|
||||
* @param messageRequest 查询参数
|
||||
* @return 系统消息列表
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/2 21:21
|
||||
*/
|
||||
List<MessageResponse> queryList(MessageRequest messageRequest);
|
||||
|
||||
/**
|
||||
* 查询分页系统消息 当前登录用户
|
||||
*
|
||||
* @param messageRequest 查询参数
|
||||
* @return 查询分页结果
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/2 21:21
|
||||
*/
|
||||
PageResult<MessageResponse> queryPageCurrentUser(MessageRequest messageRequest);
|
||||
|
||||
/**
|
||||
* 查询系统消息 当前登录用户
|
||||
*
|
||||
* @param messageRequest 查询参数
|
||||
* @return 系统消息列表
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/2 21:21
|
||||
*/
|
||||
List<MessageResponse> queryListCurrentUser(MessageRequest messageRequest);
|
||||
|
||||
/**
|
||||
* 查询系统消息数量
|
||||
*
|
||||
* @param messageRequest 查询参数
|
||||
* @return 系统消息数量
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/11 21:21
|
||||
*/
|
||||
Integer queryCount(MessageRequest messageRequest);
|
||||
|
||||
/**
|
||||
* 查询系统消息数量,当前登录用户
|
||||
*
|
||||
* @param messageRequest 查询参数
|
||||
* @return 系统消息数量
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/11 21:21
|
||||
*/
|
||||
Integer queryCountCurrentUser(MessageRequest messageRequest);
|
||||
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [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
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.message.api.constants;
|
||||
|
||||
/**
|
||||
* message模块的常量
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/1 20:58
|
||||
*/
|
||||
public interface MessageConstants {
|
||||
|
||||
/**
|
||||
* 消息模块的名称
|
||||
*/
|
||||
String MESSAGE_MODULE_NAME = "kernel-s-message";
|
||||
|
||||
/**
|
||||
* 异常枚举的步进值
|
||||
*/
|
||||
String MESSAGE_EXCEPTION_STEP_CODE = "23";
|
||||
|
||||
/**
|
||||
* 发送所有用户标识
|
||||
*/
|
||||
String RECEIVE_ALL_USER_FLAG = "all";
|
||||
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [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
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
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
|
||||
* @since 2021/1/1 21:13
|
||||
*/
|
||||
public class MessageContext {
|
||||
|
||||
/**
|
||||
* 获取消息操作api
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/1 21:13
|
||||
*/
|
||||
public static MessageApi me() {
|
||||
return SpringUtil.getBean(MessageApi.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [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
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.message.api.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 消息业务类型枚举
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/4 22:26
|
||||
*/
|
||||
@Getter
|
||||
public enum MessageBusinessTypeEnum {
|
||||
|
||||
/**
|
||||
* 已读
|
||||
*/
|
||||
SYS_NOTICE("sys_notice", "通知", "/sysNotice/detail");
|
||||
|
||||
private final String code;
|
||||
|
||||
private final String name;
|
||||
|
||||
private final String url;
|
||||
|
||||
|
||||
MessageBusinessTypeEnum(String code, String name, String url) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public static MessageBusinessTypeEnum getByCode(String code) {
|
||||
if (code == null) {
|
||||
return null;
|
||||
}
|
||||
for (MessageBusinessTypeEnum flagEnum : MessageBusinessTypeEnum.values()) {
|
||||
if (flagEnum.getCode().equals(code)) {
|
||||
return flagEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [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
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.message.api.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 消息优先级
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/8 13:26
|
||||
*/
|
||||
@Getter
|
||||
public enum MessagePriorityLevelEnum {
|
||||
|
||||
/**
|
||||
* 高
|
||||
*/
|
||||
HIGH("high", "高"),
|
||||
|
||||
/**
|
||||
* 中
|
||||
*/
|
||||
MIDDLE("middle", "中"),
|
||||
|
||||
/**
|
||||
* 低
|
||||
*/
|
||||
LOW("low", "低");
|
||||
|
||||
private final String code;
|
||||
|
||||
private final String name;
|
||||
|
||||
MessagePriorityLevelEnum(String code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static String getName(String code) {
|
||||
if (code == null) {
|
||||
return null;
|
||||
}
|
||||
for (MessagePriorityLevelEnum flagEnum : MessagePriorityLevelEnum.values()) {
|
||||
if (flagEnum.getCode().equals(code)) {
|
||||
return flagEnum.name;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [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
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.message.api.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 消息阅读状态
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/4 22:26
|
||||
*/
|
||||
@Getter
|
||||
public enum MessageReadFlagEnum {
|
||||
|
||||
/**
|
||||
* 未读
|
||||
*/
|
||||
UNREAD(0, "未读"),
|
||||
|
||||
/**
|
||||
* 已读
|
||||
*/
|
||||
READ(1, "已读");
|
||||
|
||||
private final Integer code;
|
||||
|
||||
private final String name;
|
||||
|
||||
MessageReadFlagEnum(Integer code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static String getName(Integer code) {
|
||||
if (code == null) {
|
||||
return null;
|
||||
}
|
||||
for (MessageReadFlagEnum flagEnum : MessageReadFlagEnum.values()) {
|
||||
if (flagEnum.getCode().equals(code)) {
|
||||
return flagEnum.name;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [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
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.message.api.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 系统消息的类型
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2022/11/21 23:59
|
||||
*/
|
||||
@Getter
|
||||
public enum MessageTypeEnum {
|
||||
|
||||
/**
|
||||
* 普通通知类型
|
||||
*/
|
||||
NORMAL("NORMAL"),
|
||||
|
||||
/**
|
||||
* 带有url跳转的通知类型
|
||||
*/
|
||||
URL("URL");
|
||||
|
||||
private final String code;
|
||||
|
||||
MessageTypeEnum(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [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
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.message.api.exception;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.stylefeng.roses.kernel.message.api.constants.MessageConstants;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
|
||||
/**
|
||||
* 消息异常枚举
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/1 20:55
|
||||
*/
|
||||
public class MessageException extends ServiceException {
|
||||
|
||||
public MessageException(AbstractExceptionEnum exception, Object... params) {
|
||||
super(MessageConstants.MESSAGE_MODULE_NAME, exception.getErrorCode(), StrUtil.format(exception.getUserTip(), params));
|
||||
}
|
||||
|
||||
public MessageException(AbstractExceptionEnum exception) {
|
||||
super(MessageConstants.MESSAGE_MODULE_NAME, exception);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [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
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.message.api.exception.enums;
|
||||
|
||||
import cn.stylefeng.roses.kernel.message.api.constants.MessageConstants;
|
||||
import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 消息异常枚举
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 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字符串不合法!系统无人可接收消息!"),
|
||||
|
||||
/**
|
||||
* 消息记录不存在
|
||||
*/
|
||||
NOT_EXISTED(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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [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
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.message.api.pojo.request;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统消息的查询参数
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/1 20:23
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class MessageRequest extends BaseRequest {
|
||||
|
||||
/**
|
||||
* 消息id
|
||||
*/
|
||||
@NotNull(message = "messageId不能为空", groups = {edit.class, delete.class, detail.class, updateStatus.class})
|
||||
@ChineseDescription("消息id")
|
||||
private Long messageId;
|
||||
|
||||
/**
|
||||
* 接收用户id
|
||||
*/
|
||||
@ChineseDescription("接收用户id")
|
||||
private Long receiveUserId;
|
||||
|
||||
/**
|
||||
* 发送用户id
|
||||
*/
|
||||
@ChineseDescription("发送用户id")
|
||||
private Long sendUserId;
|
||||
|
||||
/**
|
||||
* 消息标题
|
||||
*/
|
||||
@ChineseDescription("消息标题")
|
||||
private String messageTitle;
|
||||
|
||||
/**
|
||||
* 消息的内容
|
||||
*/
|
||||
@ChineseDescription("消息内容")
|
||||
private String messageContent;
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
@ChineseDescription("消息类型")
|
||||
private String messageType;
|
||||
|
||||
/**
|
||||
* 消息优先级
|
||||
*/
|
||||
@ChineseDescription("消息优先级")
|
||||
private String priorityLevel;
|
||||
|
||||
/**
|
||||
* 消息发送时间
|
||||
*/
|
||||
@ChineseDescription("消息发送时间")
|
||||
private Date messageSendTime;
|
||||
|
||||
/**
|
||||
* 业务id
|
||||
*/
|
||||
@ChineseDescription("业务id")
|
||||
private Long businessId;
|
||||
|
||||
/**
|
||||
* 业务类型
|
||||
*/
|
||||
@ChineseDescription("业务类型")
|
||||
private String businessType;
|
||||
|
||||
/**
|
||||
* 阅读状态:0-未读,1-已读
|
||||
*/
|
||||
@NotNull(message = "阅读状态不能为空", groups = {updateStatus.class})
|
||||
@ChineseDescription("阅读状态")
|
||||
private Integer readFlag;
|
||||
|
||||
/**
|
||||
* 消息id集合
|
||||
*/
|
||||
@NotEmpty(message = "消息id集合不能为空", groups = {updateReadFlag.class})
|
||||
@ChineseDescription("消息id集合")
|
||||
private List<Long> messageIdList;
|
||||
|
||||
|
||||
/**
|
||||
* 参数校验分组:修改阅读状态
|
||||
*/
|
||||
public @interface updateReadFlag {
|
||||
}
|
||||
|
||||
}
|
|
@ -1,112 +0,0 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [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
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.message.api.pojo.request;
|
||||
|
||||
import cn.stylefeng.roses.kernel.message.api.enums.MessagePriorityLevelEnum;
|
||||
import cn.stylefeng.roses.kernel.message.api.enums.MessageTypeEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 发送系统消息的参数
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/1 20:23
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class MessageSendRequest extends BaseRequest {
|
||||
|
||||
/**
|
||||
* 接收用户id字符串,多个以,分割
|
||||
*/
|
||||
@NotBlank(message = "接收用户ID字符串不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("接收用户id字符串,多个以,分割")
|
||||
private String receiveUserIds;
|
||||
|
||||
/**
|
||||
* 消息标题
|
||||
*/
|
||||
@NotBlank(message = "消息标题不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("消息标题")
|
||||
private String messageTitle;
|
||||
|
||||
/**
|
||||
* 消息的内容
|
||||
*/
|
||||
@ChineseDescription("消息内容")
|
||||
private String messageContent;
|
||||
|
||||
/**
|
||||
* 消息类型,是普通的还是带URL的
|
||||
*/
|
||||
@ChineseDescription("消息类型,是普通的还是带URL的")
|
||||
private String messageType = MessageTypeEnum.NORMAL.getCode();
|
||||
|
||||
/**
|
||||
* 消息跳转的URL
|
||||
*/
|
||||
@ChineseDescription("消息跳转的URL")
|
||||
private String messageUrl;
|
||||
|
||||
/**
|
||||
* 消息优先级
|
||||
*/
|
||||
@ChineseDescription("消息优先级")
|
||||
private String priorityLevel = MessagePriorityLevelEnum.LOW.getCode();
|
||||
|
||||
/**
|
||||
* 业务id
|
||||
*/
|
||||
@NotNull(message = "业务id不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("业务id")
|
||||
private Long businessId;
|
||||
|
||||
/**
|
||||
* 业务类型
|
||||
*/
|
||||
@NotBlank(message = "业务类型不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("业务类型")
|
||||
private String businessType;
|
||||
|
||||
/**
|
||||
* 业务类型值
|
||||
*/
|
||||
@ChineseDescription("业务类型值")
|
||||
private String businessTypeValue;
|
||||
|
||||
/**
|
||||
* 消息发送时间
|
||||
*/
|
||||
@ChineseDescription("消息发送时间")
|
||||
private Date messageSendTime;
|
||||
|
||||
}
|
|
@ -1,157 +0,0 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [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
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.message.api.pojo.response;
|
||||
|
||||
import cn.stylefeng.roses.kernel.message.api.enums.MessageBusinessTypeEnum;
|
||||
import cn.stylefeng.roses.kernel.message.api.enums.MessagePriorityLevelEnum;
|
||||
import cn.stylefeng.roses.kernel.message.api.enums.MessageReadFlagEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.SimpleFieldFormat;
|
||||
import cn.stylefeng.roses.kernel.sys.api.format.UserNameFormatProcess;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/**
|
||||
* 系统消息的查询参数
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/2 21:23
|
||||
*/
|
||||
@Data
|
||||
public class MessageResponse implements Serializable {
|
||||
|
||||
/**
|
||||
* 消息id
|
||||
*/
|
||||
@ChineseDescription("消息id")
|
||||
private Long messageId;
|
||||
|
||||
/**
|
||||
* 接收用户id
|
||||
*/
|
||||
@ChineseDescription("接收用户id")
|
||||
private Long receiveUserId;
|
||||
|
||||
/**
|
||||
* 发送用户id
|
||||
*/
|
||||
@ChineseDescription("发送用户id")
|
||||
@SimpleFieldFormat(processClass = UserNameFormatProcess.class)
|
||||
private Long sendUserId;
|
||||
|
||||
/**
|
||||
* 消息标题
|
||||
*/
|
||||
@ChineseDescription("消息标题")
|
||||
private String messageTitle;
|
||||
|
||||
/**
|
||||
* 消息的内容
|
||||
*/
|
||||
@ChineseDescription("消息内容")
|
||||
private String messageContent;
|
||||
|
||||
/**
|
||||
* 消息优先级
|
||||
*/
|
||||
@ChineseDescription("消息优先级")
|
||||
private String priorityLevel;
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
@ChineseDescription("消息类型")
|
||||
private String messageType;
|
||||
|
||||
/**
|
||||
* 消息发送时间
|
||||
*/
|
||||
@ChineseDescription("消息发送时间")
|
||||
private Date messageSendTime;
|
||||
|
||||
/**
|
||||
* 业务id
|
||||
*/
|
||||
@ChineseDescription("业务id")
|
||||
private Long businessId;
|
||||
|
||||
/**
|
||||
* 业务类型
|
||||
*/
|
||||
@ChineseDescription("业务类型")
|
||||
private String businessType;
|
||||
|
||||
/**
|
||||
* 阅读状态:0-未读,1-已读
|
||||
*/
|
||||
@ChineseDescription("阅读状态:0-未读,1-已读")
|
||||
private Integer readFlag;
|
||||
|
||||
/**
|
||||
* 消息优先级
|
||||
*/
|
||||
@ChineseDescription("消息优先级")
|
||||
private String priorityLevelValue;
|
||||
|
||||
/**
|
||||
* 阅读状态:0-未读,1-已读
|
||||
*/
|
||||
@ChineseDescription("阅读状态:0-未读,1-已读")
|
||||
private String readFlagValue;
|
||||
|
||||
/**
|
||||
* 消息跳转的URL
|
||||
*/
|
||||
@ChineseDescription("消息跳转的URL")
|
||||
private String messageUrl;
|
||||
|
||||
public String getPriorityLevelValue() {
|
||||
AtomicReference<String> value = new AtomicReference<>("");
|
||||
Optional.ofNullable(this.priorityLevel).ifPresent(val -> {
|
||||
value.set(MessagePriorityLevelEnum.getName(this.priorityLevel));
|
||||
});
|
||||
return value.get();
|
||||
}
|
||||
|
||||
public String getReadFlagValue() {
|
||||
AtomicReference<String> value = new AtomicReference<>("");
|
||||
Optional.ofNullable(this.readFlag).ifPresent(val -> {
|
||||
value.set(MessageReadFlagEnum.getName(this.readFlag));
|
||||
});
|
||||
return value.get();
|
||||
}
|
||||
|
||||
public String getBusinessTypeValue() {
|
||||
AtomicReference<String> value = new AtomicReference<>("");
|
||||
Optional.ofNullable(this.businessType).ifPresent(val -> {
|
||||
value.set(MessageBusinessTypeEnum.getName(this.businessType));
|
||||
});
|
||||
return value.get();
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
系统消息业务模块,包含发送消息,查看消息,消息列表,已读消息,未读消息的业务
|
|
@ -1,67 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>kernel-s-message</artifactId>
|
||||
<version>8.1.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>message-business</artifactId>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!--消息api模块-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>message-sdk-db</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--包装器模块-->
|
||||
<!--包装结果-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>wrapper-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--资源api模块-->
|
||||
<!--用在资源控制器,资源扫描上-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>scanner-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--参数校验模块-->
|
||||
<!--用在控制器,参数校验-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>validator-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--数据库sdk-->
|
||||
<!--数据库dao框架-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>db-sdk-mp</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--web模块-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,164 +0,0 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [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
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.message.modular.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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.MessageReadFlagEnum;
|
||||
import cn.stylefeng.roses.kernel.message.api.pojo.request.MessageRequest;
|
||||
import cn.stylefeng.roses.kernel.message.api.pojo.request.MessageSendRequest;
|
||||
import cn.stylefeng.roses.kernel.message.api.pojo.response.MessageResponse;
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ApiLog;
|
||||
import cn.stylefeng.roses.kernel.rule.enums.ResBizTypeEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统消息控制器
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/1 22:30
|
||||
*/
|
||||
@RestController
|
||||
@ApiResource(name = "系统消息控制器", resBizType = ResBizTypeEnum.SYSTEM)
|
||||
public class SysMessageController {
|
||||
|
||||
/**
|
||||
* 系统消息api
|
||||
*/
|
||||
@Resource
|
||||
private MessageApi messageApi;
|
||||
|
||||
/**
|
||||
* 发送系统消息
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/8 13:50
|
||||
*/
|
||||
@PostResource(name = "发送系统消息", path = "/sysMessage/sendMessage")
|
||||
@ApiLog
|
||||
public ResponseData<?> sendMessage(@RequestBody @Validated(MessageSendRequest.add.class) MessageSendRequest messageSendRequest) {
|
||||
messageSendRequest.setMessageSendTime(new Date());
|
||||
messageApi.sendMessage(messageSendRequest);
|
||||
return new SuccessResponseData<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新系统消息状态
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/8 13:50
|
||||
*/
|
||||
@PostResource(name = "批量更新系统消息状态", path = "/sysMessage/batchUpdateReadFlag")
|
||||
@ApiLog
|
||||
public ResponseData<?> batchUpdateReadFlag(@RequestBody @Validated(MessageRequest.updateReadFlag.class) MessageRequest messageRequest) {
|
||||
List<Long> messageIdList = messageRequest.getMessageIdList();
|
||||
messageApi.batchReadFlagByMessageIds(StrUtil.join(",", messageIdList), MessageReadFlagEnum.READ);
|
||||
return new SuccessResponseData<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统消息全部修改已读
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/8 13:50
|
||||
*/
|
||||
@GetResource(name = "系统消息全部修改已读", path = "/sysMessage/allMessageReadFlag")
|
||||
public ResponseData<?> allMessageReadFlag() {
|
||||
messageApi.allMessageReadFlag();
|
||||
return new SuccessResponseData<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除系统消息
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/8 13:50
|
||||
*/
|
||||
@PostResource(name = "删除系统消息", path = "/sysMessage/delete")
|
||||
@ApiLog
|
||||
public ResponseData<?> delete(@RequestBody @Validated(MessageRequest.delete.class) MessageRequest messageRequest) {
|
||||
messageApi.deleteByMessageId(messageRequest.getMessageId());
|
||||
return new SuccessResponseData<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看系统消息
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/8 13:50
|
||||
*/
|
||||
@GetResource(name = "查看系统消息", path = "/sysMessage/detail")
|
||||
public ResponseData<MessageResponse> detail(@Validated(MessageRequest.detail.class) MessageRequest messageRequest) {
|
||||
return new SuccessResponseData<>(messageApi.messageDetail(messageRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询系统消息列表
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/8 13:50
|
||||
*/
|
||||
@GetResource(name = "分页查询系统消息列表", path = "/sysMessage/page")
|
||||
public ResponseData<PageResult<MessageResponse>> page(MessageRequest messageRequest) {
|
||||
return new SuccessResponseData<>(messageApi.queryPageCurrentUser(messageRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统消息列表
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/8 13:50
|
||||
*/
|
||||
@GetResource(name = "系统消息列表", path = "/sysMessage/list")
|
||||
public ResponseData<List<MessageResponse>> list(MessageRequest messageRequest) {
|
||||
return new SuccessResponseData<>(messageApi.queryListCurrentUser(messageRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有未读系统消息列表
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2021/6/12 17:42
|
||||
*/
|
||||
@GetResource(name = "查询所有未读系统消息列表", path = "/sysMessage/unReadMessageList", requiredPermission = false)
|
||||
public ResponseData<List<MessageResponse>> unReadMessageList(MessageRequest messageRequest) {
|
||||
messageRequest.setReadFlag(MessageReadFlagEnum.UNREAD.getCode());
|
||||
List<MessageResponse> messageResponses = messageApi.queryListCurrentUser(messageRequest);
|
||||
return new SuccessResponseData<>(messageResponses);
|
||||
}
|
||||
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
系统消息记录的sdk,用于将消息记录到数据库中,提供相关消息管理接口
|
|
@ -1,43 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>kernel-s-message</artifactId>
|
||||
<version>8.1.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>message-sdk-db</artifactId>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!--消息模块的api-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>message-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--数据库sdk-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>db-sdk-mp</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--发送消息需要用到用户相关的接口-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>system-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,254 +0,0 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [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
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.message.db;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.message.api.MessageApi;
|
||||
import cn.stylefeng.roses.kernel.message.api.constants.MessageConstants;
|
||||
import cn.stylefeng.roses.kernel.message.api.enums.MessageReadFlagEnum;
|
||||
import cn.stylefeng.roses.kernel.message.api.exception.MessageException;
|
||||
import cn.stylefeng.roses.kernel.message.api.exception.enums.MessageExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.message.api.pojo.request.MessageRequest;
|
||||
import cn.stylefeng.roses.kernel.message.api.pojo.request.MessageSendRequest;
|
||||
import cn.stylefeng.roses.kernel.message.api.pojo.response.MessageResponse;
|
||||
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.sys.api.SysUserServiceApi;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 系统消息,数据库实现
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/2 22:00
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class MessageDbServiceImpl implements MessageApi {
|
||||
|
||||
@Resource
|
||||
private SysUserServiceApi sysUserServiceApi;
|
||||
|
||||
@Resource
|
||||
private SysMessageService sysMessageService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void sendMessage(MessageSendRequest messageSendRequest) {
|
||||
|
||||
String receiveUserIds = messageSendRequest.getReceiveUserIds();
|
||||
LoginUser loginUser = LoginContext.me().getLoginUserNullable();
|
||||
|
||||
List<SysMessage> sendMsgList = new ArrayList<>();
|
||||
List<Long> userIds;
|
||||
|
||||
// 发送所有人判断
|
||||
if (MessageConstants.RECEIVE_ALL_USER_FLAG.equals(receiveUserIds)) {
|
||||
// 查询所有用户
|
||||
userIds = sysUserServiceApi.queryAllUserIdList();
|
||||
} else {
|
||||
String[] userIdArr = receiveUserIds.split(",");
|
||||
userIds = Convert.toList(Long.class, userIdArr);
|
||||
}
|
||||
|
||||
// 无人可发,不发送
|
||||
if (userIds == null || userIds.isEmpty()) {
|
||||
throw new MessageException(MessageExceptionEnum.ERROR_RECEIVE_USER_IDS);
|
||||
}
|
||||
|
||||
Set<Long> userIdSet = new HashSet<>(userIds);
|
||||
for (Long userId : userIdSet) {
|
||||
|
||||
// 判断用户是否存在
|
||||
if (!sysUserServiceApi.userExist(userId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SysMessage sysMessage = new SysMessage();
|
||||
BeanUtil.copyProperties(messageSendRequest, sysMessage);
|
||||
|
||||
// 设置默认未读
|
||||
sysMessage.setReadFlag(MessageReadFlagEnum.UNREAD.getCode());
|
||||
|
||||
// 设置发件人
|
||||
if (loginUser != null) {
|
||||
sysMessage.setSendUserId(loginUser.getUserId());
|
||||
}
|
||||
|
||||
// 设置收信人
|
||||
sysMessage.setReceiveUserId(userId);
|
||||
|
||||
sendMsgList.add(sysMessage);
|
||||
}
|
||||
sysMessageService.saveBatch(sendMsgList);
|
||||
|
||||
// 给用户发送通知
|
||||
for (SysMessage item : sendMsgList) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateReadFlag(MessageRequest messageRequest) {
|
||||
Long messageId = messageRequest.getMessageId();
|
||||
SysMessage sysMessage = sysMessageService.getById(messageId);
|
||||
Optional.ofNullable(sysMessage).ifPresent(msg -> {
|
||||
msg.setReadFlag(messageRequest.getReadFlag());
|
||||
sysMessageService.updateById(msg);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void allMessageReadFlag() {
|
||||
// 获取当前登录人
|
||||
LoginUser loginUser = LoginContext.me().getLoginUser();
|
||||
Long userId = loginUser.getUserId();
|
||||
LambdaUpdateWrapper<SysMessage> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.set(SysMessage::getReadFlag, MessageReadFlagEnum.READ.getCode())
|
||||
.eq(SysMessage::getReadFlag, MessageReadFlagEnum.UNREAD.getCode()).eq(SysMessage::getReceiveUserId, userId)
|
||||
.set(SysMessage::getDelFlag, YesOrNotEnum.N.getCode());
|
||||
sysMessageService.update(updateWrapper);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchReadFlagByMessageIds(String messageIds, MessageReadFlagEnum flagEnum) {
|
||||
LambdaUpdateWrapper<SysMessage> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.inSql(SysMessage::getMessageId, messageIds).set(SysMessage::getReadFlag, flagEnum.getCode());
|
||||
sysMessageService.update(updateWrapper);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteByMessageId(Long messageId) {
|
||||
LambdaUpdateWrapper<SysMessage> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
// 修改为逻辑删除
|
||||
updateWrapper.eq(SysMessage::getMessageId, messageId).set(SysMessage::getDelFlag, YesOrNotEnum.Y.getCode());
|
||||
sysMessageService.update(updateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchDeleteByMessageIds(String messageIds) {
|
||||
LambdaUpdateWrapper<SysMessage> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.inSql(SysMessage::getMessageId, messageIds).set(SysMessage::getDelFlag, YesOrNotEnum.Y.getCode());
|
||||
sysMessageService.update(updateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageResponse messageDetail(MessageRequest messageRequest) {
|
||||
SysMessage sysMessage = sysMessageService.getById(messageRequest.getMessageId());
|
||||
// 判断消息为未读状态更新为已读
|
||||
Optional.ofNullable(sysMessage).ifPresent(msg -> {
|
||||
if (MessageReadFlagEnum.UNREAD.getCode().equals(sysMessage.getReadFlag())) {
|
||||
msg.setReadFlag(MessageReadFlagEnum.READ.getCode());
|
||||
sysMessageService.updateById(msg);
|
||||
}
|
||||
});
|
||||
MessageResponse messageResponse = new MessageResponse();
|
||||
BeanUtil.copyProperties(sysMessage, messageResponse);
|
||||
return messageResponse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<MessageResponse> queryPage(MessageRequest messageRequest) {
|
||||
PageResult<SysMessage> pageResult = sysMessageService.findPage(messageRequest);
|
||||
PageResult<MessageResponse> result = new PageResult<>();
|
||||
List<SysMessage> messageList = pageResult.getRows();
|
||||
List<MessageResponse> resultList = messageList.stream().map(msg -> {
|
||||
MessageResponse response = new MessageResponse();
|
||||
BeanUtil.copyProperties(msg, response);
|
||||
return response;
|
||||
}).collect(Collectors.toList());
|
||||
BeanUtil.copyProperties(pageResult, result);
|
||||
result.setRows(resultList);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MessageResponse> queryList(MessageRequest messageRequest) {
|
||||
List<SysMessage> messageList = sysMessageService.findList(messageRequest);
|
||||
return messageList.stream().map(msg -> {
|
||||
MessageResponse response = new MessageResponse();
|
||||
BeanUtil.copyProperties(msg, response);
|
||||
return response;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<MessageResponse> queryPageCurrentUser(MessageRequest messageRequest) {
|
||||
if (ObjectUtil.isEmpty(messageRequest)) {
|
||||
messageRequest = new MessageRequest();
|
||||
}
|
||||
// 获取当前登录人
|
||||
LoginUser loginUser = LoginContext.me().getLoginUser();
|
||||
messageRequest.setReceiveUserId(loginUser.getUserId());
|
||||
return this.queryPage(messageRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MessageResponse> queryListCurrentUser(MessageRequest messageRequest) {
|
||||
if (ObjectUtil.isEmpty(messageRequest)) {
|
||||
messageRequest = new MessageRequest();
|
||||
}
|
||||
// 获取当前登录人
|
||||
LoginUser loginUser = LoginContext.me().getLoginUser();
|
||||
messageRequest.setReceiveUserId(loginUser.getUserId());
|
||||
return this.queryList(messageRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer queryCount(MessageRequest messageRequest) {
|
||||
return sysMessageService.findCount(messageRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer queryCountCurrentUser(MessageRequest messageRequest) {
|
||||
if (ObjectUtil.isEmpty(messageRequest)) {
|
||||
messageRequest = new MessageRequest();
|
||||
}
|
||||
// 获取当前登录人
|
||||
LoginUser loginUser = LoginContext.me().getLoginUser();
|
||||
messageRequest.setReceiveUserId(loginUser.getUserId());
|
||||
return this.queryCount(messageRequest);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,135 +0,0 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [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
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.message.db.entity;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.serializer.ToStringSerializer;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 系统消息
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 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)
|
||||
@JSONField(serializeUsing = ToStringSerializer.class)
|
||||
private Long messageId;
|
||||
|
||||
/**
|
||||
* 接收用户id
|
||||
*/
|
||||
@TableField(value = "receive_user_id")
|
||||
@JSONField(serializeUsing = ToStringSerializer.class)
|
||||
private Long receiveUserId;
|
||||
|
||||
/**
|
||||
* 发送用户id
|
||||
*/
|
||||
@TableField(value = "send_user_id")
|
||||
@JSONField(serializeUsing = ToStringSerializer.class)
|
||||
private Long sendUserId;
|
||||
|
||||
/**
|
||||
* 消息标题
|
||||
*/
|
||||
@TableField(value = "message_title")
|
||||
private String messageTitle;
|
||||
|
||||
/**
|
||||
* 消息的内容
|
||||
*/
|
||||
@TableField(value = "message_content")
|
||||
private String messageContent;
|
||||
|
||||
/**
|
||||
* 消息类型(是普通消息 或是带url的消息)
|
||||
*/
|
||||
@TableField(value = "message_type")
|
||||
private String messageType;
|
||||
|
||||
/**
|
||||
* 消息跳转的URL
|
||||
*/
|
||||
@TableField(value = "message_url")
|
||||
private String messageUrl;
|
||||
|
||||
/**
|
||||
* 消息优先级
|
||||
*/
|
||||
@TableField(value = "priority_level")
|
||||
private String priorityLevel;
|
||||
|
||||
/**
|
||||
* 消息发送时间
|
||||
*/
|
||||
@TableField(value = "message_send_time")
|
||||
private Date messageSendTime;
|
||||
|
||||
/**
|
||||
* 业务id
|
||||
*/
|
||||
@TableField(value = "business_id")
|
||||
@JSONField(serializeUsing = ToStringSerializer.class)
|
||||
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;
|
||||
|
||||
/**
|
||||
* 业务类型值
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String businessTypeValue;
|
||||
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [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
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
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
|
||||
* @since 2020/12/31 20:09
|
||||
*/
|
||||
public interface SysMessageMapper extends BaseMapper<SysMessage> {
|
||||
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="cn.stylefeng.roses.kernel.message.db.mapper.SysMessageMapper">
|
||||
</mapper>
|
|
@ -1,105 +0,0 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [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
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
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.request.MessageRequest;
|
||||
import cn.stylefeng.roses.kernel.message.db.entity.SysMessage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统消息 service接口
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 2020/12/31 20:09
|
||||
*/
|
||||
public interface SysMessageService extends IService<SysMessage> {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param messageRequest 参数对象
|
||||
* @author liuhanqing
|
||||
* @since 2021/2/2 20:48
|
||||
*/
|
||||
void add(MessageRequest messageRequest);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param messageRequest 参数对象
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/26 12:52
|
||||
*/
|
||||
void del(MessageRequest messageRequest);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
* @param messageRequest 参数对象
|
||||
* @author liuhanqing
|
||||
* @since 2021/2/2 20:48
|
||||
*/
|
||||
void edit(MessageRequest messageRequest);
|
||||
|
||||
/**
|
||||
* 查询-详情-根据主键id
|
||||
*
|
||||
* @param messageRequest 参数对象
|
||||
* @author liuhanqing
|
||||
* @since 2021/2/2 20:48
|
||||
*/
|
||||
SysMessage detail(MessageRequest messageRequest);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param messageRequest 参数
|
||||
* @author liuhanqing
|
||||
* @since 2021/2/2 20:48
|
||||
*/
|
||||
PageResult<SysMessage> findPage(MessageRequest messageRequest);
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param messageRequest 参数
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/8 15:21
|
||||
*/
|
||||
List<SysMessage> findList(MessageRequest messageRequest);
|
||||
|
||||
/**
|
||||
* 数量查询
|
||||
*
|
||||
* @param messageRequest 参数
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/11 19:21
|
||||
*/
|
||||
Integer findCount(MessageRequest messageRequest);
|
||||
|
||||
}
|
|
@ -1,159 +0,0 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [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
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.message.db.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
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.exception.MessageException;
|
||||
import cn.stylefeng.roses.kernel.message.api.exception.enums.MessageExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.message.api.pojo.request.MessageRequest;
|
||||
import cn.stylefeng.roses.kernel.message.db.entity.SysMessage;
|
||||
import cn.stylefeng.roses.kernel.message.db.mapper.SysMessageMapper;
|
||||
import cn.stylefeng.roses.kernel.message.db.service.SysMessageService;
|
||||
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统消息 service接口实现类
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 2020/12/31 20:09
|
||||
*/
|
||||
@Service
|
||||
public class SysMessageServiceImpl extends ServiceImpl<SysMessageMapper, SysMessage> implements SysMessageService {
|
||||
|
||||
@Override
|
||||
public void add(MessageRequest messageRequest) {
|
||||
SysMessage sysMessage = new SysMessage();
|
||||
BeanUtil.copyProperties(messageRequest, sysMessage);
|
||||
this.save(sysMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void del(MessageRequest messageRequest) {
|
||||
SysMessage sysMessage = this.querySysMessageById(messageRequest);
|
||||
// 逻辑删除
|
||||
sysMessage.setDelFlag(YesOrNotEnum.Y.getCode());
|
||||
this.updateById(sysMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit(MessageRequest messageRequest) {
|
||||
SysMessage sysMessage = new SysMessage();
|
||||
BeanUtil.copyProperties(messageRequest, sysMessage);
|
||||
this.updateById(sysMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysMessage detail(MessageRequest messageRequest) {
|
||||
LambdaQueryWrapper<SysMessage> queryWrapper = this.createWrapper(messageRequest, true);
|
||||
return this.getOne(queryWrapper, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<SysMessage> findPage(MessageRequest messageRequest) {
|
||||
LambdaQueryWrapper<SysMessage> wrapper = createWrapper(messageRequest, true);
|
||||
Page<SysMessage> page = this.page(PageFactory.defaultPage(), wrapper);
|
||||
return PageResultFactory.createPageResult(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysMessage> findList(MessageRequest messageRequest) {
|
||||
LambdaQueryWrapper<SysMessage> wrapper = createWrapper(messageRequest, true);
|
||||
return this.list(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer findCount(MessageRequest messageRequest) {
|
||||
LambdaQueryWrapper<SysMessage> wrapper = createWrapper(messageRequest, false);
|
||||
long count = this.count(wrapper);
|
||||
return Convert.toInt(count);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据主键id获取对象
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 2021/2/2 20:57
|
||||
*/
|
||||
private SysMessage querySysMessageById(MessageRequest messageRequest) {
|
||||
SysMessage sysMessage = this.getById(messageRequest.getMessageId());
|
||||
if (ObjectUtil.isEmpty(sysMessage)) {
|
||||
throw new MessageException(MessageExceptionEnum.NOT_EXISTED, messageRequest.getMessageId());
|
||||
}
|
||||
return sysMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建wrapper
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @since 2021/1/8 14:16
|
||||
*/
|
||||
private LambdaQueryWrapper<SysMessage> createWrapper(MessageRequest messageRequest, boolean needOrderBy) {
|
||||
LambdaQueryWrapper<SysMessage> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
// 查询未删除的
|
||||
queryWrapper.ne(SysMessage::getDelFlag, YesOrNotEnum.Y.getCode());
|
||||
|
||||
// 按发送事件倒序
|
||||
if (needOrderBy) {
|
||||
queryWrapper.orderByDesc(SysMessage::getMessageSendTime);
|
||||
}
|
||||
|
||||
if (ObjectUtil.isEmpty(messageRequest)) {
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
// 消息标题
|
||||
String messageTitle = messageRequest.getMessageTitle();
|
||||
|
||||
// 接收人id
|
||||
Long receiveUserId = messageRequest.getReceiveUserId();
|
||||
|
||||
// 消息类型
|
||||
String messageType = messageRequest.getMessageType();
|
||||
|
||||
// 阅读状态
|
||||
Integer readFlag = messageRequest.getReadFlag();
|
||||
|
||||
// 拼接sql 条件
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(messageTitle), SysMessage::getMessageTitle, messageTitle);
|
||||
queryWrapper.eq(ObjectUtil.isNotEmpty(receiveUserId), SysMessage::getReceiveUserId, receiveUserId);
|
||||
queryWrapper.eq(ObjectUtil.isNotEmpty(messageType), SysMessage::getMessageType, messageType);
|
||||
queryWrapper.eq(ObjectUtil.isNotEmpty(readFlag), SysMessage::getReadFlag, readFlag);
|
||||
|
||||
return queryWrapper;
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
系统消息的spring boot自动加载模块
|
|
@ -1,36 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>kernel-s-message</artifactId>
|
||||
<version>8.1.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>message-spring-boot-starter</artifactId>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!--消息管理-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>message-business</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--消息默认记录到库中-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>message-sdk-db</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,36 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>roses-kernel</artifactId>
|
||||
<version>8.1.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>kernel-s-message</artifactId>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>message-api</module>
|
||||
<module>message-business</module>
|
||||
<module>message-sdk-db</module>
|
||||
<module>message-spring-boot-starter</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- 开发规则 -->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>kernel-a-rule</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -90,13 +90,6 @@
|
|||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--消息模块-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>message-spring-boot-starter</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--数据库sdk-->
|
||||
<!--数据库dao框架-->
|
||||
<dependency>
|
||||
|
|
Loading…
Reference in New Issue