Done ticket GEPAFINBE-20
This commit is contained in:
@@ -104,5 +104,8 @@ public class GepafinConstant {
|
||||
public static final String STATUS_CANNOT_BE_CHANGED = "status.cannot.be.changed";
|
||||
public static final String PUBLISHED_CALL_NOT_UPDATE = "published.call.not.update";
|
||||
public static final String INVALID_USER = "invalid_user";
|
||||
|
||||
public static final String FLOW_CREATED_SUCCESSFULLY="flow.created.successfully";
|
||||
public static final String FLOW_FETCHED_SUCCESSFULLY="flow.fetched.successfully";
|
||||
public static final String FLOW_ALREADY_EXISTS="flow.already.exists";
|
||||
public static final String FLOW_REQUEST_NOT_PROPER="flow.request.not.complete";
|
||||
}
|
||||
|
||||
175
src/main/java/net/gepafin/tendermanagement/dao/FlowDao.java
Normal file
175
src/main/java/net/gepafin/tendermanagement/dao/FlowDao.java
Normal file
@@ -0,0 +1,175 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.CallEntity;
|
||||
import net.gepafin.tendermanagement.entities.FlowDataEntity;
|
||||
import net.gepafin.tendermanagement.entities.FlowDataEntity;
|
||||
import net.gepafin.tendermanagement.entities.FlowEdgesEntity;
|
||||
import net.gepafin.tendermanagement.model.request.FlowDataRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.FlowEdgesRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.FlowRequestBean;
|
||||
import net.gepafin.tendermanagement.model.response.EvaluationCriteriaResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.FlowDataResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.FlowEdgesResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.FlowResponseBean;
|
||||
import net.gepafin.tendermanagement.repositories.CallRepository;
|
||||
import net.gepafin.tendermanagement.repositories.FlowDataRepository;
|
||||
import net.gepafin.tendermanagement.repositories.FlowDataRepository;
|
||||
import net.gepafin.tendermanagement.repositories.FlowEdgesRepository;
|
||||
import net.gepafin.tendermanagement.repositories.FlowEdgesRepository;
|
||||
import net.gepafin.tendermanagement.service.CallService;
|
||||
import net.gepafin.tendermanagement.service.FormService;
|
||||
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.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class FlowDao {
|
||||
|
||||
@Autowired
|
||||
private FlowDataRepository flowDataRepository;
|
||||
|
||||
@Autowired
|
||||
private FlowEdgesRepository flowEdgesRepository;
|
||||
|
||||
@Autowired
|
||||
private CallRepository callRepository;
|
||||
|
||||
@Autowired
|
||||
private CallService callService;
|
||||
|
||||
@Autowired
|
||||
private FormService formService;
|
||||
|
||||
public FlowResponseBean createFlow(FlowRequestBean flowRequestBean, Long callId) {
|
||||
validateFlowRequestBean(flowRequestBean);
|
||||
CallEntity call = setInitialAndFinalFormInCall(flowRequestBean, callId);
|
||||
checkIfFlowExits(callId);
|
||||
validateFlowRequest(flowRequestBean);
|
||||
List<FlowDataEntity> flowDataEntities = createFlowData(flowRequestBean,call);
|
||||
List<FlowEdgesEntity> flowEdgesEntities = createFlowEdges(flowRequestBean,call);
|
||||
FlowResponseBean flowResponseBean = getFlowByCallId(call.getId());
|
||||
return flowResponseBean;
|
||||
}
|
||||
|
||||
public void validateFlowRequestBean(FlowRequestBean flowRequestBean){
|
||||
if(flowRequestBean.getFlowData()==null || flowRequestBean.getFlowEdges()==null){
|
||||
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.FLOW_REQUEST_NOT_PROPER));
|
||||
}
|
||||
}
|
||||
|
||||
public void checkIfFlowExits(Long callId) {
|
||||
List<FlowDataEntity> flowDataEntities = flowDataRepository.findByCallId(callId);
|
||||
List<FlowEdgesEntity> flowEdgesEntities = flowEdgesRepository.findByCallId(callId);
|
||||
if (!flowDataEntities.isEmpty() || !flowEdgesEntities.isEmpty()) {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.FLOW_ALREADY_EXISTS));
|
||||
}
|
||||
}
|
||||
|
||||
public void validateFlowRequest(FlowRequestBean flowRequestBean) {
|
||||
formService.validateForm(flowRequestBean.getInitialForm());
|
||||
formService.validateForm(flowRequestBean.getFinalForm());
|
||||
flowRequestBean.getFlowData().forEach(flowData -> formService.validateForm(flowData.getFormId()));
|
||||
}
|
||||
|
||||
private List<FlowEdgesResponseBean> createFlowEdgesResponseBean(List<FlowEdgesEntity> flowEdgesEntities) {
|
||||
List<FlowEdgesResponseBean> flowEdgesResponseBeans = flowEdgesEntities.stream()
|
||||
.map(this::convertFlowEdgesEntityToFlowEdgesResponseBean).collect(Collectors.toList());
|
||||
return flowEdgesResponseBeans;
|
||||
}
|
||||
|
||||
private List<FlowDataResponseBean> createFlowDataResponseBean(List<FlowDataEntity> flowDataEntities) {
|
||||
List<FlowDataResponseBean> flowDataResponseBeans = flowDataEntities.stream()
|
||||
.map(this::convertFlowDataEntityToFlowDataResponseBean).collect(Collectors.toList());
|
||||
return flowDataResponseBeans;
|
||||
}
|
||||
|
||||
public FlowResponseBean setInitialAndFinalFormInFlowResponseBean(FlowResponseBean flowResponseBean, CallEntity call) {
|
||||
flowResponseBean.setInitialForm(call.getInitialForm());
|
||||
flowResponseBean.setFinalForm(call.getFinalForm());
|
||||
return flowResponseBean;
|
||||
}
|
||||
|
||||
private CallEntity setInitialAndFinalFormInCall(FlowRequestBean flowRequestBean, Long callId) {
|
||||
CallEntity call = callService.validateCall(callId);
|
||||
call.setInitialForm(flowRequestBean.getInitialForm());
|
||||
call.setFinalForm(flowRequestBean.getFinalForm());
|
||||
call = callRepository.save(call);
|
||||
return call;
|
||||
}
|
||||
|
||||
public List<FlowDataEntity> createFlowData(FlowRequestBean flowRequestBean, CallEntity call) {
|
||||
List<FlowDataEntity> flowDataEntities = flowRequestBean.getFlowData().stream()
|
||||
.map(flowDataRequestBean -> createFlowDataEntity(flowDataRequestBean, call))
|
||||
.collect(Collectors.toList());
|
||||
return flowDataRepository.saveAll(flowDataEntities);
|
||||
}
|
||||
|
||||
public FlowDataEntity createFlowDataEntity(FlowDataRequestBean flowDataRequestBean,CallEntity call) {
|
||||
FlowDataEntity flowDataEntity = new FlowDataEntity();
|
||||
flowDataEntity.setFormId(flowDataRequestBean.getFormId());
|
||||
flowDataEntity.setChoosenField(flowDataRequestBean.getChosenField());
|
||||
flowDataEntity.setChoosenValue(flowDataRequestBean.getChosenValue());
|
||||
flowDataEntity.setCallId(call.getId());
|
||||
return flowDataEntity;
|
||||
}
|
||||
|
||||
public List<FlowEdgesEntity> createFlowEdges(FlowRequestBean flowRequestBean, CallEntity call) {
|
||||
List<FlowEdgesEntity> flowEdgesEntities = flowRequestBean.getFlowEdges().stream()
|
||||
.map(flowEdgesRequestBean -> createFlowEdgesEntity(flowEdgesRequestBean, call))
|
||||
.collect(Collectors.toList());
|
||||
return flowEdgesRepository.saveAll(flowEdgesEntities);
|
||||
}
|
||||
|
||||
public FlowEdgesEntity createFlowEdgesEntity(FlowEdgesRequestBean flowEdgesRequestBean,CallEntity call) {
|
||||
FlowEdgesEntity flowEdgesEntity = new FlowEdgesEntity();
|
||||
flowEdgesEntity.setSourceId(Long.valueOf(flowEdgesRequestBean.getSource()));
|
||||
flowEdgesEntity.setTargetId(Long.valueOf(flowEdgesRequestBean.getTarget()));
|
||||
flowEdgesEntity.setType(flowEdgesRequestBean.getType());
|
||||
flowEdgesEntity.setCallId(call.getId());
|
||||
return flowEdgesEntity;
|
||||
}
|
||||
|
||||
public FlowDataResponseBean convertFlowDataEntityToFlowDataResponseBean(FlowDataEntity flowDataEntity) {
|
||||
FlowDataResponseBean flowDataResponseBean = new FlowDataResponseBean();
|
||||
flowDataResponseBean.setId(flowDataEntity.getId());
|
||||
flowDataResponseBean.setFormId(flowDataEntity.getFormId());
|
||||
flowDataResponseBean.setChosenField(flowDataEntity.getChoosenField());
|
||||
flowDataResponseBean.setChosenValue(flowDataEntity.getChoosenValue());
|
||||
return flowDataResponseBean;
|
||||
}
|
||||
|
||||
public FlowEdgesResponseBean convertFlowEdgesEntityToFlowEdgesResponseBean(FlowEdgesEntity flowEdgesEntity) {
|
||||
FlowEdgesResponseBean flowEdgesResponseBean = new FlowEdgesResponseBean();
|
||||
flowEdgesResponseBean.setId(flowEdgesEntity.getId());
|
||||
flowEdgesResponseBean.setType(flowEdgesEntity.getType());
|
||||
flowEdgesResponseBean.setSource(String.valueOf(flowEdgesEntity.getSourceId()));
|
||||
flowEdgesResponseBean.setTarget(String.valueOf(flowEdgesEntity.getTargetId()));
|
||||
return flowEdgesResponseBean;
|
||||
}
|
||||
|
||||
public FlowResponseBean getFlowByCallId(Long callId){
|
||||
CallEntity call= callService.validateCall(callId);
|
||||
FlowResponseBean flowResponseBean=new FlowResponseBean();
|
||||
List<FlowDataEntity> flowDataEntities=flowDataRepository.findByCallId(call.getId());
|
||||
List<FlowEdgesEntity> flowEdgesEntities=flowEdgesRepository.findByCallId(call.getId());
|
||||
List<FlowDataResponseBean> flowDataResponseBeans=createFlowDataResponseBean(flowDataEntities);
|
||||
List<FlowEdgesResponseBean> flowEdgesResponseBeans=createFlowEdgesResponseBean(flowEdgesEntities);
|
||||
flowResponseBean.setFlowData(flowDataResponseBeans);
|
||||
flowResponseBean.setFlowEdges(flowEdgesResponseBeans);
|
||||
if(flowResponseBean.getFlowData().isEmpty() || flowResponseBean.getFlowEdges().isEmpty()){
|
||||
return null;
|
||||
}
|
||||
flowResponseBean.setCallId(call.getId());
|
||||
flowResponseBean.setInitialForm(call.getInitialForm());
|
||||
flowResponseBean.setFinalForm(call.getFinalForm());
|
||||
return flowResponseBean;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -62,5 +62,11 @@ public class CallEntity extends BaseEntity {
|
||||
|
||||
@Column(name = "CONFIDI")
|
||||
private Boolean confidi;
|
||||
|
||||
@Column(name="INITIAL_FORM")
|
||||
private Long initialForm;
|
||||
|
||||
@Column(name="FINAL_FORM")
|
||||
private Long finalForm;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package net.gepafin.tendermanagement.entities;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Table(name = "FLOW_DATA")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class FlowDataEntity extends BaseEntity{
|
||||
|
||||
@Column(name = "FORM_ID")
|
||||
private Long formId;
|
||||
|
||||
@Column(name = "CHOOSEN_FIELD")
|
||||
private String choosenField;
|
||||
|
||||
@Column(name = "CHOOSEN_VALUE")
|
||||
private String choosenValue;
|
||||
|
||||
@Column(name="CALL_ID")
|
||||
private Long callId;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Table(name = "FLOW_EDGES")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class FlowEdgesEntity extends BaseEntity {
|
||||
|
||||
@Column(name = "SOURCE_ID")
|
||||
private Long sourceId;
|
||||
|
||||
@Column(name = "TARGET_ID")
|
||||
private Long targetId;
|
||||
|
||||
@Column(name = "TYPE", length = 255)
|
||||
private String type;
|
||||
|
||||
@Column(name="CALL_ID")
|
||||
private Long callId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.gepafin.tendermanagement.model.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FlowDataRequestBean {
|
||||
|
||||
private Long formId;
|
||||
|
||||
private String chosenField;
|
||||
|
||||
private String chosenValue;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.gepafin.tendermanagement.model.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FlowEdgesRequestBean {
|
||||
|
||||
private String source;
|
||||
|
||||
private String target;
|
||||
|
||||
private String type;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package net.gepafin.tendermanagement.model.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class FlowRequestBean {
|
||||
|
||||
private Long initialForm;
|
||||
|
||||
private Long finalForm;
|
||||
|
||||
private List<FlowDataRequestBean> flowData;
|
||||
|
||||
private List<FlowEdgesRequestBean> flowEdges;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.model.BaseBean;
|
||||
|
||||
@Data
|
||||
public class FlowDataResponseBean {
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long formId;
|
||||
|
||||
private String chosenField;
|
||||
|
||||
private String chosenValue;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.model.BaseBean;
|
||||
import org.springframework.security.core.parameters.P;
|
||||
|
||||
@Data
|
||||
public class FlowEdgesResponseBean {
|
||||
private Long id;
|
||||
|
||||
private String source;
|
||||
|
||||
private String target;
|
||||
|
||||
private String type;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.model.request.FlowDataRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.FlowEdgesRequestBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class FlowResponseBean {
|
||||
|
||||
private Long callId;
|
||||
|
||||
private Long initialForm;
|
||||
|
||||
private Long finalForm;
|
||||
|
||||
private List<FlowDataResponseBean> flowData;
|
||||
|
||||
private List<FlowEdgesResponseBean> flowEdges;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.FlowDataEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface FlowDataRepository extends JpaRepository<FlowDataEntity,Long> {
|
||||
|
||||
public List<FlowDataEntity> findByCallId(Long callId);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.FlowEdgesEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface FlowEdgesRepository extends JpaRepository<net.gepafin.tendermanagement.entities.FlowEdgesEntity,Long> {
|
||||
|
||||
public List<FlowEdgesEntity> findByCallId(Long callId);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package net.gepafin.tendermanagement.service;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.model.request.FlowRequestBean;
|
||||
import net.gepafin.tendermanagement.model.response.FlowResponseBean;
|
||||
|
||||
public interface FlowService {
|
||||
|
||||
public FlowResponseBean createFlow(HttpServletRequest httpServletRequest, FlowRequestBean flowRequestBean, Long callId);
|
||||
|
||||
public FlowResponseBean getFlowByCallId(HttpServletRequest request, Long callId);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package net.gepafin.tendermanagement.service.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.dao.FlowDao;
|
||||
import net.gepafin.tendermanagement.model.request.FlowRequestBean;
|
||||
import net.gepafin.tendermanagement.model.response.FlowResponseBean;
|
||||
import net.gepafin.tendermanagement.service.FlowService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class FlowServiceImpl implements FlowService {
|
||||
|
||||
@Autowired
|
||||
private FlowDao flowDao;
|
||||
|
||||
@Override
|
||||
public FlowResponseBean createFlow(HttpServletRequest httpServletRequest, FlowRequestBean flowRequestBean, Long callId) {
|
||||
return flowDao.createFlow(flowRequestBean,callId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlowResponseBean getFlowByCallId(HttpServletRequest request, Long callId) {
|
||||
return flowDao.getFlowByCallId(callId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
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 jakarta.validation.Valid;
|
||||
import net.gepafin.tendermanagement.model.request.FlowRequestBean;
|
||||
import net.gepafin.tendermanagement.model.response.FlowResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.FormResponseBean;
|
||||
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.validation.annotation.Validated;
|
||||
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.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Validated
|
||||
public interface FlowApi {
|
||||
|
||||
@Operation(summary = "Api to create flow",
|
||||
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 = "/call/{callId}",
|
||||
produces = { "application/json" })
|
||||
ResponseEntity<Response<FlowResponseBean>> createFlow(HttpServletRequest request,
|
||||
@Parameter(description = " Flow request object", required = true) @Valid @RequestBody FlowRequestBean flowRequestBean,
|
||||
@Parameter(description = "The call ID", required = true) @PathVariable("callId") Long callId);
|
||||
|
||||
@Operation(summary = "Api to get flow by callId",
|
||||
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 = "/call/{callId}",
|
||||
produces = { "application/json" })
|
||||
ResponseEntity<Response<FlowResponseBean>> getFlowByCallId(HttpServletRequest request,
|
||||
@Parameter(description = "The call ID", required = true) @PathVariable("callId") Long callId);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
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.model.request.FlowRequestBean;
|
||||
import net.gepafin.tendermanagement.model.response.FlowResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.service.FlowService;
|
||||
import net.gepafin.tendermanagement.web.rest.api.FlowApi;
|
||||
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.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("${openapi.gepafin.base-path:/v1/flow}")
|
||||
public class FlowApiController implements FlowApi {
|
||||
|
||||
@Autowired
|
||||
private FlowService flowService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor=Exception.class)
|
||||
public ResponseEntity<Response<FlowResponseBean>> createFlow(HttpServletRequest httpServletRequest, FlowRequestBean flowRequestBean, Long callId) {
|
||||
FlowResponseBean flowResponseBean=flowService.createFlow(httpServletRequest,flowRequestBean,callId);
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(new Response<>(flowResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.FLOW_CREATED_SUCCESSFULLY)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor=Exception.class)
|
||||
public ResponseEntity<Response<FlowResponseBean>> getFlowByCallId(HttpServletRequest request, Long callId) {
|
||||
FlowResponseBean flowResponseBean=flowService.getFlowByCallId(request,callId);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(flowResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.FLOW_FETCHED_SUCCESSFULLY)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user