diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/NotificationController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/NotificationController.java index eb42802d1d..6126e41175 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/NotificationController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/NotificationController.java @@ -50,7 +50,7 @@ public class NotificationController { @Operation(summary = "消息中心-获取未读的消息") @CheckOwner(resourceId = "#projectId", resourceType = "project") public Integer getUnRead(@PathVariable(value = "projectId") String projectId) { - return notificationService.getUnRead(projectId); + return notificationService.getUnRead(projectId, SessionUtils.getUserId()); } @PostMapping(value = "/count") diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/NotificationService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/NotificationService.java index e283f0a4c6..3a0ef704ef 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/NotificationService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/NotificationService.java @@ -107,12 +107,12 @@ public class NotificationService { } - public Integer getUnRead(String projectId) { + public Integer getUnRead(String projectId, String userId) { NotificationExample example = new NotificationExample(); if (StringUtils.isBlank(projectId)) { return 0; } - example.createCriteria().andProjectIdEqualTo(projectId).andStatusEqualTo(NotificationConstants.Status.UNREAD.name()); + example.createCriteria().andProjectIdEqualTo(projectId).andStatusEqualTo(NotificationConstants.Status.UNREAD.name()).andReceiverEqualTo(userId); return (int) notificationMapper.countByExample(example); } }