Merge branch 'dev/dev_xp' into dev/3.1_release_merge

This commit is contained in:
2025-11-18 17:45:53 +08:00

View File

@@ -64,7 +64,7 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
.collect(Collectors.toMap(
map -> (String) map.get("type"),
map -> Objects.isNull(map.get("count")) ? 0L : (Long) map.get("count")));
msgTypeCount.put("system", getUnreadSystemNotification());
msgTypeCount.put("system", getUnreadSystemNotification(accountId));
msgTypeCount.put("newPosted", getNewPostedCount(accountId));
log.info(msgTypeCount.toString());
// 整理数据 加上系统消息未读数
@@ -194,7 +194,7 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
count = getUnreadCountByType(type, receiverId);
} else {
// 系统未读消息
count = getUnreadSystemNotification();
count = getUnreadSystemNotification(receiverId);
}
if (type.equals("follow")) {
HashMap<String, Object> followee = new HashMap<>();
@@ -245,21 +245,21 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
return baseMapper.selectCount(queryWrapper);
}
private Long getUnreadSystemNotification() {
Long accountId = UserContext.getUserHolder().getId();
private Long getUnreadSystemNotification(Long receiverId) {
// Long accountId = UserContext.getUserHolder().getId();
// 计算总的系统通知数量
QueryWrapper<Notification> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(Notification::getType, "system")
.and(wrapper -> wrapper
.isNull(Notification::getReceiverId)
.or()
.eq(Notification::getReceiverId, accountId)
.eq(Notification::getReceiverId, receiverId)
);
Long totalSysCount = baseMapper.selectCount(queryWrapper);
// 计算单个用户读了多少条系统数据
QueryWrapper<SysNotificationReadStatus> wrapper = new QueryWrapper<>();
wrapper.eq("account_id", accountId);
wrapper.eq("account_id", receiverId);
Long readCount = sysNotificationReadStatusMapper.selectCount(wrapper);
// 计算差
@@ -416,7 +416,7 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
notification.setIsRead(0);
notification.setCreateTime(LocalDateTime.now());
save(notification);
// 这里推送消息是在接受到视频生成结束后发生的所以UserContext中没有用户信息
pushMessage("system", userId);
}