消息通知系统-一键已读;反复点赞、关注及取消 数据存储处理,

This commit is contained in:
2024-08-16 10:32:15 +08:00
parent 085dac0630
commit ac28ba233c
5 changed files with 54 additions and 4 deletions

View File

@@ -64,7 +64,6 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
return msgTypeCount;
}
// 获取历史消息 可指定消息类型 分页查询
@Override
public PageBaseResponse<NotificationVO> getHistoryNotification(GetNotificationVO getNotificationVO) {
@@ -127,14 +126,14 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
// 消息推送 只需要返回当前操作类型和该操作未读消息数量
public void pushMessage(String type, Long senderId) {
public void pushMessage(String type, Long receiverId) {
// 推送消息到前端
ArrayList<Map<String, Object>> resp = new ArrayList<>();
HashMap<String, Object> data = new HashMap<>();
Long count;
if (!type.equals("system")) {
// 个人未读消息
count = getUnreadCountByType(type, senderId);
count = getUnreadCountByType(type, receiverId);
} else {
// 系统未读消息
count = getUnreadSystemNotification();
@@ -227,7 +226,22 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
}
}
// todo 全部已读
// 一键已读
public void setReadAll(String type){
Long accountId = UserContext.getUserHolder().getId();
// 指定某个用户的某种类型的数据,将未读数据全部已读
if (!type.equals("system")){
// 个人消息已读
baseMapper.setPersonalNotificationAllRead(type, accountId, LocalDateTime.now());
}else {
// 系统消息已读
// 1、先确定当前用户未读的系统消息有哪些
List<Long> unreadSysNotificationIds = baseMapper.getUnreadSysNotification(accountId);
// 2、将未读的设为已读
if (!unreadSysNotificationIds.isEmpty()) setReadStatusSystem(unreadSysNotificationIds);
}
pushMessage(type, accountId);
}
// 发布系统消息
public void publishSystemNotification(PublishSysNotificationVO message) {