Created endpoint for get,update,delete

This commit is contained in:
Piyush
2024-12-23 19:28:37 +05:30
parent d7e2e35746
commit db48cf9502
11 changed files with 279 additions and 19 deletions

View File

@@ -1,5 +1,7 @@
package net.gepafin.tendermanagement.constants; package net.gepafin.tendermanagement.constants;
import com.amazonaws.services.dynamodbv2.xspec.S;
public class GepafinConstant { public class GepafinConstant {
public static final String USER_CREATED_SUCCESS_MSG = "user.created.success"; public static final String USER_CREATED_SUCCESS_MSG = "user.created.success";
@@ -345,5 +347,14 @@ public class GepafinConstant {
//Notification //Notification
public static final String COMMON_SINGLE_CHANNEL_PREFIX = "/topic/notifications_user_"; public static final String COMMON_SINGLE_CHANNEL_PREFIX = "/topic/notifications_user_";
public static final String COMPANY_PREFIX = "_company_"; 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";
} }

View File

@@ -1,5 +0,0 @@
package net.gepafin.tendermanagement.constants;
public class NotificationConstant {
public static final String NOTIFICATION_SENT_SUCCESSFULLY = "Notification Sent Successfully.";
}

View File

@@ -1,28 +1,38 @@
package net.gepafin.tendermanagement.dao; package net.gepafin.tendermanagement.dao;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.gepafin.tendermanagement.config.Translator;
import net.gepafin.tendermanagement.constants.GepafinConstant; import net.gepafin.tendermanagement.constants.GepafinConstant;
import net.gepafin.tendermanagement.entities.ApplicationEntity; import net.gepafin.tendermanagement.entities.ApplicationEntity;
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity; import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
import net.gepafin.tendermanagement.entities.NotificationEntity; import net.gepafin.tendermanagement.entities.NotificationEntity;
import net.gepafin.tendermanagement.entities.NotificationTypeEntity; import net.gepafin.tendermanagement.entities.NotificationTypeEntity;
import net.gepafin.tendermanagement.entities.UserEntity; import net.gepafin.tendermanagement.entities.UserEntity;
import net.gepafin.tendermanagement.entities.UserWithCompanyEntity;
import net.gepafin.tendermanagement.enums.NotificationEnum; import net.gepafin.tendermanagement.enums.NotificationEnum;
import net.gepafin.tendermanagement.enums.NotificationTypeEnum; import net.gepafin.tendermanagement.enums.NotificationTypeEnum;
import net.gepafin.tendermanagement.enums.RoleStatusEnum; import net.gepafin.tendermanagement.enums.RoleStatusEnum;
import net.gepafin.tendermanagement.model.request.NotificationReq; 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.NotificationRepository;
import net.gepafin.tendermanagement.repositories.NotificationTypeRepository; import net.gepafin.tendermanagement.repositories.NotificationTypeRepository;
import net.gepafin.tendermanagement.repositories.UserRepository; import net.gepafin.tendermanagement.repositories.UserRepository;
import net.gepafin.tendermanagement.repositories.UserWithCompanyRepository; import net.gepafin.tendermanagement.repositories.UserWithCompanyRepository;
import net.gepafin.tendermanagement.util.DateTimeUtil;
import net.gepafin.tendermanagement.util.Utils; 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.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate; import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
@Component @Component
@Slf4j @Slf4j
@@ -43,7 +53,10 @@ public class NotificationDao {
@Autowired @Autowired
private UserRepository userRepository; private UserRepository userRepository;
public NotificationReq sendNotification(NotificationReq notificationReq) { @Autowired
private CompanyDao companyDao;
public NotificationResponse sendNotification(NotificationReq notificationReq) {
// Ensure userId is properly set in notificationReq if not already // Ensure userId is properly set in notificationReq if not already
Long userId = notificationReq.getUserId(); Long userId = notificationReq.getUserId();
@@ -55,13 +68,13 @@ public class NotificationDao {
log.info("Sending notification to user {} with content: {}", userId, notificationReq.getMessage()); log.info("Sending notification to user {} with content: {}", userId, notificationReq.getMessage());
List<Long> companyIds = notificationReq.getCompanyIds(); List<Long> companyIds = notificationReq.getCompanyIds();
if (companyIds.isEmpty()) { if (companyIds==null || companyIds.isEmpty()) {
sendToUser(userId, notificationEntity); sendToUser(userId, notificationEntity);
} else { } else {
sendToCompanies(userId, companyIds, notificationEntity); sendToCompanies(userId, companyIds, notificationEntity);
} }
return convertToNotificationReq(notificationEntity); return convertNotificationEntityToNotificationResponse(notificationEntity);
} }
private NotificationEntity saveNotification(NotificationReq notificationReq) { private NotificationEntity saveNotification(NotificationReq notificationReq) {
@@ -147,4 +160,78 @@ public class NotificationDao {
sendNotification(notificationreq); sendNotification(notificationreq);
} }
} }
public NotificationResponse getNotificationById(Long id) {
NotificationEntity notificationEntity = validateNotificationEntity(id);
NotificationResponse notificationReq=convertNotificationEntityToNotificationResponse(notificationEntity);
return notificationReq;
}
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);
}
}
List<NotificationResponse> notificationReq= notificationEntities.stream()
.map(this::convertNotificationEntityToNotificationResponse)
.collect(Collectors.toList());
return notificationReq;
}
public NotificationResponse convertNotificationEntityToNotificationResponse(NotificationEntity entity) {
if (entity == null) {
return null; // Handle null entity gracefully
}
NotificationResponse response = new NotificationResponse();
response.setId(entity.getId());
response.setUserId(entity.getUserId());
response.setMessage(entity.getMessage());
response.setNotificationType(entity.getNotificationType());
response.setStatus(entity.getStatus());
response.setCreatedDate(entity.getCreatedDate());
response.setUpdatedDate(entity.getUpdatedDate());
response.setRedirectUrl(entity.getRedirectLink());
response.setCompanyId(entity.getUserWithCompanyId());
return response;
}
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);
}
} }

