Added audit for Beneficiary Preferred Call
This commit is contained in:
@@ -2,13 +2,18 @@ package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||
import net.gepafin.tendermanagement.entities.BeneficiaryPreferredCallEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.enums.BeneficiaryCallStatus;
|
||||
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.BeneficiaryPreferredCallReq;
|
||||
|
||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||
import net.gepafin.tendermanagement.model.response.BeneficiaryPreferredCallResponseBean;
|
||||
import net.gepafin.tendermanagement.repositories.BeneficiaryPreferredCallRepository;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
@@ -36,6 +41,11 @@ public class BeneficiaryPreferredCallDao {
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
@Autowired
|
||||
private LoggingUtil loggingUtil;
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest httpServletRequest;
|
||||
|
||||
public BeneficiaryPreferredCallResponseBean createBeneficiaryPreferredCall(HttpServletRequest httpServletRequest, BeneficiaryPreferredCallReq request, UserEntity user) {
|
||||
log.info("Creating new beneficiary preferred call with details: {}", request);
|
||||
@@ -51,6 +61,10 @@ public class BeneficiaryPreferredCallDao {
|
||||
|
||||
BeneficiaryPreferredCallEntity entity = convertRequestToEntity(request, user);
|
||||
entity = beneficiaryPreferredCallRepository.save(entity);
|
||||
|
||||
/** This code is responsible for adding a version history log for "Create Beneficiary Preferred Call" operation. **/
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(httpServletRequest).actionType(VersionActionTypeEnum.INSERT).oldData(null).newData(entity).build());
|
||||
|
||||
log.info("Beneficiary preferred call created with ID: {}", entity.getId());
|
||||
return convertEntityToResponse(entity);
|
||||
}
|
||||
@@ -92,8 +106,14 @@ public class BeneficiaryPreferredCallDao {
|
||||
log.info("Soft deleting beneficiary preferred call with ID: {}", id);
|
||||
BeneficiaryPreferredCallEntity entity = validateBeneficiaryPreferredCall(id);
|
||||
validator.validateUserId(request, entity.getUserId());
|
||||
BeneficiaryPreferredCallEntity oldBeneficiaryPreferredCallEntity = Utils.getClonedEntityForData(entity);
|
||||
entity.setIsDeleted(true);
|
||||
beneficiaryPreferredCallRepository.save(entity);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Delete Beneficiary Preferred Call" operation. **/
|
||||
loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.SOFT_DELETE).oldData(oldBeneficiaryPreferredCallEntity).newData(entity).build());
|
||||
|
||||
log.info("Beneficiary preferred call soft deleted with ID: {}", id);
|
||||
}
|
||||
|
||||
@@ -130,8 +150,13 @@ public class BeneficiaryPreferredCallDao {
|
||||
public void updateBeneficiaryPreferredCallStatus(Long id, BeneficiaryCallStatus status) {
|
||||
log.info("Updating status for beneficiary preferred call with ID: {}", id);
|
||||
BeneficiaryPreferredCallEntity existingEntity = validateBeneficiaryPreferredCall(id);
|
||||
BeneficiaryPreferredCallEntity oldBeneficiaryPreferredCallEntity = Utils.getClonedEntityForData(existingEntity);
|
||||
existingEntity.setStatus(status.getValue());
|
||||
beneficiaryPreferredCallRepository.save(existingEntity);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Update Application" operation. **/
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(httpServletRequest).actionType(VersionActionTypeEnum.UPDATE).oldData(oldBeneficiaryPreferredCallEntity).newData(existingEntity).build());
|
||||
|
||||
log.info("Beneficiary preferred call status updated with ID: {}", existingEntity.getId());
|
||||
}
|
||||
public List<BeneficiaryPreferredCallResponseBean> getBeneficiaryPreferredCallByUserId(UserEntity userEntity, Long companyId) {
|
||||
|
||||
@@ -50,6 +50,12 @@ public enum UserActionContextEnum {
|
||||
GET_APPLICATION_EVALUATION("GET_APPLICATION_EVALUATION"),
|
||||
DELETE_APPLICATION_EVALUATION("DELETE_APPLICATION_EVALUATION"),
|
||||
|
||||
/** Beneficiary Preferred Call action context **/
|
||||
CREATE_BENEFICIARY_PREFERRED_CALL("CREATE_BENEFICIARY_PREFERRED_CALL"),
|
||||
DELETE_BENEFICIARY_PREFERRED_CALL("DELETE_BENEFICIARY_PREFERRED_CALL"),
|
||||
GET_BENEFICIARY_PREFERRED_CALL("GET_BENEFICIARY_PREFERRED_CALL"),
|
||||
UPDATE_BENEFICIARY_PREFERRED_CALL("UPDATE_BENEFICIARY_PREFERRED_CALL"),
|
||||
|
||||
/** Assigned Application action context **/
|
||||
CREATE_ASSIGNED_APPLICATION("CREATE_ASSIGNED_APPLICATION"),
|
||||
DELETE_ASSIGNED_APPLICATION("DELETE_ASSIGNED_APPLICATION"),
|
||||
|
||||
@@ -4,11 +4,15 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.enums.BeneficiaryCallStatus;
|
||||
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
|
||||
import net.gepafin.tendermanagement.model.request.BeneficiaryPreferredCallReq;
|
||||
|
||||
import net.gepafin.tendermanagement.model.request.UserActionRequest;
|
||||
import net.gepafin.tendermanagement.model.response.BeneficiaryPreferredCallResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.service.BeneficiaryPreferredCallService;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.web.rest.api.BeneficiaryPreferredCallApi;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.slf4j.Logger;
|
||||
@@ -27,10 +31,16 @@ public class BeneficiaryPreferredCallApiController implements BeneficiaryPreferr
|
||||
|
||||
@Autowired
|
||||
private BeneficiaryPreferredCallService beneficiaryPreferredCallService;
|
||||
|
||||
@Autowired
|
||||
private LoggingUtil loggingUtil;
|
||||
@Override
|
||||
public ResponseEntity<Response<BeneficiaryPreferredCallResponseBean>> createBeneficiaryPreferredCall(HttpServletRequest request, BeneficiaryPreferredCallReq beneficiaryPreferredCallReq) {
|
||||
log.info("Creating Beneficiary Preferred Call");
|
||||
|
||||
/** This code is responsible for creating user action logs for the "Create Beneficiary Preferred Call" operation. **/
|
||||
loggingUtil.logUserAction(
|
||||
UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.INSERT).actionContext(UserActionContextEnum.CREATE_BENEFICIARY_PREFERRED_CALL).build());
|
||||
|
||||
BeneficiaryPreferredCallResponseBean responseBean = beneficiaryPreferredCallService.createBeneficiaryPreferredCall(request, beneficiaryPreferredCallReq);
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(new Response<>(responseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.BENEFICIARY_PREFERRED_CALL_CREATED_SUCCESS_MSG)));
|
||||
@@ -47,6 +57,12 @@ public class BeneficiaryPreferredCallApiController implements BeneficiaryPreferr
|
||||
@Override
|
||||
public ResponseEntity<Response<BeneficiaryPreferredCallResponseBean>> getBeneficiaryPreferredCallById(HttpServletRequest request, Long id) {
|
||||
log.info("Fetching Beneficiary Preferred Call by ID - ID: {}", id);
|
||||
|
||||
|
||||
/** This code is responsible for creating user action logs for the "Get Beneficiary Preferred Call by id" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
|
||||
.actionContext(UserActionContextEnum.GET_BENEFICIARY_PREFERRED_CALL).build());
|
||||
|
||||
BeneficiaryPreferredCallResponseBean response = beneficiaryPreferredCallService.getBeneficiaryPreferredCallById(request, id);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_BENEFICIARY_PREFERRED_CALL_SUCCESS_MSG)));
|
||||
@@ -55,6 +71,10 @@ public class BeneficiaryPreferredCallApiController implements BeneficiaryPreferr
|
||||
@Override
|
||||
public ResponseEntity<Response<Void>> deleteBeneficiaryPreferredCall(HttpServletRequest request, Long id) {
|
||||
log.info("Deleting Beneficiary Preferred Call - ID: {}", id);
|
||||
|
||||
/** This code is responsible for creating user action logs for the "Delete Beneficiary Preferred Call" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.DELETE).actionContext(UserActionContextEnum.DELETE_BENEFICIARY_PREFERRED_CALL).build());
|
||||
|
||||
beneficiaryPreferredCallService.deleteBeneficiaryPreferredCall(request, id);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.DELETE_BENEFICIARY_PREFERRED_CALL_SUCCESS_MSG)));
|
||||
@@ -63,6 +83,11 @@ public class BeneficiaryPreferredCallApiController implements BeneficiaryPreferr
|
||||
@Override
|
||||
public ResponseEntity<Response<Void>> updateBeneficiaryPreferredCallStatus(HttpServletRequest request, Long id, BeneficiaryCallStatus status) {
|
||||
log.info("Updating status of Beneficiary Preferred Call - ID: {}, Status: {}", id, status);
|
||||
|
||||
/** This code is responsible for "Updating Beneficiary Preferred Call details" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.UPDATE)
|
||||
.actionContext(UserActionContextEnum.UPDATE_BENEFICIARY_PREFERRED_CALL).build());
|
||||
|
||||
beneficiaryPreferredCallService.updateBeneficiaryPreferredCallStatus(request, id, status);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.BENEFICIARY_PREFERRED_CALL_STATUS_UPDATED_SUCCESS_MSG)));
|
||||
@@ -71,6 +96,10 @@ public class BeneficiaryPreferredCallApiController implements BeneficiaryPreferr
|
||||
@Override
|
||||
public ResponseEntity<Response<List<BeneficiaryPreferredCallResponseBean>>> getBeneficiaryPreferredCallByUserId(HttpServletRequest request,Long userId,Long beneficiaryId,Long companyId) {
|
||||
log.info("Fetching all Beneficiary Preferred Calls for User ID");
|
||||
|
||||
/** This code is responsible for creating user action logs for the "Get Beneficiary Preferred Call" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW).actionContext(UserActionContextEnum.GET_BENEFICIARY_PREFERRED_CALL).build());
|
||||
|
||||
List<BeneficiaryPreferredCallResponseBean> response = beneficiaryPreferredCallService.getBeneficiaryPreferredCallByUserId(request, userId,beneficiaryId,companyId);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_ALL_BENEFICIARY_PREFERRED_CALLS_SUCCESS_MSG)));
|
||||
|
||||
Reference in New Issue
Block a user