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

@@ -29,6 +29,14 @@ public class NotificationController {
.collect(Collectors.toList());
}
@GetMapping("/unread-count")
public UnreadCount unreadCount(Authentication auth) {
long count = notificationService.countUnread(auth.getName());
UnreadCount uc = new UnreadCount();
uc.setCount(count);
return uc;
}
@PostMapping("/read")
public void markRead(@RequestBody MarkReadRequest req, Authentication auth) {
notificationService.markRead(auth.getName(), req.getIds());
@@ -115,4 +123,9 @@ public class NotificationController {
private String username;
private String avatar;
}
@Data
private static class UnreadCount {
private long count;
}
}