Done ticket GEPAFINBE-20

This commit is contained in:
rajesh
2024-09-10 18:39:50 +05:30
parent 2d5aeb95b5
commit c93c7a031e
20 changed files with 585 additions and 2 deletions

View File

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

View File

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