mirror of https://gitee.com/stylefeng/roses
【message】系统消息接口调试完成
parent
17fedc40f3
commit
1056a41826
|
@ -3,7 +3,7 @@ package cn.stylefeng.roses.kernel.message.api.enums;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消息阅读状态
|
* 消息业务类型枚举
|
||||||
*
|
*
|
||||||
* @author liuhanqing
|
* @author liuhanqing
|
||||||
* @date 2021/1/4 22:26
|
* @date 2021/1/4 22:26
|
||||||
|
@ -14,24 +14,28 @@ public enum MessageBusinessTypeEnum {
|
||||||
/**
|
/**
|
||||||
* 已读
|
* 已读
|
||||||
*/
|
*/
|
||||||
SYS_NOTICE("sys_notice", "系统通知");
|
SYS_NOTICE("sys_notice", "系统通知", "/sysNotice/detail");
|
||||||
|
|
||||||
private String code;
|
private final String code;
|
||||||
|
|
||||||
private String name;
|
private final String name;
|
||||||
|
|
||||||
MessageBusinessTypeEnum(String code, String name) {
|
private final String url;
|
||||||
|
|
||||||
|
|
||||||
|
MessageBusinessTypeEnum(String code, String name, String url) {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getName(String code) {
|
public static MessageBusinessTypeEnum getByCode(String code) {
|
||||||
if (code == null) {
|
if (code == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
for (MessageBusinessTypeEnum flagEnum : MessageBusinessTypeEnum.values()) {
|
for (MessageBusinessTypeEnum flagEnum : MessageBusinessTypeEnum.values()) {
|
||||||
if (flagEnum.getCode().equals(code)) {
|
if (flagEnum.getCode().equals(code)) {
|
||||||
return flagEnum.name;
|
return flagEnum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -26,9 +26,9 @@ public enum MessageProrityLevelEnum {
|
||||||
*/
|
*/
|
||||||
LOW("low", "低");
|
LOW("low", "低");
|
||||||
|
|
||||||
private String code;
|
private final String code;
|
||||||
|
|
||||||
private String name;
|
private final String name;
|
||||||
|
|
||||||
MessageProrityLevelEnum(String code, String name) {
|
MessageProrityLevelEnum(String code, String name) {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
|
|
|
@ -21,9 +21,9 @@ public enum MessageReadFlagEnum {
|
||||||
*/
|
*/
|
||||||
READ(1, "已读");
|
READ(1, "已读");
|
||||||
|
|
||||||
private Integer code;
|
private final Integer code;
|
||||||
|
|
||||||
private String name;
|
private final String name;
|
||||||
|
|
||||||
MessageReadFlagEnum(Integer code, String name) {
|
MessageReadFlagEnum(Integer code, String name) {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
|
|
|
@ -9,6 +9,7 @@ import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||||
import cn.stylefeng.roses.kernel.message.api.MessageApi;
|
import cn.stylefeng.roses.kernel.message.api.MessageApi;
|
||||||
import cn.stylefeng.roses.kernel.message.api.constants.MessageConstants;
|
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.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.exception.enums.MessageExceptionEnum;
|
||||||
import cn.stylefeng.roses.kernel.message.api.pojo.MessageParam;
|
import cn.stylefeng.roses.kernel.message.api.pojo.MessageParam;
|
||||||
import cn.stylefeng.roses.kernel.message.api.pojo.MessageResponse;
|
import cn.stylefeng.roses.kernel.message.api.pojo.MessageResponse;
|
||||||
|
@ -17,7 +18,6 @@ import cn.stylefeng.roses.kernel.message.db.entity.SysMessage;
|
||||||
import cn.stylefeng.roses.kernel.message.db.service.SysMessageService;
|
import cn.stylefeng.roses.kernel.message.db.service.SysMessageService;
|
||||||
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
||||||
import cn.stylefeng.roses.kernel.system.UserServiceApi;
|
import cn.stylefeng.roses.kernel.system.UserServiceApi;
|
||||||
import cn.stylefeng.roses.kernel.system.exception.SystemModularException;
|
|
||||||
import cn.stylefeng.roses.kernel.system.pojo.user.request.SysUserRequest;
|
import cn.stylefeng.roses.kernel.system.pojo.user.request.SysUserRequest;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -26,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统消息,数据库实现
|
* 系统消息,数据库实现
|
||||||
|
@ -62,7 +63,7 @@ public class MessageDbServiceImpl implements MessageApi {
|
||||||
userIds = Convert.toList(Long.class, userIdArr);
|
userIds = Convert.toList(Long.class, userIdArr);
|
||||||
}
|
}
|
||||||
if (userIds == null || userIds.isEmpty()) {
|
if (userIds == null || userIds.isEmpty()) {
|
||||||
throw new SystemModularException(MessageExceptionEnum.ERROR_RECEIVE_USER_IDS, "传入接收用户id字符串不合法:" + receiveUserIds);
|
throw new MessageException(MessageExceptionEnum.ERROR_RECEIVE_USER_IDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<Long> userIdSet = new HashSet<>(userIds);
|
Set<Long> userIdSet = new HashSet<>(userIds);
|
||||||
|
@ -164,8 +165,11 @@ public class MessageDbServiceImpl implements MessageApi {
|
||||||
@Override
|
@Override
|
||||||
public List<MessageResponse> queryList(MessageParam messageParam) {
|
public List<MessageResponse> queryList(MessageParam messageParam) {
|
||||||
List<SysMessage> messageList = sysMessageService.list(messageParam);
|
List<SysMessage> messageList = sysMessageService.list(messageParam);
|
||||||
List<MessageResponse> resultList = new ArrayList<>();
|
List<MessageResponse> resultList = messageList.stream().map(msg -> {
|
||||||
BeanUtil.copyProperties(messageList, resultList);
|
MessageResponse response = new MessageResponse();
|
||||||
|
BeanUtil.copyProperties(msg, response);
|
||||||
|
return response;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
return resultList;
|
return resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue