mirror of https://gitee.com/stylefeng/roses
【7.0.4】更新message提示
parent
82a389adab
commit
8cd14e900e
|
@ -41,7 +41,7 @@ public enum MessageExceptionEnum implements AbstractExceptionEnum {
|
|||
/**
|
||||
* 发送系统消息时,传入的参数中receiveUserIds不合法
|
||||
*/
|
||||
ERROR_RECEIVE_USER_IDS(RuleConstants.BUSINESS_ERROR_TYPE_CODE + MessageConstants.MESSAGE_EXCEPTION_STEP_CODE + "01", "接收用户id字符串不合法!"),
|
||||
ERROR_RECEIVE_USER_IDS(RuleConstants.BUSINESS_ERROR_TYPE_CODE + MessageConstants.MESSAGE_EXCEPTION_STEP_CODE + "01", "接收用户id字符串不合法!系统无人可接收消息!"),
|
||||
|
||||
/**
|
||||
* 消息记录不存在
|
||||
|
|
|
@ -38,8 +38,8 @@ 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.response.MessageResponse;
|
||||
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;
|
||||
|
@ -76,11 +76,13 @@ public class MessageDbServiceImpl implements MessageApi {
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void sendMessage(MessageSendRequest messageSendRequest) {
|
||||
|
||||
String receiveUserIds = messageSendRequest.getReceiveUserIds();
|
||||
// 获取当前登录人
|
||||
LoginUser loginUser = LoginContext.me().getLoginUser();
|
||||
|
||||
List<SysMessage> sendMsgList = new ArrayList<>();
|
||||
List<Long> userIds;
|
||||
|
||||
// 发送所有人判断
|
||||
if (MessageConstants.RECEIVE_ALL_USER_FLAG.equals(receiveUserIds)) {
|
||||
// 查询所有用户
|
||||
|
@ -89,6 +91,8 @@ public class MessageDbServiceImpl implements MessageApi {
|
|||
String[] userIdArr = receiveUserIds.split(",");
|
||||
userIds = Convert.toList(Long.class, userIdArr);
|
||||
}
|
||||
|
||||
// 无人可发,不发送
|
||||
if (userIds == null || userIds.isEmpty()) {
|
||||
throw new MessageException(MessageExceptionEnum.ERROR_RECEIVE_USER_IDS);
|
||||
}
|
||||
|
|
|
@ -36,10 +36,10 @@ import cn.stylefeng.roses.kernel.message.api.pojo.request.MessageSendRequest;
|
|||
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
||||
import cn.stylefeng.roses.kernel.system.api.exception.SystemModularException;
|
||||
import cn.stylefeng.roses.kernel.system.api.exception.enums.notice.NoticeExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.notice.SysNoticeRequest;
|
||||
import cn.stylefeng.roses.kernel.system.modular.notice.entity.SysNotice;
|
||||
import cn.stylefeng.roses.kernel.system.modular.notice.mapper.SysNoticeMapper;
|
||||
import cn.stylefeng.roses.kernel.system.modular.notice.service.SysNoticeService;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.notice.SysNoticeRequest;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
@ -198,7 +198,12 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
|||
message.setBusinessId(sysNotice.getNoticeId());
|
||||
message.setMessageSendTime(new Date());
|
||||
|
||||
messageApi.sendMessage(message);
|
||||
try {
|
||||
messageApi.sendMessage(message);
|
||||
} catch (Exception exception) {
|
||||
// 发送失败打印异常
|
||||
log.error("发送消息失败:", exception);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue