Added API for getting notifications by compnayId and userId.
This commit is contained in:
@@ -61,6 +61,9 @@ public class NotificationDao {
|
||||
@Autowired
|
||||
private ApplicationService applicationService;
|
||||
|
||||
@Autowired
|
||||
private UserDao userDao;
|
||||
|
||||
public NotificationResponse sendNotification(NotificationReq notificationReq) {
|
||||
|
||||
// Ensure userId is properly set in notificationReq if not already
|
||||
@@ -249,4 +252,20 @@ public class NotificationDao {
|
||||
notificationEntity.setIsDeleted(true);
|
||||
notificationRepository.save(notificationEntity);
|
||||
}
|
||||
|
||||
public List<NotificationResponse> getNotificationByCompanyIdAndUserId(Long userId, Long companyId) {
|
||||
|
||||
companyDao.validateCompany(companyId);
|
||||
userDao.validateUser(userId);
|
||||
|
||||
UserWithCompanyEntity userWithCompanyData = userWithCompanyRepository.findByUserIdAndCompanyIdAndIsDeletedFalseForNotification(userId, companyId);
|
||||
if (userWithCompanyData == null) {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, GepafinConstant.USER_MUST_BE_ASSOCIATED_WITH_COMPANY);
|
||||
}
|
||||
|
||||
List<NotificationEntity> notifications = notificationRepository.findByUserWithCompanyIdAndUserIdAndIsDeletedFalse(userWithCompanyData.getId(),
|
||||
userWithCompanyData.getUserId());
|
||||
return notifications.stream().map(this::convertNotificationEntityToNotificationResponse).toList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user