feat: show unread message count

This commit is contained in:
Tim
2025-07-07 19:26:38 +08:00
parent 60b789759a
commit 87d0441ef6
7 changed files with 94 additions and 0 deletions

View File

@@ -45,4 +45,10 @@ public class NotificationService {
}
notificationRepository.saveAll(notifs);
}
public long countUnread(String username) {
User user = userRepository.findByUsername(username)
.orElseThrow(() -> new IllegalArgumentException("User not found"));
return notificationRepository.countByUserAndRead(user, false);
}
}