Updated get endpoints

This commit is contained in:
rajesh
2024-09-14 20:22:03 +05:30
parent 492317be2e
commit 6224ab526a
13 changed files with 256 additions and 73 deletions

View File

@@ -7,7 +7,10 @@ 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.ApplicationRequest;
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
import net.gepafin.tendermanagement.model.response.ApplicationGetResponseBean;
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
import net.gepafin.tendermanagement.model.response.ApplicationResponseBean;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
@@ -30,11 +33,11 @@ public interface ApplicationApi {
@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) })) })
@PutMapping(value = "/call/{callId}",
@PutMapping(value = "/form/{formId}",
produces = { "application/json" })
ResponseEntity<Response<ApplicationResponseBean>> createApplication(HttpServletRequest request,
@Parameter(description = " Flow request object", required = true) @Valid @RequestBody ApplicationRequestBean applicationRequestBean,
@Parameter(description = "The call ID", required = true) @PathVariable("callId") Long callId);
@Parameter(description = "The form ID", required = true) @PathVariable("formId") Long formId);
@Operation(summary = "Api to get an application by id",
responses = {
@@ -46,8 +49,7 @@ public interface ApplicationApi {
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
@GetMapping(value = "/{applicationId}", produces = "application/json")
ResponseEntity<Response<ApplicationResponseBean>> getApplicationById(HttpServletRequest request,
@Parameter(description = "The application id", required = true) @PathVariable("applicationId") Long applicationId);
ResponseEntity<Response<ApplicationGetResponseBean>> getApplicationByFormId(HttpServletRequest request, @Parameter(description = "The application id", required = true) @PathVariable(value = "applicationId", required = true) Long applicationId,@Parameter(description = "The form id", required = false) @RequestParam(value = "formId",required = false) Long formId);
@Operation(summary = "Api to get all applications",
responses = {
@@ -59,7 +61,7 @@ public interface ApplicationApi {
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
@GetMapping(value = "", produces = "application/json")
ResponseEntity<Response<List<ApplicationResponseBean>>> getAllApplications(HttpServletRequest request);
ResponseEntity<Response<List<ApplicationResponse>>> getAllApplications(HttpServletRequest request);
@Operation(summary = "Api to delete application",
responses = {
@@ -73,5 +75,21 @@ public interface ApplicationApi {
@DeleteMapping(value = "/{applicationId}")
ResponseEntity<Response<Void>> deleteApplication(HttpServletRequest request,
@Parameter(description = "The application id", required = true) @PathVariable("applicationId") Long applicationId);
@Operation(summary = "Api to create application",
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<ApplicationResponse>> createApplicationByCallId(HttpServletRequest request,
@Parameter(description = " Flow request object", required = true) @Valid @RequestBody ApplicationRequest applicationRequest,
@Parameter(description = "The call ID", required = true) @PathVariable("callId") Long callId);
}

View File

@@ -3,9 +3,11 @@ 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.ApplicationRequest;
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
import net.gepafin.tendermanagement.model.response.ApplicationGetResponseBean;
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
import net.gepafin.tendermanagement.model.response.ApplicationResponseBean;
import net.gepafin.tendermanagement.model.response.FlowResponseBean;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.service.ApplicationService;
import net.gepafin.tendermanagement.web.rest.api.ApplicationApi;
@@ -31,16 +33,16 @@ public class ApplicationApiController implements ApplicationApi {
private ApplicationService applicationService;
@Override
public ResponseEntity<Response<ApplicationResponseBean>> createApplication(HttpServletRequest request, ApplicationRequestBean applicationRequestBean, Long callId) {
ApplicationResponseBean applicationResponseBean= applicationService.createApplication(request,applicationRequestBean,callId);
public ResponseEntity<Response<ApplicationResponseBean>> createApplication(HttpServletRequest request, ApplicationRequestBean applicationRequestBean, Long formId) {
ApplicationResponseBean applicationResponseBean= applicationService.createApplication(request,applicationRequestBean,formId);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(applicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_CREATED_SUCCESS_MSG))); }
@Override
public ResponseEntity<Response<ApplicationResponseBean>> getApplicationById(HttpServletRequest request,
Long applicationId) {
public ResponseEntity<Response<ApplicationGetResponseBean>> getApplicationByFormId(HttpServletRequest request
, Long applicationId,Long formId) {
log.info("Get Application by ID - Application ID: {}", applicationId);
ApplicationResponseBean application = applicationService.getApplicationById(request,applicationId);
ApplicationGetResponseBean application = applicationService.getApplicationByFormId(request,applicationId,formId);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(application, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_SUCCESS_MSG)));
}
@@ -55,8 +57,14 @@ public class ApplicationApiController implements ApplicationApi {
}
@Override
public ResponseEntity<Response<List<ApplicationResponseBean>>> getAllApplications(HttpServletRequest request) {
List<ApplicationResponseBean> applications = applicationService.getAllApplications(request);
public ResponseEntity<Response<ApplicationResponse>> createApplicationByCallId(HttpServletRequest request, ApplicationRequest applicationRequest, Long callId) {
ApplicationResponse applicationResponseBean=applicationService.createApplication(request,applicationRequest,callId);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(applicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_CREATED_SUCCESS_MSG)));
}
@Override
public ResponseEntity<Response<List<ApplicationResponse>>> getAllApplications(HttpServletRequest request) {
List<ApplicationResponse> applications = applicationService.getAllApplications(request);
log.info("Get All Applications");
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(applications, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_SUCCESS_MSG)));