View File

@@ -1,7 +1,19 @@
package net.gepafin.tendermanagement.repositories; package net.gepafin.tendermanagement.repositories;
import net.gepafin.tendermanagement.entities.NotificationEntity; import net.gepafin.tendermanagement.entities.NotificationEntity;
import net.gepafin.tendermanagement.enums.NotificationTypeEnum;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface NotificationRepository extends JpaRepository<NotificationEntity, Long> { 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);
} }

View File

@@ -1,7 +1,20 @@
package net.gepafin.tendermanagement.service; 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.request.NotificationReq;
import net.gepafin.tendermanagement.model.response.NotificationResponse;
import java.util.List;
public interface NotificationService { public interface NotificationService {
NotificationReq sendNotification(Long userId, NotificationReq notificationReq); NotificationResponse sendNotification(Long userId, NotificationReq notificationReq);
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);
} }

View File

@@ -1,12 +1,17 @@
package net.gepafin.tendermanagement.service.impl; package net.gepafin.tendermanagement.service.impl;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.gepafin.tendermanagement.dao.NotificationDao; import net.gepafin.tendermanagement.dao.NotificationDao;
import net.gepafin.tendermanagement.enums.NotificationEnum;
import net.gepafin.tendermanagement.model.request.NotificationReq; import net.gepafin.tendermanagement.model.request.NotificationReq;
import net.gepafin.tendermanagement.model.response.NotificationResponse;
import net.gepafin.tendermanagement.service.NotificationService; import net.gepafin.tendermanagement.service.NotificationService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
@Service @Service
@Slf4j @Slf4j
public class NotificationServiceImpl implements NotificationService { public class NotificationServiceImpl implements NotificationService {
@@ -15,12 +20,33 @@ public class NotificationServiceImpl implements NotificationService {
private NotificationDao notificationDao; private NotificationDao notificationDao;
@Override @Override
public NotificationReq sendNotification(Long userId, NotificationReq notificationReq) { public NotificationResponse sendNotification(Long userId, NotificationReq notificationReq) {
log.info("Sending notification to user {} with content: {}", userId, notificationReq.getMessage()); log.info("Sending notification to user {} with content: {}", userId, notificationReq.getMessage());
notificationReq.setUserId(userId); notificationReq.setUserId(userId);
notificationReq = notificationDao.sendNotification(notificationReq); NotificationResponse notificationResponse = notificationDao.sendNotification(notificationReq);
return notificationReq; return notificationResponse;
}
@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;
} }
} }

View File

@@ -6,15 +6,25 @@ import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject; import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponse;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.enums.NotificationEnum;
import net.gepafin.tendermanagement.enums.NotificationTypeEnum;
import net.gepafin.tendermanagement.model.request.NotificationReq; import net.gepafin.tendermanagement.model.request.NotificationReq;
import net.gepafin.tendermanagement.model.response.ApplicationGetResponseBean;
import net.gepafin.tendermanagement.model.response.LookUpDataResponseBean; import net.gepafin.tendermanagement.model.response.LookUpDataResponseBean;
import net.gepafin.tendermanagement.model.response.NotificationResponse;
import net.gepafin.tendermanagement.model.util.Response; import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants; import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; 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.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; 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.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
public interface NotificationApi { public interface NotificationApi {
@Operation(summary = "Api to send notification.", responses = { @ApiResponse(responseCode = "200", description = "OK"), @Operation(summary = "Api to send notification.", responses = { @ApiResponse(responseCode = "200", description = "OK"),
@@ -24,7 +34,59 @@ public interface NotificationApi {
ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE))), ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE))),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = @ExampleObject(value = @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = @ExampleObject(value =
ErrorConstants.BADREQUEST_ERROR_EXAMPLE))) }) ErrorConstants.BADREQUEST_ERROR_EXAMPLE))) })
@PostMapping(value = "/{userId}", consumes = "application/json", produces = "application/json") @PostMapping(value = "/user/{userId}/sent", consumes = "application/json", produces = "application/json")
ResponseEntity<Response<NotificationReq>> sendNotification(HttpServletRequest request, @RequestBody NotificationReq notificationReq, ResponseEntity<Response<NotificationResponse>> sendNotification(HttpServletRequest request, @RequestBody NotificationReq notificationReq,
@Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId); @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);
} }

