diff --git a/src/main/java/com/ai/da/service/impl/MessageCenterServiceImpl.java b/src/main/java/com/ai/da/service/impl/MessageCenterServiceImpl.java index b1652140..b7f40399 100644 --- a/src/main/java/com/ai/da/service/impl/MessageCenterServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/MessageCenterServiceImpl.java @@ -188,7 +188,7 @@ public class MessageCenterServiceImpl extends ServiceImpl> resp = new ArrayList<>(); HashMap data = new HashMap<>(); Long count; - if (!type.equals("system") || Objects.nonNull(receiverId)) { + if (!type.equals("system")) { // 个人未读消息 count = getUnreadCountByType(type, receiverId); } else { @@ -245,14 +245,20 @@ public class MessageCenterServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("type", "system"); + queryWrapper.lambda().eq(Notification::getType, "system") + .and(wrapper -> wrapper + .isNull(Notification::getReceiverId) + .or() + .eq(Notification::getReceiverId, accountId) + ); Long totalSysCount = baseMapper.selectCount(queryWrapper); // 计算单个用户读了多少条系统数据 QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq("account_id", UserContext.getUserHolder().getId()); + wrapper.eq("account_id", accountId); Long readCount = sysNotificationReadStatusMapper.selectCount(wrapper); // 计算差