BUGFIX: 获取系统通知未读数
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user