Updated Apis, Code, Configurations for Notification.

This commit is contained in:
piyushkag
2024-12-24 16:07:42 +05:30
parent db48cf9502
commit 96b57519fb
23 changed files with 278 additions and 201 deletions

View File

@@ -8,13 +8,13 @@ import net.gepafin.tendermanagement.model.response.NotificationResponse;
import java.util.List;
public interface NotificationService {
NotificationResponse sendNotification(Long userId, NotificationReq notificationReq);
NotificationResponse sendNotification(Long userId, NotificationReq notificationReq, Long companyId);
public NotificationResponse getNotificationById(HttpServletRequest servletRequest,Long id);
public NotificationResponse getNotificationById(HttpServletRequest servletRequest, Long id);
public List<NotificationResponse> getNotificationByUserId(HttpServletRequest servletRequest, Long userId, Long companyId, List<NotificationEnum> statuses);
public NotificationResponse updateNotificationStatus(HttpServletRequest request,Long id,NotificationEnum status);
public NotificationResponse updateNotificationStatus(HttpServletRequest request, Long id, NotificationEnum status);
public void deleteNotification(HttpServletRequest request, Long id);
}

View File

@@ -12,6 +12,8 @@ import org.springframework.stereotype.Service;
import java.util.List;
import static org.hibernate.internal.util.collections.CollectionHelper.listOf;
@Service
@Slf4j
public class NotificationServiceImpl implements NotificationService {
@@ -20,33 +22,37 @@ public class NotificationServiceImpl implements NotificationService {
private NotificationDao notificationDao;
@Override
public NotificationResponse sendNotification(Long userId, NotificationReq notificationReq) {
public NotificationResponse sendNotification(Long userId, NotificationReq notificationReq, Long companyId) {
log.info("Sending notification to user {} with content: {}", userId, notificationReq.getMessage());
notificationReq.setUserId(userId);
NotificationResponse notificationResponse = notificationDao.sendNotification(notificationReq);
return notificationResponse;
notificationReq.setCompanyIds(listOf(companyId));
return notificationDao.sendNotification(notificationReq);
}
@Override
public NotificationResponse getNotificationById(HttpServletRequest servletRequest, Long id) {
return notificationDao.getNotificationById(id);
}
@Override
public List<NotificationResponse> getNotificationByUserId(HttpServletRequest servletRequest, Long userId, Long companyId, List<NotificationEnum> statuses) {
return notificationDao.getNotificationByUserId(userId,companyId,statuses);
return notificationDao.getNotificationByUserId(userId, companyId, statuses);
}
@Override
public NotificationResponse updateNotificationStatus(HttpServletRequest request, Long id,NotificationEnum status) {
return notificationDao.updateNotificationStatus(id,status);
public NotificationResponse updateNotificationStatus(HttpServletRequest request, Long id, NotificationEnum status) {
return notificationDao.updateNotificationStatus(id, status);
}
@Override
public void deleteNotification(HttpServletRequest request, Long id) {
notificationDao.deleteNotification(id);
return;
notificationDao.deleteNotification(id);
return;
}
}