feat: support paginated notifications

This commit is contained in:
Tim
2025-08-19 18:45:56 +08:00
parent 1a12bec7b1
commit a64fd71bbe
7 changed files with 255 additions and 186 deletions

View File

@@ -23,9 +23,19 @@ 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,
@RequestParam(value = "size", defaultValue = "30") int size,
Authentication auth) {
return notificationService.listNotifications(auth.getName(), read).stream()
return notificationService.listNotifications(auth.getName(), 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.listUnreadNotifications(auth.getName(), page, size).stream()
.map(notificationMapper::toDto)
.collect(Collectors.toList());
}