Updated Code

This commit is contained in:
piyuskag
2024-10-27 16:07:56 +05:30
parent 452a661389
commit 90cdc9ba50
19 changed files with 574 additions and 302 deletions

View File

@@ -1,15 +0,0 @@
package net.gepafin.tendermanagement.web.rest.api;
import feign.Param;
import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.Optional;
public interface ApplicationAmendmentRepository extends JpaRepository<ApplicationAmendmentRequestEntity, Long> {
@Query("SELECT app FROM ApplicationAmendmentRequestEntity app WHERE app.id = :id")
ApplicationAmendmentRequestEntity findAmendmentById(@Param("id") Long id);
}

View File

@@ -6,8 +6,8 @@ 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 net.gepafin.tendermanagement.entities.CommunicationAmendmentEntity;
import net.gepafin.tendermanagement.model.request.CommunicationRequestBean;
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentResponse;
import net.gepafin.tendermanagement.model.response.CommunicationResponseBean;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
@@ -17,10 +17,10 @@ import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
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.PutMapping;
import java.util.Optional;
import org.springframework.web.bind.annotation.RequestBody;
@Validated
public interface CommunicationAmendmentApi {
@@ -31,19 +31,19 @@ public interface CommunicationAmendmentApi {
@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 = "", produces = { "application/json" })
ResponseEntity<Response<CommunicationResponseBean>> addCommentToAmendmentRequest(HttpServletRequest request, @Parameter CommunicationRequestBean communicationResponseBean);
@PostMapping(value = "/{amendmentId}", produces = { "application/json" })
ResponseEntity<Response<CommunicationResponseBean>> addCommentToAmendmentRequest(HttpServletRequest request, @RequestBody @Parameter CommunicationRequestBean communicationResponseBean,
@Param(value = "amendmentId") Long amendmentId);
@Operation(summary = "Api to Get Amendment request comment", 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 = "/{amendmentId}/{commentId}", produces = { "application/json" })
ResponseEntity<Response<CommunicationResponseBean>> getAmendmentComments(HttpServletRequest request, @Param(value = "amendmentId") Long id,
@Param(value = "commentId") Long commentId);
@Operation(summary = "API to Get Amendment Request Comment", 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 = "/{amendmentId}", produces = "application/json")
public ResponseEntity<Response<ApplicationAmendmentResponse>> getAmendmentComments(@PathVariable Long amendmentId);
@Operation(summary = "Api to update communication comments", responses = { @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@@ -52,8 +52,9 @@ public interface CommunicationAmendmentApi {
@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 = "", produces = { "application/json" })
ResponseEntity<Response<CommunicationResponseBean>> updateCommunicationAmendment(HttpServletRequest request, @Parameter CommunicationRequestBean communicationResponseBean);
@PutMapping(value = "/{amendmentId}/{commentId}", produces = { "application/json" })
ResponseEntity<Response<CommunicationResponseBean>> updateCommunicationAmendment(HttpServletRequest request, @RequestBody @Parameter CommunicationRequestBean communicationResponseBean,
@PathVariable Long amendmentId, @PathVariable Long commentId);
@Operation(summary = "Api to delete communication comments", responses = { @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {

View File

@@ -3,8 +3,8 @@ 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.entities.CommunicationAmendmentEntity;
import net.gepafin.tendermanagement.model.request.CommunicationRequestBean;
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentResponse;
import net.gepafin.tendermanagement.model.response.CommunicationResponseBean;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.service.CommunicationAmendmentService;
@@ -16,8 +16,6 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Optional;
@RestController
@RequestMapping("${openapi.gepafin.base-path:/v1/communication-amendment}")
public class CommunicationAmendmentController implements CommunicationAmendmentApi {
@@ -26,32 +24,33 @@ public class CommunicationAmendmentController implements CommunicationAmendmentA
CommunicationAmendmentService communicationAmendmentService;
@Override
public ResponseEntity<Response<CommunicationResponseBean>> addCommentToAmendmentRequest(HttpServletRequest request, CommunicationRequestBean communicationRequestBean) {
public ResponseEntity<Response<CommunicationResponseBean>> addCommentToAmendmentRequest(HttpServletRequest request, CommunicationRequestBean communicationRequestBean,
Long amendmentId) {
CommunicationResponseBean communicationResponseBean = communicationAmendmentService.addCommentToAmendmentRequest(communicationRequestBean);
CommunicationResponseBean communicationResponseBean = communicationAmendmentService.addCommentToAmendmentRequest(communicationRequestBean, amendmentId);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(communicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMMUNICATION_ADDED_TO_AMENDMENT_REQUEST_SUCCESS)));
}
@Override
public ResponseEntity<Response<CommunicationResponseBean>> getAmendmentComments(HttpServletRequest request, Long id, Long commentId) {
public ResponseEntity<Response<ApplicationAmendmentResponse>> getAmendmentComments(Long amendmentId) {
CommunicationResponseBean communicationResponseBean = communicationAmendmentService.getAmendmentComments(id, commentId);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(communicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMMUNICATION_ADDED_TO_AMENDMENT_REQUEST_SUCCESS)));
ApplicationAmendmentResponse response = communicationAmendmentService.getAmendmentComments(amendmentId);
return ResponseEntity.ok(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.AMENDMENT_FOUND_SUCCESS)));
}
@Override
public ResponseEntity<Response<CommunicationResponseBean>> updateCommunicationAmendment(HttpServletRequest request, CommunicationRequestBean communicationRequestBean) {
public ResponseEntity<Response<CommunicationResponseBean>> updateCommunicationAmendment(HttpServletRequest request, CommunicationRequestBean communicationRequestBean,
Long amendmentId, Long commentId) {
CommunicationResponseBean communicationResponseBean = communicationAmendmentService.updateCommunicationAmendment(communicationRequestBean);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(communicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMMUNICATION_ADDED_TO_AMENDMENT_REQUEST_SUCCESS)));
CommunicationResponseBean communicationResponseBean = communicationAmendmentService.updateCommunicationAmendment(communicationRequestBean, amendmentId, commentId);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(communicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMMENT_UPDATED_SUCCESS_MSG)));
}
@Override
public ResponseEntity<Response<String>> deleteApplicationAmendmentComment(HttpServletRequest request, Long applicationAmendId, Long commentId) {
String communicationResponseBean = communicationAmendmentService.deleteCommunicationAmendmentComment(applicationAmendId, commentId);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(communicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMMUNICATION_ADDED_TO_AMENDMENT_REQUEST_SUCCESS)));
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(communicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMMENT_DELETED_SUCCESS_MSG)));
}
}