Revert "feat: add paginated notification APIs and frontend support"

This reverts commit c344b5b4ae.
This commit is contained in:
tim
2025-08-19 19:37:59 +08:00
parent ac3c7b7bec
commit 02be045f55
5 changed files with 204 additions and 340 deletions

View File

@@ -180,21 +180,15 @@ public class NotificationService {
userRepository.save(user);
}
public List<Notification> listNotifications(String username, Boolean read, int page, int size) {
public List<Notification> listNotifications(String username, Boolean read) {
User user = userRepository.findByUsername(username)
.orElseThrow(() -> new com.openisle.exception.NotFoundException("User not found"));
Set<NotificationType> disabled = user.getDisabledNotificationTypes();
org.springframework.data.domain.Pageable pageable =
org.springframework.data.domain.PageRequest.of(page, size);
List<Notification> list;
if (read == null) {
list = notificationRepository
.findByUserOrderByCreatedAtDesc(user, pageable)
.getContent();
list = notificationRepository.findByUserOrderByCreatedAtDesc(user);
} else {
list = notificationRepository
.findByUserAndReadOrderByCreatedAtDesc(user, read, pageable)
.getContent();
list = notificationRepository.findByUserAndReadOrderByCreatedAtDesc(user, read);
}
return list.stream().filter(n -> !disabled.contains(n.getType())).collect(Collectors.toList());
}