diff --git a/fineract-provider/src/main/java/org/apache/fineract/notification/domain/NotificationMapperRepository.java b/fineract-provider/src/main/java/org/apache/fineract/notification/domain/NotificationMapperRepository.java index cbf99e37f4b..467baa67f05 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/notification/domain/NotificationMapperRepository.java +++ b/fineract-provider/src/main/java/org/apache/fineract/notification/domain/NotificationMapperRepository.java @@ -47,14 +47,18 @@ select case when count(nm) > 0 then true else false end """) void markUnreadNotificationsAsRead(@Param("appUserId") Long appUserId); - // 1. Method for fetching ALL notifications (No read status filter) @Query(value = """ select new org.apache.fineract.notification.data.NotificationData( - n.id, n.objectType, n.objectIdentifier, n.actorId, n.action, - n.notificationContent, n.isSystemGenerated, nm.createdAt + nm.notification.id, + nm.notification.objectType, + nm.notification.objectIdentifier, + nm.notification.actorId, + nm.notification.action, + nm.notification.notificationContent, + nm.notification.isSystemGenerated, + nm.createdAt ) from NotificationMapper nm - join nm.notification n where nm.userId.id = :appUserId """, countQuery = """ select count(nm) @@ -63,22 +67,25 @@ select count(nm) """) Page findNotificationDataByUserId(@Param("appUserId") Long appUserId, Pageable pageable); - // 2. Method for fetching with a SPECIFIC read status (e.g., Unread only) @Query(value = """ select new org.apache.fineract.notification.data.NotificationData( - n.id, n.objectType, n.objectIdentifier, n.actorId, n.action, - n.notificationContent, n.isSystemGenerated, nm.createdAt + nm.notification.id, + nm.notification.objectType, + nm.notification.objectIdentifier, + nm.notification.actorId, + nm.notification.action, + nm.notification.notificationContent, + nm.notification.isSystemGenerated, + nm.createdAt ) from NotificationMapper nm - join nm.notification n where nm.userId.id = :appUserId - and nm.isRead = :isRead + and nm.isRead = false """, countQuery = """ select count(nm) from NotificationMapper nm where nm.userId.id = :appUserId - and nm.isRead = :isRead + and nm.isRead = false """) - Page findNotificationDataByUserIdAndReadStatus(@Param("appUserId") Long appUserId, @Param("isRead") Boolean isRead, - Pageable pageable); + Page findUnreadNotificationDataByUserId(@Param("appUserId") Long appUserId, Pageable pageable); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/notification/service/NotificationReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/notification/service/NotificationReadPlatformServiceImpl.java index ea66004b160..e5a3c5d4553 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/notification/service/NotificationReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/notification/service/NotificationReadPlatformServiceImpl.java @@ -96,7 +96,7 @@ public Page getAllUnreadNotifications(final SearchParameters s final Long appUserId = context.authenticatedUser().getId(); final Pageable pageable = toPageable(searchParameters); final org.springframework.data.domain.Page springPage = this.notificationMapperRepository - .findNotificationDataByUserIdAndReadStatus(appUserId, false, pageable); + .findUnreadNotificationDataByUserId(appUserId, pageable); return toFineractPage(springPage); }