Merge pull request #141 from Kitzanos/feature/GEPAFINBE-105
GEPAFINBE-105 (Manage Notification)
This commit is contained in:
@@ -23,8 +23,7 @@ public class TendermanagementApplication {
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**").allowedOrigins("http://localhost:3000")
|
||||
.allowedMethods("GET", "POST", "PUT", "DELETE", "HEAD").allowCredentials(true);
|
||||
registry.addMapping("/**").allowedOrigins("http://localhost:3000").allowedMethods("GET", "POST", "PUT", "DELETE", "HEAD").allowCredentials(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +109,7 @@ public class SecurityConfig {
|
||||
.requestMatchers("/v1/api-docs/**").permitAll() // API docs
|
||||
.requestMatchers("/v1/user/reset-password/initiate").permitAll()
|
||||
.requestMatchers("/v1/user/reset-password").permitAll()
|
||||
.requestMatchers("/wss/**").permitAll() // if this is not running use this /gs-guide-websocket
|
||||
.anyRequest().authenticated())
|
||||
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED))
|
||||
.exceptionHandling(exceptionHandling -> exceptionHandling
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package net.gepafin.tendermanagement.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
|
||||
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
|
||||
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
|
||||
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSocketMessageBroker
|
||||
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
|
||||
|
||||
@Value("${spring.rabbitmq.host}")
|
||||
private String relayHost;
|
||||
|
||||
@Value("${spring.rabbitmq.port}")
|
||||
private int relayPort;
|
||||
|
||||
@Value("${spring.rabbitmq.username}")
|
||||
private String clientUserName;
|
||||
|
||||
@Value("${spring.rabbitmq.password}")
|
||||
private String clientPassword;
|
||||
|
||||
@Override
|
||||
public void configureMessageBroker(MessageBrokerRegistry config) {
|
||||
|
||||
config.enableStompBrokerRelay("/topic").setRelayHost(relayHost).setRelayPort(relayPort).setClientLogin(clientUserName).setClientPasscode(clientPassword);
|
||||
config.setApplicationDestinationPrefixes("/app");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerStompEndpoints(StompEndpointRegistry registry) {
|
||||
|
||||
registry.addEndpoint("/wss").setAllowedOrigins("http://localhost:3000").withSockJS();
|
||||
}
|
||||
}
|
||||
@@ -342,5 +342,16 @@ public class GepafinConstant {
|
||||
public static final String DOCUMENT_UPLOADING_IN_PROGRESS = "document.uploading.is.in.progress";
|
||||
public static final String ASYNC_DOCUMENT_UPLOAD_NAME = "AsyncDocumentUpload-";
|
||||
public static final String All_DOCUMENT_CHECKED_AND_ONE_CHECKLIST_CHECKED="all.document.checked.and.one.checklist.checked";
|
||||
|
||||
//Notification
|
||||
public static final String COMMON_SINGLE_CHANNEL_PREFIX = "/topic/notifications_user_";
|
||||
public static final String COMPANY_PREFIX = "_company_";
|
||||
public static final String NOTIFICATION_SENT_SUCCESSFULLY = "notification.sent.successfully";
|
||||
public static final String NOTIFICATION_FETCHED_SUCCESSFULLY= "notification.fetched.successfully";
|
||||
public static final String NOTIFICATION_NOT_FOUND= "notification.not.found";
|
||||
public static final String NOTIFICATION_ALREADY_IN_THAT_STATE="notification.already.in.state";
|
||||
public static final String NOTIFICATION_DELETED_SUCCESSFULLY="notification.deleted.successfully";
|
||||
public static final String NOTIFICATION_UPDATED_SUCCESSFULLY="notification.updated.successfully";
|
||||
public static final String USER_WITH_COMPANY_NOT_FOUND = "user.with.company.not.found";
|
||||
}
|
||||
|
||||
|
||||
@@ -113,6 +113,12 @@ public class ApplicationAmendmentRequestDao {
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
@Autowired
|
||||
private NotificationDao notificationDao;
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
public ApplicationAmendmentRequestResponse getApplicationDataForAmendment(Long applicationEvaluationId) {
|
||||
log.info("Fetching the application data for the Amendment process {}", applicationEvaluationId);
|
||||
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(applicationEvaluationId);
|
||||
@@ -328,6 +334,10 @@ public class ApplicationAmendmentRequestDao {
|
||||
assignedApplicationsEntity.setStatus(AssignedApplicationEnum.SOCCORSO.getValue());
|
||||
assignedApplicationsRepository.save(assignedApplicationsEntity);
|
||||
|
||||
Map<String, String> placeHolders = notificationDao.sendNotificationToBeneficiary(applicationEntity, NotificationTypeEnum.AMENDMENT_CREATION);
|
||||
|
||||
notificationDao.sendNotificationToInstructor(placeHolders,applicationAmendmentRequestEntity.getApplicationEvaluationEntity(),NotificationTypeEnum.AMENDMENT_CREATION);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Update Assigned Application" operation. **/
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldAssignedApplication).newData(assignedApplicationsEntity).build());
|
||||
}
|
||||
@@ -955,8 +965,7 @@ public class ApplicationAmendmentRequestDao {
|
||||
ApplicationAmendmentRequestEntity existingApplicationAmendment = validateApplicationAmendmentRequest(id);
|
||||
//cloned entity for old data and versioning
|
||||
ApplicationAmendmentRequestEntity oldApplicationAmendmentEntity = Utils.getClonedEntityForData(existingApplicationAmendment);
|
||||
|
||||
List<ApplicationAmendmentRequestEntity> amendmentRequestList = applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndIsDeletedFalse(
|
||||
List<ApplicationAmendmentRequestEntity> amendmentRequestList = applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndIsDeletedFalse(
|
||||
existingApplicationAmendment.getApplicationEvaluationEntity().getId()
|
||||
);
|
||||
|
||||
@@ -1001,6 +1010,11 @@ public class ApplicationAmendmentRequestDao {
|
||||
AssignedApplicationsEntity oldAssignedApplicationData = Utils.getClonedEntityForData(assignedApplicationsEntity);
|
||||
assignedApplicationsEntity = assignedApplicationsRepository.save(existingApplicationAmendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity());
|
||||
|
||||
|
||||
Map<String, String> placeHolders = notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.AMENDMENT_CLOSED);
|
||||
|
||||
notificationDao.sendNotificationToInstructor(placeHolders,existingApplicationAmendment.getApplicationEvaluationEntity(),NotificationTypeEnum.AMENDMENT_CLOSED);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Update Application Evaluation" operation. **/
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationEvaluationEntity)
|
||||
.newData(existingApplicationEvaluationEntity).build());
|
||||
@@ -1020,6 +1034,7 @@ public class ApplicationAmendmentRequestDao {
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
public ApplicationAmendmentRequestResponse extendResponseDays(Long id, Long newResponseDays) {
|
||||
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = validateApplicationAmendmentRequest(id);
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.gepafin.tendermanagement.model.request.ApplicationFormFieldRequestBea
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationRequest;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.EmailLogRequest;
|
||||
import net.gepafin.tendermanagement.model.request.NotificationReq;
|
||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.repositories.*;
|
||||
@@ -162,6 +163,15 @@ public class ApplicationDao {
|
||||
@Autowired
|
||||
private ApplicationEvaluationService applicationEvaluationService;
|
||||
|
||||
@Autowired
|
||||
private NotificationDao notificationDao;
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Autowired
|
||||
private RoleRepository roleRepository;
|
||||
|
||||
public ApplicationResponseBean createApplication(HttpServletRequest request, ApplicationRequestBean applicationRequestBean, Long formId, Long applicationId) {
|
||||
FormEntity formEntity = formService.validateForm(formId);
|
||||
// callService.validatePublishedCall(formEntity.getCall().getId());
|
||||
@@ -851,6 +861,8 @@ public class ApplicationDao {
|
||||
applicationEntity.setStatus(ApplicationStatusTypeEnum.SUBMIT.getValue());
|
||||
applicationEntity.setSubmissionDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||
applicationEntity = applicationRepository.save(applicationEntity);
|
||||
Map<String ,String> placeHolders=notificationDao.sendNotificationToBeneficiary(applicationEntity,NotificationTypeEnum.APPLICATION_SUBMISSION);
|
||||
notificationDao.sendNotificationToSuperUser(applicationEntity,placeHolders,NotificationTypeEnum.APPLICATION_SUBMISSION);
|
||||
|
||||
/** This code is responsible for adding a version history log for "Update application status" operation. **/
|
||||
loggingUtil.addVersionHistory(
|
||||
|
||||
@@ -94,6 +94,12 @@ public class ApplicationEvaluationDao {
|
||||
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
@Autowired
|
||||
private NotificationDao notificationDao;
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
@@ -606,8 +612,14 @@ public class ApplicationEvaluationDao {
|
||||
setIfUpdated(entity::getMotivation, entity::setMotivation, req.getMotivation());
|
||||
actionType = VersionActionTypeEnum.UPDATE;
|
||||
} else {
|
||||
ApplicationEntity application=entity.getAssignedApplicationsEntity().getApplication();
|
||||
entity = convertToEntity(user, req, assignedApplicationId);
|
||||
actionType = VersionActionTypeEnum.INSERT;
|
||||
|
||||
Map<String, String> placeHolders = notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.EVALUATION_CREATION);
|
||||
notificationDao.sendNotificationToSuperUser(application,placeHolders,NotificationTypeEnum.EVALUATION_CREATION);
|
||||
notificationDao.sendNotificationToInstructor(placeHolders,entity,NotificationTypeEnum.EVALUATION_CREATION);
|
||||
|
||||
}
|
||||
ApplicationStatusForEvaluation status = req.getApplicationStatus();
|
||||
// Fetch all amendment request entities associated with the evaluation ID
|
||||
@@ -1806,12 +1818,17 @@ public class ApplicationEvaluationDao {
|
||||
if (Boolean.TRUE.equals(statusType.equals((ApplicationStatusTypeEnum.REJECTED.getValue())))) {
|
||||
emailNotificationDao.sendInadmissibilityEmailForRejectedApplication(application,existingEntity);
|
||||
}
|
||||
|
||||
Map<String, String> placeHolders = notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.EVALUATION_RESULT);
|
||||
notificationDao.sendNotificationToSuperUser(application,placeHolders,NotificationTypeEnum.EVALUATION_RESULT);
|
||||
notificationDao.sendNotificationToInstructor(placeHolders,existingEntity,NotificationTypeEnum.EVALUATION_RESULT);
|
||||
|
||||
return convertToResponse(entity);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ApplicationEvaluationEntity validateApplicationEvaluationByApplicationId(Long applicationId) {
|
||||
public ApplicationEvaluationEntity validateApplicationEvaluationByApplicationId(Long applicationId) {
|
||||
return applicationEvaluationRepository
|
||||
.findByApplicationIdAndIsDeletedFalse(applicationId)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
|
||||
@@ -16,14 +16,18 @@ import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
||||
import net.gepafin.tendermanagement.entities.DocumentEntity;
|
||||
import net.gepafin.tendermanagement.entities.HubEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.NotificationTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.RoleStatusEnum;
|
||||
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.AppointmentCreationRequest;
|
||||
import net.gepafin.tendermanagement.model.request.AppointmentNdgRequest;
|
||||
import net.gepafin.tendermanagement.model.request.AppointmentVisuraListRequest;
|
||||
import net.gepafin.tendermanagement.model.request.AppointmentVisuraRequest;
|
||||
import net.gepafin.tendermanagement.model.request.CreateAppointmentRequest;
|
||||
import net.gepafin.tendermanagement.model.request.NotificationReq;
|
||||
import net.gepafin.tendermanagement.model.request.UploadDocToExternalSystemRequest;
|
||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||
import net.gepafin.tendermanagement.model.response.AppointmentCreationResponse;
|
||||
@@ -34,6 +38,7 @@ import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
||||
import net.gepafin.tendermanagement.repositories.CompanyRepository;
|
||||
import net.gepafin.tendermanagement.repositories.DocumentRepository;
|
||||
import net.gepafin.tendermanagement.repositories.HubRepository;
|
||||
import net.gepafin.tendermanagement.repositories.UserRepository;
|
||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||
import net.gepafin.tendermanagement.service.CompanyService;
|
||||
import net.gepafin.tendermanagement.service.feignClient.AppointmentApiService;
|
||||
@@ -58,6 +63,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -130,6 +136,12 @@ public class AppointmentDao {
|
||||
@Autowired
|
||||
private TokenProvider tokenProvider;
|
||||
|
||||
@Autowired
|
||||
private NotificationDao notificationDao;
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
private final Map<Long, ExecutorService> executorMap = new ConcurrentHashMap<>();
|
||||
|
||||
private final ConcurrentHashMap<Long, ExecutorService> threadForDocumentMap = new ConcurrentHashMap<>();
|
||||
@@ -312,6 +324,8 @@ public class AppointmentDao {
|
||||
company.setNdg(ndg);
|
||||
companyRepository.save(company);
|
||||
applicationRepository.save(application);
|
||||
Map<String ,String> placeHolders=notificationDao.sendNotificationToBeneficiary(application,NotificationTypeEnum.NDG_GENERATION);
|
||||
notificationDao.sendNotificationToSuperUser(application,placeHolders,NotificationTypeEnum.NDG_GENERATION);
|
||||
|
||||
// /** This code is responsible for adding a version history log for the "update application ndg code, status, and Id visura" operation. **/
|
||||
// loggingUtil.addVersionHistory(
|
||||
|
||||
@@ -15,7 +15,9 @@ import java.util.zip.ZipOutputStream;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.NotificationTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.NotificationReq;
|
||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.repositories.*;
|
||||
@@ -49,6 +51,7 @@ import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
|
||||
import static net.gepafin.tendermanagement.enums.RoleStatusEnum.ROLE_SUPER_ADMIN;
|
||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||
import static org.hibernate.internal.util.collections.CollectionHelper.listOf;
|
||||
|
||||
@Component
|
||||
public class CallDao {
|
||||
@@ -108,6 +111,15 @@ public class CallDao {
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
private NotificationDao notificationDao;
|
||||
|
||||
@Autowired
|
||||
private BeneficiaryRepository beneficiaryRepository;
|
||||
|
||||
@Autowired
|
||||
private NotificationTypeRepository notificationTypeRepository;
|
||||
|
||||
public CallResponse createCallStep1(CreateCallRequestStep1 createCallRequest, UserEntity userEntity) {
|
||||
createCallRequest.setRegionId(userEntity.getRoleEntity().getRegion().getId());
|
||||
CallEntity callEntity = convertToCallEntity(createCallRequest, userEntity);
|
||||
@@ -828,10 +840,20 @@ public class CallDao {
|
||||
validateStatusChange(currentStatus, statusReq);
|
||||
callEntity.setStatus(statusReq.getValue());
|
||||
callEntity = callRepository.save(callEntity);
|
||||
|
||||
|
||||
//Creating notification.
|
||||
List<Long> userIds = beneficiaryRepository.findUserIdsByHubIdAndBeneficiaryId(callEntity.getHub().getId());
|
||||
Map<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("{{call_name}}", callEntity.getName());
|
||||
userIds.forEach(userId -> {
|
||||
List<Long> companyIds = notificationDao.getAllCompanyIdsForUser(userId);
|
||||
NotificationReq notificationReq = notificationDao.createNotificationReq(NotificationTypeEnum.CALL_CREATED.getValue(), placeholders, userId, null, companyIds);
|
||||
notificationDao.sendNotification(notificationReq);
|
||||
});
|
||||
|
||||
/** This code is responsible for adding a version history log for the "update call status" operation **/
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldCallEntity).newData(callEntity).build());
|
||||
|
||||
|
||||
return convertToCallResponseBean(callEntity);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,252 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
|
||||
import net.gepafin.tendermanagement.entities.NotificationEntity;
|
||||
import net.gepafin.tendermanagement.entities.NotificationTypeEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserWithCompanyEntity;
|
||||
import net.gepafin.tendermanagement.enums.NotificationEnum;
|
||||
import net.gepafin.tendermanagement.enums.NotificationTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.RoleStatusEnum;
|
||||
import net.gepafin.tendermanagement.model.request.NotificationReq;
|
||||
import net.gepafin.tendermanagement.model.response.NotificationResponse;
|
||||
import net.gepafin.tendermanagement.repositories.NotificationRepository;
|
||||
import net.gepafin.tendermanagement.repositories.NotificationTypeRepository;
|
||||
import net.gepafin.tendermanagement.repositories.UserRepository;
|
||||
import net.gepafin.tendermanagement.repositories.UserWithCompanyRepository;
|
||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.hibernate.internal.util.collections.CollectionHelper.listOf;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class NotificationDao {
|
||||
|
||||
@Autowired
|
||||
private SimpMessagingTemplate messagingTemplate;
|
||||
|
||||
@Autowired
|
||||
private NotificationRepository notificationRepository;
|
||||
|
||||
@Autowired
|
||||
private NotificationTypeRepository notificationTypeRepository;
|
||||
|
||||
@Autowired
|
||||
private UserWithCompanyRepository userWithCompanyRepository;
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Autowired
|
||||
private CompanyDao companyDao;
|
||||
|
||||
@Autowired
|
||||
private ApplicationService applicationService;
|
||||
|
||||
public NotificationResponse sendNotification(NotificationReq notificationReq) {
|
||||
|
||||
// Ensure userId is properly set in notificationReq if not already
|
||||
Long userId = notificationReq.getUserId();
|
||||
if (userId == null) {
|
||||
log.error("User ID is missing in the notification request.");
|
||||
return null;
|
||||
}
|
||||
NotificationEntity notificationEntity = saveNotification(notificationReq);
|
||||
log.info("Sending notification to user {} with content: {}", userId, notificationReq.getMessage());
|
||||
List<Long> companyIds = notificationReq.getCompanyIds();
|
||||
|
||||
if (companyIds == null || companyIds.isEmpty()) {
|
||||
sendToUser(userId, notificationEntity);
|
||||
} else {
|
||||
sendToCompanies(userId, companyIds, notificationEntity);
|
||||
}
|
||||
|
||||
return convertNotificationEntityToNotificationResponse(notificationEntity);
|
||||
}
|
||||
|
||||
private NotificationEntity saveNotification(NotificationReq notificationReq) {
|
||||
|
||||
return notificationRepository.save(convertNotificationRequestToNotificationEntity(notificationReq));
|
||||
}
|
||||
|
||||
private void sendToUser(Long userId, NotificationEntity notificationEntity) {
|
||||
|
||||
String userChannel = GepafinConstant.COMMON_SINGLE_CHANNEL_PREFIX + userId;
|
||||
log.info("Channel for User {}", userChannel);
|
||||
NotificationResponse notificationResponse = convertNotificationEntityToNotificationResponse(notificationEntity);
|
||||
messagingTemplate.convertAndSend(userChannel, notificationResponse);
|
||||
}
|
||||
|
||||
private void sendToCompanies(Long userId, List<Long> companyIds, NotificationEntity notificationEntity) {
|
||||
// Send notification to each company provided in the companyIds list
|
||||
companyIds.forEach(companyId -> {
|
||||
UserWithCompanyEntity userWithCompany = userWithCompanyRepository.findByUserIdAndCompanyIdAndIsDeletedFalseForNotification(userId, companyId);
|
||||
String companyChannel = Utils.createChannelForUserAndCompany(userId, companyId);
|
||||
log.info("Channel for User and Company {}, {}", userId, companyChannel);
|
||||
if (userWithCompany == null) {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, GepafinConstant.USER_WITH_COMPANY_NOT_FOUND);
|
||||
}
|
||||
notificationEntity.setUserWithCompany(userWithCompany);
|
||||
notificationRepository.save(notificationEntity);
|
||||
NotificationResponse notificationResponse = convertNotificationEntityToNotificationResponse(notificationEntity);
|
||||
messagingTemplate.convertAndSend(companyChannel, notificationResponse);
|
||||
});
|
||||
}
|
||||
|
||||
private NotificationResponse convertNotificationEntityToNotificationResponse(NotificationEntity notificationEntity) {
|
||||
|
||||
NotificationResponse notificationResponse = new NotificationResponse();
|
||||
notificationResponse.setId(notificationEntity.getId());
|
||||
notificationResponse.setUserId(notificationEntity.getUserId());
|
||||
notificationResponse.setStatus(notificationEntity.getStatus());
|
||||
notificationResponse.setMessage(notificationEntity.getMessage());
|
||||
notificationResponse.setCreatedDate(notificationEntity.getCreatedDate());
|
||||
notificationResponse.setUpdatedDate(notificationEntity.getUpdatedDate());
|
||||
notificationResponse.setRedirectUrl(notificationEntity.getNotificationType());
|
||||
notificationResponse.setCompanyId(notificationEntity.getUserWithCompany() != null ? notificationEntity.getUserWithCompany().getCompanyId() : null);
|
||||
notificationResponse.setNotificationType(notificationEntity.getNotificationType());
|
||||
notificationResponse.setTitle(notificationEntity.getTitle());
|
||||
return notificationResponse;
|
||||
}
|
||||
|
||||
private NotificationEntity convertNotificationRequestToNotificationEntity(NotificationReq notificationReq) {
|
||||
|
||||
NotificationEntity notificationEntity = new NotificationEntity();
|
||||
String message = notificationReq.getMessage();
|
||||
notificationEntity.setNotificationType(notificationReq.getNotificationType());
|
||||
notificationEntity.setUserId(notificationReq.getUserId());
|
||||
notificationEntity.setStatus(NotificationEnum.UNREAD.getValue());
|
||||
notificationEntity.setIsDeleted(Boolean.FALSE);
|
||||
notificationEntity.setUserWithCompany(notificationReq.getUserWithCompanyEntity() != null ? notificationReq.getUserWithCompanyEntity() : null);
|
||||
notificationEntity.setMessage(message);
|
||||
notificationEntity.setTitle(notificationReq.getTitle());
|
||||
return notificationEntity;
|
||||
}
|
||||
|
||||
public NotificationReq createNotificationReq(String notificationType, Map<String, String> placeholders, Long userId, UserWithCompanyEntity userWithCompanyEntity,
|
||||
List<Long> companyIds) {
|
||||
// Create NotificationReq object
|
||||
NotificationReq notificationReq = new NotificationReq();
|
||||
NotificationTypeEntity notificationTypeEntity = notificationTypeRepository.findByNotificationNameAndIsDeletedFalse(notificationType);
|
||||
notificationReq.setNotificationType(notificationType);
|
||||
String message = Utils.replacePlaceholders(notificationTypeEntity.getJsonTemplate(), placeholders);
|
||||
notificationReq.setMessage(message);
|
||||
notificationReq.setUserId(userId);
|
||||
notificationReq.setCompanyIds(companyIds);
|
||||
String title = Utils.replacePlaceholders(notificationTypeEntity.getTitle(), placeholders);
|
||||
notificationReq.setTitle(title);
|
||||
notificationReq.setUserWithCompanyEntity(userWithCompanyEntity);
|
||||
return notificationReq;
|
||||
}
|
||||
|
||||
public Map<String, String> sendNotificationToBeneficiary(ApplicationEntity application, NotificationTypeEnum notificationTypeEnum) {
|
||||
|
||||
Map<String, String> placeHolders = new HashMap<>();
|
||||
placeHolders.put("{{call_name}}", application.getCall().getName());
|
||||
placeHolders.put("{{protocol_number}}", String.valueOf(application.getProtocol().getProtocolNumber()));
|
||||
NotificationReq notificationReq = createNotificationReq(notificationTypeEnum.getValue(), placeHolders, application.getUserId(), application.getUserWithCompany(),
|
||||
listOf(application.getCompanyId()));
|
||||
sendNotification(notificationReq);
|
||||
return placeHolders;
|
||||
}
|
||||
|
||||
public void sendNotificationToInstructor(Map<String, String> placeHolders, ApplicationEvaluationEntity applicationEvaluationEntity, NotificationTypeEnum notificationTypeEnum) {
|
||||
|
||||
Long instructorId = applicationEvaluationEntity.getUserId();
|
||||
ApplicationEntity application = applicationService.validateApplication(applicationEvaluationEntity.getApplicationId());
|
||||
if (instructorId != null) {
|
||||
NotificationReq notificationreq = createNotificationReq(notificationTypeEnum.getValue(), placeHolders, instructorId, application.getUserWithCompany(),
|
||||
listOf(application.getCompanyId()));
|
||||
sendNotification(notificationreq);
|
||||
}
|
||||
}
|
||||
public void sendNotificationToSuperUser(ApplicationEntity application, Map<String, String> placeHolders, NotificationTypeEnum notificationTypeEnum) {
|
||||
|
||||
List<UserEntity> user = userRepository.findByRoleEntity_RoleTypeAndHubId(RoleStatusEnum.ROLE_SUPER_ADMIN.getValue(), application.getHubId());
|
||||
UserEntity userEntity1 = user.get(0);
|
||||
if (userEntity1 != null) {
|
||||
NotificationReq notificationreq = createNotificationReq(notificationTypeEnum.getValue(), placeHolders, userEntity1.getId(), application.getUserWithCompany(),
|
||||
listOf(application.getCompanyId()));
|
||||
sendNotification(notificationreq);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Long> getAllCompanyIdsForUser(Long userId) {
|
||||
|
||||
return userWithCompanyRepository.findActiveCompanyIdsByUserId(userId);
|
||||
}
|
||||
|
||||
public NotificationResponse getNotificationById(Long id) {
|
||||
|
||||
NotificationEntity notificationEntity = validateNotificationEntity(id);
|
||||
return convertNotificationEntityToNotificationResponse(notificationEntity);
|
||||
}
|
||||
|
||||
private NotificationEntity validateNotificationEntity(Long id) {
|
||||
|
||||
NotificationEntity notificationEntity = notificationRepository.findByIdAndIsDeletedFalse(id);
|
||||
if (notificationEntity == null) {
|
||||
throw new CustomValidationException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.NOTIFICATION_NOT_FOUND));
|
||||
}
|
||||
return notificationEntity;
|
||||
}
|
||||
|
||||
public List<NotificationResponse> getNotificationByUserId(Long userId, Long companyId, List<NotificationEnum> statuses) {
|
||||
|
||||
List<NotificationEntity> notificationEntities = notificationRepository.findByUserIdAndIsDeletedFalse(userId);
|
||||
UserWithCompanyEntity userWithCompany = null;
|
||||
List<String> statusStrings = new ArrayList<>();
|
||||
if (companyId != null) {
|
||||
userWithCompany = companyDao.validateUserWithCompny(userId, companyId);
|
||||
}
|
||||
|
||||
if (statuses != null) {
|
||||
statusStrings = statuses.stream().map(NotificationEnum::name) // Convert enum to its name as String
|
||||
.toList();
|
||||
notificationEntities = notificationRepository.findByUserIdAndIsDeletedFalseAndStatusIn(userId, statusStrings);
|
||||
|
||||
if (userWithCompany != null) {
|
||||
notificationEntities = notificationRepository.findByUserIdAndUserWithCompanyIdAndIsDeletedFalseAndStatusIn(userId, userWithCompany.getId(), statusStrings);
|
||||
}
|
||||
}
|
||||
|
||||
return notificationEntities.stream().map(this::convertNotificationEntityToNotificationResponse).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public NotificationResponse updateNotificationStatus(Long id, NotificationEnum status) {
|
||||
|
||||
NotificationEntity notificationEntity = validateNotificationEntity(id);
|
||||
if (notificationEntity.getStatus().equals(status.getValue())) {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.NOTIFICATION_ALREADY_IN_THAT_STATE));
|
||||
}
|
||||
notificationEntity.setStatus(status.getValue());
|
||||
notificationEntity.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||
notificationRepository.save(notificationEntity);
|
||||
return convertNotificationEntityToNotificationResponse(notificationEntity);
|
||||
}
|
||||
|
||||
public void deleteNotification(Long id) {
|
||||
|
||||
NotificationEntity notificationEntity = validateNotificationEntity(id);
|
||||
notificationEntity.setIsDeleted(true);
|
||||
notificationRepository.save(notificationEntity);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Data;
|
||||
|
||||
@Entity
|
||||
@Table(name = "NOTIFICATION")
|
||||
@Data
|
||||
public class NotificationEntity extends BaseEntity {
|
||||
|
||||
@Column(name = "USER_ID")
|
||||
private Long userId;
|
||||
|
||||
@Column(name = "MESSAGE")
|
||||
private String message;
|
||||
|
||||
@Column(name = "TITLE")
|
||||
private String title;
|
||||
|
||||
@Column(name = "STATUS")
|
||||
private String status;
|
||||
|
||||
@Column(name = "IS_DELETED")
|
||||
private Boolean isDeleted;
|
||||
|
||||
@Column(name = "NOTIFICATION_TYPE")
|
||||
private String notificationType;
|
||||
|
||||
@Column(name = "REDIRECT_LINK")
|
||||
private String redirectLink;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "USER_WITH_COMPANY_ID")
|
||||
private UserWithCompanyEntity userWithCompany;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Data;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name = "NOTIFICATION_TYPE")
|
||||
public class NotificationTypeEntity extends BaseEntity {
|
||||
|
||||
@Column(name = "NOTIFICATION_NAME")
|
||||
private String notificationName;
|
||||
|
||||
@Column(name = "JSON_TEMPLATE")
|
||||
private String jsonTemplate;
|
||||
|
||||
@Column(name = "TITLE")
|
||||
private String title;
|
||||
|
||||
@Column(name="IS_DELETED")
|
||||
private Boolean isDeleted;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package net.gepafin.tendermanagement.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
public enum NotificationEnum {
|
||||
//status
|
||||
READ("READ"), UNREAD("UNREAD");
|
||||
|
||||
private final String value;
|
||||
|
||||
NotificationEnum(String value) {
|
||||
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String getValue() {
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return String.valueOf(value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package net.gepafin.tendermanagement.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
public enum NotificationTypeEnum {
|
||||
CALL_CREATED("CALL_CREATED"),
|
||||
APPLICATION_SUBMISSION("APPLICATION_SUBMISSION"),
|
||||
AMENDMENT_CREATION("AMENDMENT_CREATION"),
|
||||
EVALUATION_RESULT("EVALUATION_RESULT"),
|
||||
AMENDMENT_EXPIRED("AMENDMENT_EXPIRED"),
|
||||
AMENDMENT_CLOSED("AMENDMENT_CLOSED"),
|
||||
NDG_GENERATION("NDG_GENERATION"),
|
||||
EVALUATION_CREATION("EVALUATION_CREATION"),
|
||||
EVALUATION_EXPIRED("EVALUATION_EXPIRED");
|
||||
|
||||
private final String value;
|
||||
|
||||
NotificationTypeEnum(String value) {
|
||||
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String getValue() {
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return String.valueOf(value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package net.gepafin.tendermanagement.model.request;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.entities.UserWithCompanyEntity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class NotificationReq {
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
Long id;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
Long userId;
|
||||
|
||||
String message;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
String notificationType;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
String status;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
private LocalDateTime createdDate;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
private LocalDateTime updatedDate;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
private String redirectUrl;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
private String title;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
private List<Long> companyIds;
|
||||
|
||||
@JsonIgnore
|
||||
private UserWithCompanyEntity userWithCompanyEntity;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.model.BaseBean;
|
||||
|
||||
@Data
|
||||
public class NotificationResponse extends BaseBean {
|
||||
private Long userId;
|
||||
|
||||
private String title;
|
||||
|
||||
private String message;
|
||||
|
||||
private String status;
|
||||
|
||||
private Long companyId;
|
||||
|
||||
private String redirectUrl;
|
||||
|
||||
private String notificationType;
|
||||
}
|
||||
@@ -40,6 +40,7 @@ public class UserResponseBean extends BaseBean {
|
||||
|
||||
private List<CompanyResponse> companies;
|
||||
private Boolean privacy;
|
||||
|
||||
private Boolean terms;
|
||||
|
||||
private Boolean marketing;
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.BeneficiaryEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface BeneficiaryRepository extends JpaRepository<BeneficiaryEntity, Long> {
|
||||
|
||||
@Query("SELECT u.id FROM UserEntity u JOIN u.beneficiary b WHERE b.id = u.beneficiary.id AND b.hubId = :hubId")
|
||||
List<Long> findUserIdsByHubIdAndBeneficiaryId(Long hubId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.NotificationEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface NotificationRepository extends JpaRepository<NotificationEntity, Long> {
|
||||
|
||||
NotificationEntity findByIdAndIsDeletedFalse(Long id);
|
||||
|
||||
List<NotificationEntity> findByUserIdAndIsDeletedFalse(Long userId);
|
||||
|
||||
List<NotificationEntity> findByUserIdAndUserWithCompanyIdAndIsDeletedFalseAndStatusIn(Long userId, Long userWithCompanyId, List<String> statuses);
|
||||
|
||||
List<NotificationEntity> findByUserIdAndIsDeletedFalseAndStatusIn(Long userId, List<String> statuses);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.NotificationTypeEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface NotificationTypeRepository extends JpaRepository<NotificationTypeEntity, Long> {
|
||||
NotificationTypeEntity findByNotificationNameAndIsDeletedFalse(String value);
|
||||
}
|
||||
@@ -25,4 +25,7 @@ public interface UserRepository extends JpaRepository<UserEntity, Long> {
|
||||
Optional<UserEntity> findByBeneficiaryCodiceFiscaleAndHubId(String codiceFiscale, Long hubId);
|
||||
|
||||
boolean existsByBeneficiaryCodiceFiscaleAndHubId(String codiceFiscale, Long hubId);
|
||||
|
||||
List<UserEntity> findByRoleEntity_RoleTypeAndHubId(String roleType, Long hubId);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.UserWithCompanyEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.UserWithCompanyEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface UserWithCompanyRepository extends JpaRepository<UserWithCompanyEntity, Long> {
|
||||
|
||||
void deleteByCompanyIdAndIsDeletedFalse(Long companyId);
|
||||
void deleteByCompanyIdAndIsDeletedFalse(Long companyId);
|
||||
|
||||
@Query("SELECT u.companyId FROM UserWithCompanyEntity u WHERE u.userId = :userId AND u.isDeleted = false")
|
||||
List<Long> findActiveCompanyIdsByUserId(@Param("userId") Long userId);
|
||||
@Query("SELECT u.companyId FROM UserWithCompanyEntity u WHERE u.userId = :userId AND u.isDeleted = false")
|
||||
List<Long> findActiveCompanyIdsByUserId(@Param("userId") Long userId);
|
||||
|
||||
Optional<UserWithCompanyEntity> findByUserIdAndCompanyIdAndIsDeletedFalse(Long userId, Long companyId);
|
||||
Optional<UserWithCompanyEntity> findByUserIdAndCompanyIdAndIsDeletedFalse(Long userId, Long companyId);
|
||||
|
||||
@Query("SELECT u FROM UserWithCompanyEntity u WHERE u.userId = :userId AND u.companyId = :companyId AND u.isDeleted = false")
|
||||
UserWithCompanyEntity findByUserIdAndCompanyIdAndIsDeletedFalseForNotification(Long userId, Long companyId);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,35 +1,42 @@
|
||||
package net.gepafin.tendermanagement.scheduler;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.dao.ApplicationAmendmentRequestDao;
|
||||
import net.gepafin.tendermanagement.dao.NotificationDao;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
|
||||
import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
|
||||
import net.gepafin.tendermanagement.enums.*;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationAmendmentRequestEnum;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationEvaluationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
||||
import net.gepafin.tendermanagement.enums.NotificationTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
|
||||
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.UserActionRequest;
|
||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationAmendmentRequestRepository;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationEvaluationRepository;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
||||
import net.gepafin.tendermanagement.repositories.AssignedApplicationsRepository;
|
||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.dao.ApplicationAmendmentRequestDao;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
|
||||
import net.gepafin.tendermanagement.model.request.UserActionRequest;
|
||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationAmendmentRequestRepository;
|
||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class ApplicationAmendmentScheduler {
|
||||
@@ -47,6 +54,9 @@ public class ApplicationAmendmentScheduler {
|
||||
@Autowired
|
||||
private LoggingUtil loggingUtil;
|
||||
|
||||
@Autowired
|
||||
private NotificationDao notificationDao;
|
||||
|
||||
@Autowired
|
||||
private AssignedApplicationsRepository assignedApplicationsRepository;
|
||||
|
||||
@@ -90,8 +100,10 @@ public class ApplicationAmendmentScheduler {
|
||||
try {
|
||||
ApplicationAmendmentRequestEntity oldAmendmentRequestEntity = Utils.getClonedEntityForData(request);
|
||||
request.setStatus(ApplicationAmendmentRequestEnum.EXPIRED.getValue());
|
||||
ApplicationEntity application=oldAmendmentRequestEntity.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication();
|
||||
request = applicationAmendmentRepository.save(request);
|
||||
|
||||
Map<String ,String> placeHolders=notificationDao.sendNotificationToBeneficiary(application,NotificationTypeEnum.AMENDMENT_EXPIRED);
|
||||
notificationDao.sendNotificationToInstructor(placeHolders,oldAmendmentRequestEntity.getApplicationEvaluationEntity(),NotificationTypeEnum.AMENDMENT_EXPIRED);
|
||||
/** This code is responsible for adding a version history log for the "Update Application Amendment" operation. **/
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(httpServletRequest).actionType(VersionActionTypeEnum.UPDATE).oldData(oldAmendmentRequestEntity).newData(request).build());
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package net.gepafin.tendermanagement.scheduler;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.dao.NotificationDao;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationEvaluationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.NotificationTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
|
||||
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
|
||||
@@ -22,6 +25,7 @@ import org.springframework.stereotype.Component;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class ApplicationEvaluationScheduler {
|
||||
@@ -35,6 +39,9 @@ public class ApplicationEvaluationScheduler {
|
||||
@Autowired
|
||||
private HttpServletRequest httpServletRequest;
|
||||
|
||||
@Autowired
|
||||
private NotificationDao notificationDao;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ApplicationEvaluationScheduler.class);
|
||||
|
||||
@Scheduled(cron = "0 0 2 * * ?") // Runs daily at midnight
|
||||
@@ -76,10 +83,15 @@ public class ApplicationEvaluationScheduler {
|
||||
|
||||
ApplicationEvaluationEntity oldApplicationEvaluationEntity = Utils
|
||||
.getClonedEntityForData(evaluation);
|
||||
|
||||
ApplicationEntity application=evaluation.getAssignedApplicationsEntity().getApplication();
|
||||
evaluation.setStatus(ApplicationEvaluationStatusTypeEnum.EXPIRED.getValue());
|
||||
evaluation = applicationEvaluationRepository.save(evaluation);
|
||||
|
||||
Map<String, String> placeHolders = notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.EVALUATION_EXPIRED);
|
||||
notificationDao.sendNotificationToSuperUser(application,placeHolders,NotificationTypeEnum.EVALUATION_EXPIRED);
|
||||
notificationDao.sendNotificationToInstructor(placeHolders,evaluation,NotificationTypeEnum.EVALUATION_EXPIRED);
|
||||
|
||||
|
||||
// Logging version history for the update operation
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(httpServletRequest)
|
||||
.actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationEvaluationEntity)
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package net.gepafin.tendermanagement.service;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.enums.NotificationEnum;
|
||||
import net.gepafin.tendermanagement.model.request.NotificationReq;
|
||||
import net.gepafin.tendermanagement.model.response.NotificationResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface NotificationService {
|
||||
NotificationResponse sendNotification(Long userId, NotificationReq notificationReq, Long companyId);
|
||||
|
||||
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 void deleteNotification(HttpServletRequest request, Long id);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package net.gepafin.tendermanagement.service.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.gepafin.tendermanagement.dao.NotificationDao;
|
||||
import net.gepafin.tendermanagement.enums.NotificationEnum;
|
||||
import net.gepafin.tendermanagement.model.request.NotificationReq;
|
||||
import net.gepafin.tendermanagement.model.response.NotificationResponse;
|
||||
import net.gepafin.tendermanagement.service.NotificationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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 {
|
||||
|
||||
@Autowired
|
||||
private NotificationDao notificationDao;
|
||||
|
||||
@Override
|
||||
public NotificationResponse sendNotification(Long userId, NotificationReq notificationReq, Long companyId) {
|
||||
|
||||
log.info("Sending notification to user {} with content: {}", userId, notificationReq.getMessage());
|
||||
notificationReq.setUserId(userId);
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,19 +19,15 @@ import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
@@ -48,7 +44,6 @@ import net.gepafin.tendermanagement.web.rest.api.errors.FeignClientForbiddenExce
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.FeignClientNotFoundException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.FeignClientUnauthorizedException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.FeignClientValidationException;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
@@ -691,4 +686,8 @@ public class Utils {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String createChannelForUserAndCompany(Long userId, Long companyId) {
|
||||
return GepafinConstant.COMMON_SINGLE_CHANNEL_PREFIX + userId + GepafinConstant.COMPANY_PREFIX + companyId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.enums.NotificationEnum;
|
||||
import net.gepafin.tendermanagement.model.request.NotificationReq;
|
||||
import net.gepafin.tendermanagement.model.response.NotificationResponse;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface NotificationApi {
|
||||
@Operation(summary = "Api to send notification.", responses = { @ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = @ExampleObject(value =
|
||||
ErrorConstants.NOTFOUND_ERROR_EXAMPLE))),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = @ExampleObject(value =
|
||||
ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE))),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = @ExampleObject(value =
|
||||
ErrorConstants.BADREQUEST_ERROR_EXAMPLE))) })
|
||||
@PostMapping(value = "/user/{userId}/sent", consumes = "application/json", produces = "application/json")
|
||||
ResponseEntity<Response<NotificationResponse>> sendNotification(HttpServletRequest request, @RequestBody NotificationReq notificationReq,
|
||||
@Parameter(description = "The company id", required = false) @RequestParam(value = "companyId", required = false) Long companyId,
|
||||
@Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId);
|
||||
|
||||
@Operation(summary = "Api to get notification by id", responses = { @ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@GetMapping(value = "/{id}", produces = "application/json")
|
||||
ResponseEntity<Response<NotificationResponse>> getNotificationById(HttpServletRequest request,
|
||||
@Parameter(description = "The notification id", required = true) @PathVariable(value = "id", required = true) Long id);
|
||||
|
||||
@Operation(summary = "Api to get notification by user id", responses = { @ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@GetMapping(value = "/user/{userId}", produces = "application/json")
|
||||
ResponseEntity<Response<List<NotificationResponse>>> getNotificationByUserId(HttpServletRequest request,
|
||||
@Parameter(description = "The user id", required = true) @PathVariable(value = "userId", required = true) Long userId,
|
||||
@Parameter(description = "The company id", required = false) @RequestParam(value = "companyId", required = false) Long companyId,
|
||||
@Parameter(description = "The notification status", required = false) @RequestParam(value = "status", required = false) List<NotificationEnum> statuses);
|
||||
|
||||
@Operation(summary = "Api to update notification status", responses = { @ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@PutMapping(value = "/{id}", produces = "application/json")
|
||||
ResponseEntity<Response<NotificationResponse>> updateNotificationStatus(HttpServletRequest request,
|
||||
@Parameter(description = "The notification id", required = true) @PathVariable(value = "id", required = true) Long id,
|
||||
@Parameter(description = "The notification status", required = true) @RequestParam(value = "status", required = true) NotificationEnum status);
|
||||
|
||||
@Operation(summary = "Api to delete notification", responses = { @ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@DeleteMapping(value = "/{id}", produces = "application/json")
|
||||
ResponseEntity<Response<Void>> deleteNotification(HttpServletRequest request,
|
||||
@Parameter(description = "The notification id", required = true) @PathVariable(value = "id", required = true) Long id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.enums.NotificationEnum;
|
||||
import net.gepafin.tendermanagement.enums.NotificationTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.NotificationReq;
|
||||
import net.gepafin.tendermanagement.model.response.NotificationResponse;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.service.NotificationService;
|
||||
import net.gepafin.tendermanagement.web.rest.api.NotificationApi;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.hibernate.internal.util.collections.CollectionHelper.listOf;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("${openapi.gepafin.base-path:/v1/notification}")
|
||||
public class NotificationApiController implements NotificationApi {
|
||||
|
||||
@Autowired
|
||||
private NotificationService notificationService;
|
||||
|
||||
public ResponseEntity<Response<NotificationResponse>> sendNotification(HttpServletRequest request, NotificationReq notificationReq, Long userId, Long companyId) {
|
||||
|
||||
NotificationResponse notificationData = notificationService.sendNotification(userId, notificationReq, companyId);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new Response<>(notificationData, Status.SUCCESS, Translator.toLocale(GepafinConstant.NOTIFICATION_SENT_SUCCESSFULLY)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<NotificationResponse>> getNotificationById(HttpServletRequest request, Long id) {
|
||||
|
||||
NotificationResponse notificationResponse = notificationService.getNotificationById(request, id);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(notificationResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.NOTIFICATION_FETCHED_SUCCESSFULLY)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<List<NotificationResponse>>> getNotificationByUserId(HttpServletRequest request, Long userId, Long companyId, List<NotificationEnum> statuses) {
|
||||
|
||||
List<NotificationResponse> notificationResponses = notificationService.getNotificationByUserId(request, userId, companyId, statuses);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<List<NotificationResponse>>(notificationResponses, Status.SUCCESS, Translator.toLocale(GepafinConstant.NOTIFICATION_FETCHED_SUCCESSFULLY)));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<NotificationResponse>> updateNotificationStatus(HttpServletRequest request, Long id, NotificationEnum notificationEnums) {
|
||||
|
||||
NotificationResponse notificationResponse = notificationService.updateNotificationStatus(request, id, notificationEnums);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(notificationResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.NOTIFICATION_UPDATED_SUCCESSFULLY)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<Void>> deleteNotification(HttpServletRequest request, Long id) {
|
||||
|
||||
notificationService.deleteNotification(request, id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.NOTIFICATION_DELETED_SUCCESSFULLY)));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user