【8.0.5】【message】删除message模块

pull/60/head
fengshuonan 2024-01-12 17:28:58 +08:00
parent 1d1bb0e0bf
commit 6f94500659
32 changed files with 0 additions and 2186 deletions

View File

@ -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>

View File

@ -1,3 +0,0 @@
系统消息模块
系统消息模块可以发送消息记录,已读未读状态

View File

@ -1 +0,0 @@
系统消息模块的api

View File

@ -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>

View File

@ -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.
*
* GunsAPACHE 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);
}

View File

@ -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.
*
* GunsAPACHE 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";
}

View File

@ -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.
*
* GunsAPACHE 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);
}
}

View File

@ -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.
*
* GunsAPACHE 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;
}
}

View File

@ -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.
*
* GunsAPACHE 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;
}
}

View File

@ -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.
*
* GunsAPACHE 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;
}
}

View File

@ -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.
*
* GunsAPACHE 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;
}
}

View File

@ -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.
*
* GunsAPACHE 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);
}
}

View File

@ -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.
*
* GunsAPACHE 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;
}
}

View File

@ -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.
*
* GunsAPACHE 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 {
}
}

View File

@ -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.
*
* GunsAPACHE 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;
}

View File

@ -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.
*
* GunsAPACHE 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();
}
}

View File

@ -1 +0,0 @@
系统消息业务模块,包含发送消息,查看消息,消息列表,已读消息,未读消息的业务

View File

@ -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>

View File

@ -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.
*
* GunsAPACHE 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);
}
}

View File

@ -1 +0,0 @@
系统消息记录的sdk用于将消息记录到数据库中提供相关消息管理接口

View File

@ -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>

View File

@ -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.
*
* GunsAPACHE 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);
}
}

View File

@ -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.
*
* GunsAPACHE 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;
}

View File

@ -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.
*
* GunsAPACHE 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> {
}

View File

@ -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>

View File

@ -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.
*
* GunsAPACHE 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);
}

View File

@ -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.
*
* GunsAPACHE 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;
}
}

View File

@ -1 +0,0 @@
系统消息的spring boot自动加载模块

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -97,9 +97,6 @@
<!--分组业务-->
<module>kernel-s-group</module>
<!--系统消息模块-->
<module>kernel-s-message</module>
<!--业务点击统计-->
<module>kernel-s-stat</module>