View File

@@ -2,8 +2,11 @@ package net.gepafin.tendermanagement.web.rest.api.impl;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.config.Translator; import net.gepafin.tendermanagement.config.Translator;
import net.gepafin.tendermanagement.constants.NotificationConstant; 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.request.NotificationReq;
import net.gepafin.tendermanagement.model.response.NotificationResponse;
import net.gepafin.tendermanagement.model.util.Response; import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.service.NotificationService; import net.gepafin.tendermanagement.service.NotificationService;
import net.gepafin.tendermanagement.web.rest.api.NotificationApi; import net.gepafin.tendermanagement.web.rest.api.NotificationApi;
@@ -14,6 +17,8 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController @RestController
@RequestMapping("${openapi.gepafin.base-path:/v1/notification}") @RequestMapping("${openapi.gepafin.base-path:/v1/notification}")
public class NotificationApiController implements NotificationApi { public class NotificationApiController implements NotificationApi {
@@ -21,12 +26,41 @@ public class NotificationApiController implements NotificationApi {
@Autowired @Autowired
private NotificationService notificationService; private NotificationService notificationService;
public ResponseEntity<Response<NotificationReq>> sendNotification(HttpServletRequest request, NotificationReq notificationReq, Long userId) { public ResponseEntity<Response<NotificationResponse>> sendNotification(HttpServletRequest request, NotificationReq notificationReq, Long userId) {
NotificationReq notificationData = notificationService.sendNotification(userId, notificationReq); NotificationResponse notificationData = notificationService.sendNotification(userId, notificationReq);
return ResponseEntity.status(HttpStatus.OK) return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(notificationData, Status.SUCCESS, Translator.toLocale(NotificationConstant.NOTIFICATION_SENT_SUCCESSFULLY))); .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)));
} }
} }

View File

@@ -2030,5 +2030,9 @@
<sqlFile dbms="postgresql" <sqlFile dbms="postgresql"
path="db/dump/insert_json_template_for_notification_13_12_2024.sql"/> path="db/dump/insert_json_template_for_notification_13_12_2024.sql"/>
</changeSet> </changeSet>
<changeSet id="23-12-2024" author="Piyush Kag">
<addColumn tableName="notification">
<column name="user_with_company_id" type="INTEGER"></column>
</addColumn>
</changeSet>
</databaseChangeLog> </databaseChangeLog>

View File

@@ -335,3 +335,11 @@ upload.document.is.only.for.gepafin = Document cant be uploaded, this is only av
appointment.created.successfully = Appointment created successfully. appointment.created.successfully = Appointment created successfully.
error.try.again = Service call error while performing the operation. Please try again. error.try.again = Service call error while performing the operation. Please try again.
document.uploading.is.in.progress = Document uploading is in progress. document.uploading.is.in.progress = Document uploading is in progress.
#notification messsages
notification.already.in.state=Notification is already in provided status.
notification.fetched.successfully=Notification fetched successfully.
notification.not.found=Notification not found.
notification.sent.successfully=Notification sent successfully.
notification.deleted.successfully=Notification deleted successfully.
notification.updated.successfully=Notification updated successfully.

View File

@@ -325,3 +325,11 @@ upload.document.is.only.for.gepafin = Il documento non pu? essere caricato, ques
appointment.created.successfully = Appuntamento creato con successo. appointment.created.successfully = Appuntamento creato con successo.
error.try.again = Errore di chiamata di servizio durante l'esecuzione dell'operazione. Riprovare. error.try.again = Errore di chiamata di servizio durante l'esecuzione dell'operazione. Riprovare.
document.uploading.is.in.progress = Il documento è in fase di caricamento. document.uploading.is.in.progress = Il documento è in fase di caricamento.
#notification messsages
notification.already.in.state=La notifica è già nello stato fornito.
notification.fetched.successfully=Notifica recuperata con successo.
notification.not.found=Notifica non trovata.
notification.sent.successfully=Notifica inviata con successo.
notification.deleted.successfully=Notifica eliminata con successo.
notification.updated.successfully=Notifica aggiornata con successo.