feat: 通知公告临时提交
通知公告临时提交
This commit is contained in:
@@ -33,8 +33,8 @@ public interface NoticeConverter{
|
||||
Page<NoticeVO> toPageVo(Page<NoticeBO> noticePage);
|
||||
|
||||
@Mappings({
|
||||
@Mapping(target = "noticeTypeLabel", expression = "java(com.youlai.boot.common.base.IBaseEnum.getLabelByValue(bo.getNoticeType(), com.youlai.boot.common.enums.NoticeTypeEnum.class))")
|
||||
@Mapping(target = "noticeTypeLabel", expression = "java(com.youlai.boot.common.base.IBaseEnum.getLabelByValue(bo.getNoticeType(), com.youlai.boot.common.enums.NoticeWayEnum.class))")
|
||||
})
|
||||
NoticeVO toPageVo(NoticeBO bo);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,12 +22,12 @@ public class MessageHandler {
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
* 如果后面有多种消息发送方式,可以设置MessageDTO中的noticeWay,调用不同的消息发送方式,实现消息多种发送方式
|
||||
* @param messageDTO 消息载体
|
||||
*/
|
||||
public void sendMessage(MessageDTO messageDTO) {
|
||||
messageServices.forEach(messageService -> {
|
||||
if (messageService.check(messageDTO.getMessageType())) {
|
||||
if (messageService.check(messageDTO.getNoticeWay())) {
|
||||
messageService.sendMessage(messageDTO);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.youlai.boot.system.model.dto;
|
||||
|
||||
import com.youlai.boot.common.enums.NoticeTypeEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* WebSocket 消息体
|
||||
* 系统消息体
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@@ -22,4 +23,9 @@ public class ChatMessage {
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
private NoticeTypeEnum noticeType;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.youlai.boot.system.model.dto;
|
||||
|
||||
import com.youlai.boot.common.enums.MessageTypeEnum;
|
||||
import com.youlai.boot.common.enums.NoticeWayEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -25,6 +25,6 @@ public class MessageDTO {
|
||||
@Schema(description = "接收者")
|
||||
private List<String> receiver;
|
||||
|
||||
@Schema(description = "消息类型")
|
||||
private MessageTypeEnum messageType;
|
||||
@Schema(description = "通知方式")
|
||||
private NoticeWayEnum noticeWay;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,22 @@
|
||||
package com.youlai.boot.system.model.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户公告状态VO
|
||||
*
|
||||
* @auther Theo
|
||||
* @author Theo
|
||||
* @since 2024-08-28 16:56
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "用户公告状态VO")
|
||||
public class NoticeStatusVO {
|
||||
|
||||
@Schema(description = "公告ID")
|
||||
private Long noticeId;
|
||||
|
||||
@Schema(description = "是否已读")
|
||||
private Boolean read;
|
||||
|
||||
}
|
||||
|
||||
@@ -8,8 +8,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.boot.common.constant.SymbolConstant;
|
||||
import com.youlai.boot.common.enums.MessageTypeEnum;
|
||||
import com.youlai.boot.common.util.CommonUtil;
|
||||
import com.youlai.boot.common.enums.NoticeWayEnum;
|
||||
import com.youlai.boot.core.security.util.SecurityUtils;
|
||||
import com.youlai.boot.system.converter.NoticeConverter;
|
||||
import com.youlai.boot.system.handler.MessageHandler;
|
||||
@@ -180,7 +179,7 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
|
||||
usernameList = userList.stream().map(User::getUsername).collect(Collectors.toList());
|
||||
}
|
||||
MessageDTO message = new MessageDTO();
|
||||
message.setMessageType(MessageTypeEnum.WEBSOCKET);
|
||||
message.setNoticeWay(NoticeWayEnum.WEBSOCKET);
|
||||
message.setReceiver(usernameList);
|
||||
message.setContent(getNoticeContent(notice));
|
||||
message.setSender(SecurityUtils.getUsername());
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.youlai.boot.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.boot.common.result.Result;
|
||||
import com.youlai.boot.system.mapper.NoticeStatusMapper;
|
||||
import com.youlai.boot.system.model.entity.NoticeStatus;
|
||||
import com.youlai.boot.system.model.vo.NoticeStatusVO;
|
||||
import com.youlai.boot.system.service.NoticeService;
|
||||
import com.youlai.boot.system.service.NoticeStatusService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -21,9 +23,13 @@ import java.util.List;
|
||||
@RequiredArgsConstructor
|
||||
public class NoticeStatusServiceImpl extends ServiceImpl<NoticeStatusMapper, NoticeStatus> implements NoticeStatusService {
|
||||
|
||||
private final NoticeService noticeService;
|
||||
|
||||
@Override
|
||||
public List<NoticeStatusVO> listNotices(Integer count) {
|
||||
|
||||
LambdaQueryWrapper<NoticeStatus> queryWrapper = new LambdaQueryWrapper<>();
|
||||
//获取当前用户
|
||||
queryWrapper.eq(NoticeStatus::getUserId, 1L);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user