feat: add paginated notification API and frontend support

This commit is contained in:
Tim
2025-08-19 17:07:27 +08:00
parent 35bcd2cdc2
commit df7ca77652
7 changed files with 256 additions and 185 deletions

View File

@@ -23,9 +23,17 @@ public class NotificationController {
private final NotificationMapper notificationMapper;
@GetMapping
public List<NotificationDto> list(@RequestParam(value = "read", required = false) Boolean read,
public List<NotificationDto> list(@RequestParam(value = "page", defaultValue = "0") int page,
Authentication auth) {
return notificationService.listNotifications(auth.getName(), read).stream()
return notificationService.listNotifications(auth.getName(), null, page).stream()
.map(notificationMapper::toDto)
.collect(Collectors.toList());
}
@GetMapping("/unread")
public List<NotificationDto> listUnread(@RequestParam(value = "page", defaultValue = "0") int page,
Authentication auth) {
return notificationService.listNotifications(auth.getName(), false, page).stream()
.map(notificationMapper::toDto)
.collect(Collectors.toList());
}