Added audit for Beneficiary Preferred Call

This commit is contained in:
rajesh
2024-11-24 16:24:14 +05:30
parent ee7a958a08
commit 85e4efd0dd
3 changed files with 63 additions and 3 deletions

View File

@@ -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)));