Added user action and versioning for Flow get api

This commit is contained in:
rajesh
2024-11-24 21:58:11 +05:30
parent 654666525c
commit 5143795b36
2 changed files with 23 additions and 2 deletions

View File

@@ -105,6 +105,10 @@ public enum UserActionContextEnum {
UPDATE_DOCUMENT("UPDATE_DOCUEMENT"),
UPDATE_IMAGES("UPDATE_IMAGES"),
GET_DOCUMENT("GET_DOCUMENT"),
/** Assigned flow context **/
CREATE_UPDATE_FLOW("CREATE_UPDATE_FLOW"),
GET_FLOW("GET_FLOW"),
/** Login attempt action context **/
GET_LOGIN_ATTEMPT_LIST("GET_LOGIN_ATTEMPT_LIST"),

View File

@@ -3,10 +3,14 @@ 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.UserActionContextEnum;
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
import net.gepafin.tendermanagement.model.request.FlowRequestBean;
import net.gepafin.tendermanagement.model.request.UserActionRequest;
import net.gepafin.tendermanagement.model.response.FlowResponseBean;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.service.FlowService;
import net.gepafin.tendermanagement.util.LoggingUtil;
import net.gepafin.tendermanagement.web.rest.api.FlowApi;
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
import org.springframework.beans.factory.annotation.Autowired;
@@ -22,16 +26,29 @@ public class FlowApiController implements FlowApi {
@Autowired
private FlowService flowService;
@Autowired
private LoggingUtil loggingUtil;
@Override
public ResponseEntity<Response<FlowResponseBean>> createOrUpdateFlow(HttpServletRequest httpServletRequest, FlowRequestBean flowRequestBean, Long callId) {
FlowResponseBean flowResponseBean=flowService.createOrUpdateFlow(httpServletRequest,flowRequestBean,callId);
public ResponseEntity<Response<FlowResponseBean>> createOrUpdateFlow(HttpServletRequest request, FlowRequestBean flowRequestBean, Long callId) {
/** This code is responsible for creating user action logs for the "Create or update Flow" operation. **/
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.INSERT)
.actionContext(UserActionContextEnum.CREATE_UPDATE_FLOW).build());
FlowResponseBean flowResponseBean=flowService.createOrUpdateFlow(request,flowRequestBean,callId);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(flowResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.FLOW_CREATED_SUCCESSFULLY)));
}
@Override
public ResponseEntity<Response<FlowResponseBean>> getFlowByCallId(HttpServletRequest request, Long callId) {
/** This code is responsible for creating user action logs for the "Create or update Flow" operation. **/
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
.actionContext(UserActionContextEnum.GET_FLOW).build());
FlowResponseBean flowResponseBean=flowService.getFlowByCallId(request,callId);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(flowResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.FLOW_FETCHED_SUCCESSFULLY)));