mirror of https://gitee.com/stylefeng/roses
【8.1.0】【message】【个人消息】更新消息的通用发送接口
parent
44399b85fa
commit
9f284f1867
|
@ -0,0 +1,57 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.message.factory;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.stylefeng.roses.kernel.sys.api.enums.message.ReadFlagEnum;
|
||||
import cn.stylefeng.roses.kernel.sys.api.pojo.message.MessageSendDTO;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.message.entity.SysMessage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 创建我的消息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2024/1/14 22:24
|
||||
*/
|
||||
public class MessageFactory {
|
||||
|
||||
/**
|
||||
* 批量创建个人消息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2024/1/14 22:24
|
||||
*/
|
||||
public static List<SysMessage> createBatchMessage(MessageSendDTO messageSendDTO) {
|
||||
|
||||
List<SysMessage> sysMessages = new ArrayList<>();
|
||||
|
||||
if (ObjectUtil.isEmpty(messageSendDTO)) {
|
||||
return sysMessages;
|
||||
}
|
||||
|
||||
Set<Long> userIdList = messageSendDTO.getUserIdList();
|
||||
if (ObjectUtil.isEmpty(userIdList)) {
|
||||
return sysMessages;
|
||||
}
|
||||
|
||||
for (Long userId : userIdList) {
|
||||
SysMessage sysMessage = new SysMessage();
|
||||
sysMessage.setSendUserId(messageSendDTO.getSendUserId());
|
||||
sysMessage.setReceiveUserId(userId);
|
||||
sysMessage.setMessageTitle(messageSendDTO.getMessageTitle());
|
||||
sysMessage.setMessageContent(messageSendDTO.getMessageContent());
|
||||
sysMessage.setMessageType(messageSendDTO.getMessageType());
|
||||
sysMessage.setMessageUrl(messageSendDTO.getMessageUrl());
|
||||
sysMessage.setPriorityLevel(messageSendDTO.getPriorityLevel());
|
||||
sysMessage.setBusinessId(messageSendDTO.getBusinessId());
|
||||
sysMessage.setBusinessType(messageSendDTO.getBusinessType());
|
||||
sysMessage.setReadFlag(ReadFlagEnum.NO_READ.getCode());
|
||||
sysMessages.add(sysMessage);
|
||||
}
|
||||
|
||||
return sysMessages;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.message.mapper;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.mp.injector.CustomBaseMapper;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.message.entity.SysMessage;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.message.pojo.request.SysMessageRequest;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.message.pojo.response.SysMessageVo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
@ -15,7 +15,7 @@ import java.util.List;
|
|||
* @author fengshuonan
|
||||
* @since 2024/01/12 17:31
|
||||
*/
|
||||
public interface SysMessageMapper extends BaseMapper<SysMessage> {
|
||||
public interface SysMessageMapper extends CustomBaseMapper<SysMessage> {
|
||||
|
||||
/**
|
||||
* 获取自定义查询列表
|
||||
|
@ -23,6 +23,6 @@ public interface SysMessageMapper extends BaseMapper<SysMessage> {
|
|||
* @author fengshuonan
|
||||
* @since 2024/01/12 17:31
|
||||
*/
|
||||
List<SysMessageVo> customFindList(@Param("page") Page page, @Param("param")SysMessageRequest request);
|
||||
List<SysMessageVo> customFindList(@Param("page") Page page, @Param("param") SysMessageRequest request);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.message.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.sys.api.MessagePublishApi;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.message.entity.SysMessage;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.message.pojo.request.SysMessageRequest;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
@ -11,7 +12,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
* @author fengshuonan
|
||||
* @since 2024/01/12 17:31
|
||||
*/
|
||||
public interface SysMessageService extends IService<SysMessage> {
|
||||
public interface SysMessageService extends IService<SysMessage>, MessagePublishApi {
|
||||
|
||||
/**
|
||||
* 删除系统消息
|
||||
|
|
|
@ -8,8 +8,11 @@ import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
|||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import cn.stylefeng.roses.kernel.sys.api.enums.message.ReadFlagEnum;
|
||||
import cn.stylefeng.roses.kernel.sys.api.pojo.message.MessageRetractDTO;
|
||||
import cn.stylefeng.roses.kernel.sys.api.pojo.message.MessageSendDTO;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.message.entity.SysMessage;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.message.enums.SysMessageExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.message.factory.MessageFactory;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.message.mapper.SysMessageMapper;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.message.pojo.request.SysMessageRequest;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.message.service.SysMessageService;
|
||||
|
@ -19,6 +22,8 @@ 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;
|
||||
|
||||
/**
|
||||
* 系统消息业务实现层
|
||||
*
|
||||
|
@ -92,6 +97,23 @@ public class SysMessageServiceImpl extends ServiceImpl<SysMessageMapper, SysMess
|
|||
this.update(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchSendMessage(MessageSendDTO messageSendDTO) {
|
||||
// 获取发送到指定哪些用户上,批量创建消息
|
||||
List<SysMessage> batchMessage = MessageFactory.createBatchMessage(messageSendDTO);
|
||||
if (ObjectUtil.isNotEmpty(batchMessage)) {
|
||||
this.getBaseMapper().insertBatchSomeColumn(batchMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchRetractMessage(MessageRetractDTO messageRetractDTO) {
|
||||
LambdaUpdateWrapper<SysMessage> wrapper = new LambdaUpdateWrapper<>();
|
||||
wrapper.eq(SysMessage::getBusinessType, messageRetractDTO.getBusinessType());
|
||||
wrapper.eq(SysMessage::getBusinessId, messageRetractDTO.getBusinessId());
|
||||
this.remove(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取信息
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue