feat: add paginated notification APIs and frontend support

This commit is contained in:
Tim
2025-08-19 19:34:13 +08:00
parent 3f2829cd37
commit c344b5b4ae
5 changed files with 341 additions and 205 deletions

View File

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