created validate api for call

This commit is contained in:
rajesh
2024-08-28 12:38:11 +05:30
parent ffa07d779b
commit 630643f156
18 changed files with 214 additions and 61 deletions

View File

@@ -23,7 +23,7 @@ import net.gepafin.tendermanagement.model.request.CreateCallRequestStep1;
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep2;
import net.gepafin.tendermanagement.model.request.UpdateCallRequestStep1;
import net.gepafin.tendermanagement.model.response.CallDetailsResponseBean;
import net.gepafin.tendermanagement.model.response.CreateCallResponseBean;
import net.gepafin.tendermanagement.model.response.CallResponse;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
@@ -42,7 +42,7 @@ public interface CallApi {
})
@PostMapping(value = "/step1", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
public ResponseEntity<Response<CreateCallResponseBean>> createCallStep1(HttpServletRequest request,
public ResponseEntity<Response<CallResponse>> createCallStep1(HttpServletRequest request,
@Parameter(description = "Call request object", required = true)
@Valid @RequestBody CreateCallRequestStep1 createCallRequest);
@@ -58,7 +58,7 @@ public interface CallApi {
})
@PutMapping(value = "/step2/{callId}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
public ResponseEntity<Response<CreateCallResponseBean>> createCallStep2(HttpServletRequest request,
public ResponseEntity<Response<CallResponse>> createCallStep2(HttpServletRequest request,
@Parameter(description = "The call id", required = true) @PathVariable("callId") Long callId,
@Parameter(description = "Call request object", required = true) @Valid @RequestBody CreateCallRequestStep2 createCallRequest);
@@ -74,7 +74,7 @@ public interface CallApi {
})
@PutMapping(value = "/step1/{callId}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
public ResponseEntity<Response<CreateCallResponseBean>> updateCallStep1(HttpServletRequest request,
public ResponseEntity<Response<CallResponse>> updateCallStep1(HttpServletRequest request,
@Parameter(description = "The call id", required = true) @PathVariable("callId") Long callId,
@Parameter(description = "Call request object", required = true) @Valid @RequestBody UpdateCallRequestStep1 updateCallRequest);
@Operation(summary = "Api to get call by id",
@@ -88,8 +88,10 @@ public interface CallApi {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
@GetMapping(value = "/{callId}",
produces = { "application/json" })
ResponseEntity<Response<CreateCallResponseBean>> getCallById(
ResponseEntity<Response<CallResponse>> getCallById(
@Parameter(description = "The call ID", required = true) @PathVariable("callId") Long callId);
@Operation(summary = "Api to get all calls",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@@ -102,5 +104,21 @@ public interface CallApi {
@GetMapping(value = "",
produces = { "application/json" })
ResponseEntity<Response<List<CallDetailsResponseBean>>> getAllCalls();
@Operation(summary = "Api to validate call",
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 = "/validate/{callId}", produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
public ResponseEntity<Response<CallResponse>> validateCall(HttpServletRequest request,
@Parameter(description = "The call id", required = true) @PathVariable("callId") Long callId);
}

View File

@@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.*;
public interface EvaluationCriteriaApi {
@Operation(summary = "API to create evaluation criteria",
@Operation(summary = "Api to create evaluation criteria",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@@ -28,12 +28,12 @@ public interface EvaluationCriteriaApi {
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
})
@PostMapping(value = "/criteria", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@PostMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Response<EvaluationCriteriaResponseBean>> createEvaluationCriteria(HttpServletRequest request,
@Parameter(description = "Evaluation criteria request object", required = true)
@Valid @RequestBody EvaluationCriteriaRequest createCallRequest);
@Operation(summary = "API to get evaluation criteria by id",
@Operation(summary = "Api to get evaluation criteria by id",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@@ -41,7 +41,7 @@ public interface EvaluationCriteriaApi {
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) }))
})
@GetMapping(value = "/criteria/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Response<EvaluationCriteriaResponseBean>> getEvaluationCriteriaById(HttpServletRequest request,
@Parameter(description = "evaluation criteria id", required = true)
@PathVariable Long id);
@@ -56,7 +56,7 @@ public interface EvaluationCriteriaApi {
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
})
@PutMapping(value = "/criteria/{id}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@PutMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Response<EvaluationCriteriaResponseBean>> updateEvaluationCriteria(HttpServletRequest request,
@Parameter(description = "evaluation criteria id", required = true)
@PathVariable Long id,
@@ -71,7 +71,7 @@ public interface EvaluationCriteriaApi {
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) }))
})
@DeleteMapping(value = "/criteria/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@DeleteMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Void> deleteEvaluationCriteria(HttpServletRequest request,
@Parameter(description = "evaluation criteria id", required = true)
@PathVariable Long id);

View File

@@ -0,0 +1,27 @@
package net.gepafin.tendermanagement.web.rest.api.errors;
import java.util.List;
public class ValidationException extends CustomValidationException {
private final Status status;
private static final long serialVersionUID = 1L;
private final List<String> errors;
public ValidationException(Status status, List<String> errors) {
super(status, errors.toString());
this.errors = errors;
this.status = status;
}
public List<String> getErrors() {
return errors;
}
public Status getStatus() {
return status;
}
}

View File

@@ -16,7 +16,7 @@ import net.gepafin.tendermanagement.model.request.CreateCallRequestStep1;
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep2;
import net.gepafin.tendermanagement.model.request.UpdateCallRequestStep1;
import net.gepafin.tendermanagement.model.response.CallDetailsResponseBean;
import net.gepafin.tendermanagement.model.response.CreateCallResponseBean;
import net.gepafin.tendermanagement.model.response.CallResponse;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.service.CallService;
import net.gepafin.tendermanagement.web.rest.api.CallApi;
@@ -33,31 +33,31 @@ public class CallApiController implements CallApi {
@Override
@Transactional(rollbackFor=Exception.class)
public ResponseEntity<Response<CreateCallResponseBean>> createCallStep1(HttpServletRequest request, CreateCallRequestStep1 createCallRequest) {
CreateCallResponseBean createCallResponseBean = callService.createCallStep1(request, createCallRequest);
public ResponseEntity<Response<CallResponse>> createCallStep1(HttpServletRequest request, CreateCallRequestStep1 createCallRequest) {
CallResponse createCallResponseBean = callService.createCallStep1(request, createCallRequest);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(createCallResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_CREATED_SUCCESSFULLY_MSG)));
}
@Override
@Transactional(rollbackFor=Exception.class)
public ResponseEntity<Response<CreateCallResponseBean>> createCallStep2(HttpServletRequest request, Long callId, CreateCallRequestStep2 createCallRequest) {
CreateCallResponseBean createCallResponseBean = callService.createCallStep2(request, callId, createCallRequest);
public ResponseEntity<Response<CallResponse>> createCallStep2(HttpServletRequest request, Long callId, CreateCallRequestStep2 createCallRequest) {
CallResponse createCallResponseBean = callService.createCallStep2(request, callId, createCallRequest);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(createCallResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_CREATED_SUCCESSFULLY_MSG)));
}
@Override
@Transactional(rollbackFor=Exception.class)
public ResponseEntity<Response<CreateCallResponseBean>> updateCallStep1(HttpServletRequest request, Long callId, UpdateCallRequestStep1 updateCallRequest) {
CreateCallResponseBean createCallResponseBean = callService.updateCallStep1(request, callId, updateCallRequest);
public ResponseEntity<Response<CallResponse>> updateCallStep1(HttpServletRequest request, Long callId, UpdateCallRequestStep1 updateCallRequest) {
CallResponse createCallResponseBean = callService.updateCallStep1(request, callId, updateCallRequest);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(createCallResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_UPDATE_SUCCESSFULLY_MSG)));
}
@Override
@Transactional(readOnly = true)
public ResponseEntity<Response<CreateCallResponseBean>> getCallById(Long callId) {
CreateCallResponseBean createCallResponseBean = callService.getCallById(callId);
public ResponseEntity<Response<CallResponse>> getCallById(Long callId) {
CallResponse createCallResponseBean = callService.getCallById(callId);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(createCallResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_FETCH_SUCCESS_MSG)));
}
@@ -71,4 +71,11 @@ public class CallApiController implements CallApi {
.body(new Response<>(calls, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_FETCH_SUCCESS_MSG)));
}
@Override
public ResponseEntity<Response<CallResponse>> validateCall(HttpServletRequest request, Long callId) {
CallResponse call = callService.validateCall(callId);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(call, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_FETCH_SUCCESS_MSG)));
}
}

View File

@@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("${openapi.gepafin.base-path:/v1/evaluation}")
@RequestMapping("${openapi.gepafin.base-path:/v1/evaluationCriteria}")
public class EvaluationCriteriaApiController implements EvaluationCriteriaApi {
@Autowired

View File

@@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("${openapi.gepafin.base-path:/v1/lookupdata}")
@RequestMapping("${openapi.gepafin.base-path:/v1/lookUpData}")
public class LookUpDataApiController implements LookUpDataApi {
@Autowired