From 452a661389da3f4efa2645709fcc156f5781cf49 Mon Sep 17 00:00:00 2001 From: piyuskag Date: Sat, 26 Oct 2024 12:11:30 +0530 Subject: [PATCH] Communication amend test. --- .../constants/GepafinConstant.java | 7 + .../dao/CommunicationAmendmentDao.java | 126 ++++++++++++++++++ .../ApplicationAmendmentRequestEntity.java | 37 +++++ .../CommunicationAmendmentEntity.java | 31 +++++ .../request/CommunicationRequestBean.java | 11 ++ .../response/CommunicationResponseBean.java | 11 ++ .../CommunicationAmendmentRepository.java | 14 ++ .../CommunicationAmendmentService.java | 17 +++ .../CommunicationAmendmentServiceImpl.java | 38 ++++++ .../api/ApplicationAmendmentRepository.java | 15 +++ .../rest/api/CommunicationAmendmentApi.java | 67 ++++++++++ .../CommunicationAmendmentController.java | 57 ++++++++ .../db/changelog/db.changelog-1.0.0.xml | 60 ++++++++- 13 files changed, 489 insertions(+), 2 deletions(-) create mode 100644 src/main/java/net/gepafin/tendermanagement/dao/CommunicationAmendmentDao.java create mode 100644 src/main/java/net/gepafin/tendermanagement/entities/ApplicationAmendmentRequestEntity.java create mode 100644 src/main/java/net/gepafin/tendermanagement/entities/CommunicationAmendmentEntity.java create mode 100644 src/main/java/net/gepafin/tendermanagement/model/request/CommunicationRequestBean.java create mode 100644 src/main/java/net/gepafin/tendermanagement/model/response/CommunicationResponseBean.java create mode 100644 src/main/java/net/gepafin/tendermanagement/repositories/CommunicationAmendmentRepository.java create mode 100644 src/main/java/net/gepafin/tendermanagement/service/CommunicationAmendmentService.java create mode 100644 src/main/java/net/gepafin/tendermanagement/service/impl/CommunicationAmendmentServiceImpl.java create mode 100644 src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationAmendmentRepository.java create mode 100644 src/main/java/net/gepafin/tendermanagement/web/rest/api/CommunicationAmendmentApi.java create mode 100644 src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/CommunicationAmendmentController.java diff --git a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java index bdcf563f..37768891 100644 --- a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java +++ b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java @@ -260,5 +260,12 @@ public class GepafinConstant { public static final String S3_PATH_CONFIG_DUPLICATE_TYPE_ALREADY_EXIST ="s3.path.config.already.exist."; public static final String S3_PATH_GENERATION_ERROR_MSG ="s3.path.config.already.exist."; public static final String INVALID_APPLICATION_STATUS = "invalid.application.status"; + + public static final String COMMUNICATION_ADDED_TO_AMENDMENT_REQUEST_SUCCESS = "added.comment.to.amendment.request.success"; + public static final String AMENDMENT_NOT_FOUND = "amendment.not.found"; + public static final String COMMENT_NOT_FOUND = "comment.not.found"; + public static final String COMMENT_UPDATED_SUCCESS_MSG = "comment.updated.successfully"; + public static final String COMMENT_DELETED_SUCCESS_MSG = "comment.deleted.successfully"; + public static final String COMMENT_NOT_ASSOCIATE_WITH_AMENDMENT_ID_ERROR_MSG = "comment.not.associate.with.amendment"; } diff --git a/src/main/java/net/gepafin/tendermanagement/dao/CommunicationAmendmentDao.java b/src/main/java/net/gepafin/tendermanagement/dao/CommunicationAmendmentDao.java new file mode 100644 index 00000000..e5369f1d --- /dev/null +++ b/src/main/java/net/gepafin/tendermanagement/dao/CommunicationAmendmentDao.java @@ -0,0 +1,126 @@ +package net.gepafin.tendermanagement.dao; + +import net.gepafin.tendermanagement.config.Translator; +import net.gepafin.tendermanagement.constants.GepafinConstant; +import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity; +import net.gepafin.tendermanagement.entities.CommunicationAmendmentEntity; +import net.gepafin.tendermanagement.model.request.CommunicationRequestBean; +import net.gepafin.tendermanagement.model.response.CommunicationResponseBean; +import net.gepafin.tendermanagement.repositories.CommunicationAmendmentRepository; +import net.gepafin.tendermanagement.web.rest.api.ApplicationAmendmentRepository; +import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException; +import net.gepafin.tendermanagement.web.rest.api.errors.Status; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.time.Instant; +import java.util.Optional; + +@Component +public class CommunicationAmendmentDao { + private static final Logger log = LoggerFactory.getLogger(CommunicationAmendmentDao.class); + + @Autowired + CommunicationAmendmentRepository communicationAmendmentRepository; + + @Autowired + ApplicationAmendmentRepository applicationAmendmentRepository; + + // @Autowired + // ApplicationAmendmentRequestRepository applicationAmendmentRequestRepository; + + public CommunicationResponseBean addCommentToAmendmentRequest(CommunicationRequestBean communicationReq) { + + log.info("Adding communication request..."); + + // Fetch amendment request by ID to set the relationship + ApplicationAmendmentRequestEntity amendmentRequest = applicationAmendmentRepository + .findAmendmentById(communicationReq.getAmendmentId()); + // Create and populate CommunicationAmendmentEntity + CommunicationAmendmentEntity communicationAmendmentEntity = new CommunicationAmendmentEntity(); + communicationAmendmentEntity.setAmendmentRequest(amendmentRequest); + communicationAmendmentEntity.setCommunicationTitle(communicationReq.getTitle()); + communicationAmendmentEntity.setCommunicationComment(communicationReq.getComment()); + communicationAmendmentEntity.setIsDeleted(false); + + // Save the communication amendment entity + communicationAmendmentEntity = communicationAmendmentRepository.save(communicationAmendmentEntity); + log.info("Added comment: {}", communicationAmendmentEntity); + + // Convert and return the response bean + return convertToCommunicationResponseBean(communicationAmendmentEntity); + } + + public String deleteCommunicationAmendmentComment(Long amendmentId, Long commentId) { + // Optional amendmentData = communicationAmendmentRepository.findById(amendmentId); + // if(amendmentData.isEmpty()) { + // throw new CustomValidationException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.COMMENT_NOT_ASSOCIATE_WITH_AMENDMENT_ID_ERROR_MSG)); + // } + Optional data = communicationAmendmentRepository.findById(commentId); + if (data.isEmpty()) { + throw new CustomValidationException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.COMMENT_NOT_FOUND)); + } + communicationAmendmentRepository.deleteById(commentId); + return "Deleted Comment Successfully."; + } + public CommunicationResponseBean updateCommunicationAmendment(CommunicationRequestBean communicationRequestBean) { + + log.info("Updating communication comment..."); + CommunicationAmendmentEntity communicationAmendmentEntity = convertToCommunicationAmendmentEntity(communicationRequestBean); + communicationAmendmentEntity = communicationAmendmentRepository.save(communicationAmendmentEntity); + log.info("Updated Comment {}", communicationAmendmentEntity); + return convertToCommunicationResponseBean(communicationAmendmentEntity); + + } + public CommunicationResponseBean getAmendmentComments(Long amendmentId, Long commentId) { + // Optional amendmentData = communicationAmendmentRepository.findById(amendmentId); + // if(amendmentData.isEmpty()) { + // throw new CustomValidationException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.AMENDMENT_NOT_FOUND)); + // } + CommunicationAmendmentEntity commentData = communicationAmendmentRepository.findCommentsById(commentId); + CommunicationResponseBean data = convertToCommunicationResponseBean1(commentData); + return data; + + } + private CommunicationResponseBean convertToCommunicationResponseBean(CommunicationAmendmentEntity entity) { + + CommunicationResponseBean response = new CommunicationResponseBean(); + response.setComment(entity.getCommunicationComment()); + response.setCommunicationAddedDate(Instant.now()); + return response; + } + private CommunicationResponseBean convertToCommunicationResponseBean1(CommunicationAmendmentEntity entity) { + + CommunicationResponseBean response = new CommunicationResponseBean(); + response.setComment(entity.getCommunicationComment()); + response.setCommunicationAddedDate(Instant.now()); + return response; + } + + private CommunicationAmendmentEntity convertToCommunicationAmendmentEntity(CommunicationRequestBean communicationReq) { + + CommunicationAmendmentEntity communicationAmendmentEntity = new CommunicationAmendmentEntity(); + ApplicationAmendmentRequestEntity entity = applicationAmendmentRepository.findAmendmentById(communicationReq.getAmendmentId()); + if (entity == null) { + throw new CustomValidationException(Status.NOT_FOUND, "Amendment Request not found for id: " + communicationReq.getAmendmentId()); + } + communicationAmendmentEntity.setAmendmentRequest(entity); + communicationAmendmentEntity.setCommunicationTitle(communicationReq.getComment()); + communicationAmendmentEntity.setCommunicationComment(communicationReq.getComment()); + return communicationAmendmentEntity; + } + public ApplicationAmendmentRequestEntity getAmendmentRequestById(Long id) { + + if(id==null){ + throw new CustomValidationException(Status.BAD_REQUEST, "Please provide amendmentId" + null); + } + ApplicationAmendmentRequestEntity applicationAmendmentData = applicationAmendmentRepository.findAmendmentById(id); + if(Boolean.FALSE.equals(applicationAmendmentData)){ + throw new CustomValidationException(Status.NOT_FOUND, "Amendment Request not found for id: " + applicationAmendmentData.getId()); + } + return applicationAmendmentData; + } + +} diff --git a/src/main/java/net/gepafin/tendermanagement/entities/ApplicationAmendmentRequestEntity.java b/src/main/java/net/gepafin/tendermanagement/entities/ApplicationAmendmentRequestEntity.java new file mode 100644 index 00000000..8e36d49d --- /dev/null +++ b/src/main/java/net/gepafin/tendermanagement/entities/ApplicationAmendmentRequestEntity.java @@ -0,0 +1,37 @@ +package net.gepafin.tendermanagement.entities; + +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; +import lombok.Data; + +import java.util.List; + +@Entity +@Table(name = "application_amendment_request") +@Data +public class ApplicationAmendmentRequestEntity extends BaseEntity { + + @Column(name = "NOTE") + private String note; + + @Column(name = "RESPONSE_DAYS") + private Long responseDays; + + @Column(name = "IS_NOTIFICATION") + private Boolean isNotification; + + @Column(name = "IS_EMAIL") + private Boolean isEmail; + + @ElementCollection + @Column(name = "FIELD_ID") + private List fieldId; + + @OneToMany(mappedBy = "amendmentRequest", cascade = CascadeType.ALL) + private List communicationAmendmentEntities; +} + diff --git a/src/main/java/net/gepafin/tendermanagement/entities/CommunicationAmendmentEntity.java b/src/main/java/net/gepafin/tendermanagement/entities/CommunicationAmendmentEntity.java new file mode 100644 index 00000000..0665df52 --- /dev/null +++ b/src/main/java/net/gepafin/tendermanagement/entities/CommunicationAmendmentEntity.java @@ -0,0 +1,31 @@ +package net.gepafin.tendermanagement.entities; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import lombok.Data; + +import java.util.Optional; + +@Entity +@Table(name = "communication_amendment") +@Data +public class CommunicationAmendmentEntity extends BaseEntity { + + @Column(name = "COMMUNICATION_TITLE") + private String communicationTitle; + + @Column(name = "COMMUNICATION_COMMENT") + private String communicationComment; + + @Column(name = "IS_DELETED") + private Boolean isDeleted; + + @ManyToOne + @JoinColumn(name = "AMENDMENT_ID", referencedColumnName = "id", nullable = false) + private ApplicationAmendmentRequestEntity amendmentRequest; + +} + diff --git a/src/main/java/net/gepafin/tendermanagement/model/request/CommunicationRequestBean.java b/src/main/java/net/gepafin/tendermanagement/model/request/CommunicationRequestBean.java new file mode 100644 index 00000000..512b39be --- /dev/null +++ b/src/main/java/net/gepafin/tendermanagement/model/request/CommunicationRequestBean.java @@ -0,0 +1,11 @@ +package net.gepafin.tendermanagement.model.request; + +import lombok.Data; + +@Data +public class CommunicationRequestBean { + private String title; + private String comment; + private Long amendmentId; +} + diff --git a/src/main/java/net/gepafin/tendermanagement/model/response/CommunicationResponseBean.java b/src/main/java/net/gepafin/tendermanagement/model/response/CommunicationResponseBean.java new file mode 100644 index 00000000..ae69e24c --- /dev/null +++ b/src/main/java/net/gepafin/tendermanagement/model/response/CommunicationResponseBean.java @@ -0,0 +1,11 @@ +package net.gepafin.tendermanagement.model.response; + +import lombok.Data; + +import java.time.Instant; + +@Data +public class CommunicationResponseBean { + private Instant communicationAddedDate; + private String comment; +} diff --git a/src/main/java/net/gepafin/tendermanagement/repositories/CommunicationAmendmentRepository.java b/src/main/java/net/gepafin/tendermanagement/repositories/CommunicationAmendmentRepository.java new file mode 100644 index 00000000..591e633e --- /dev/null +++ b/src/main/java/net/gepafin/tendermanagement/repositories/CommunicationAmendmentRepository.java @@ -0,0 +1,14 @@ +package net.gepafin.tendermanagement.repositories; + +import net.gepafin.tendermanagement.entities.CommunicationAmendmentEntity; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; + +import java.util.Optional; + +public interface CommunicationAmendmentRepository extends JpaRepository { + + @Query("Select c from CommunicationAmendmentEntity c Where c.id = :id") + CommunicationAmendmentEntity findCommentsById(@Param("id") Long id); +} diff --git a/src/main/java/net/gepafin/tendermanagement/service/CommunicationAmendmentService.java b/src/main/java/net/gepafin/tendermanagement/service/CommunicationAmendmentService.java new file mode 100644 index 00000000..a19f134f --- /dev/null +++ b/src/main/java/net/gepafin/tendermanagement/service/CommunicationAmendmentService.java @@ -0,0 +1,17 @@ +package net.gepafin.tendermanagement.service; + +import net.gepafin.tendermanagement.entities.CommunicationAmendmentEntity; +import net.gepafin.tendermanagement.model.request.CommunicationRequestBean; +import net.gepafin.tendermanagement.model.response.CommunicationResponseBean; + +import java.util.Optional; + +public interface CommunicationAmendmentService { + CommunicationResponseBean addCommentToAmendmentRequest(CommunicationRequestBean communicationRequestBean); + + String deleteCommunicationAmendmentComment(Long amendmentId, Long commentId); + + CommunicationResponseBean updateCommunicationAmendment(CommunicationRequestBean communicationRequestBean); + + CommunicationResponseBean getAmendmentComments(Long id, Long commentId); +} diff --git a/src/main/java/net/gepafin/tendermanagement/service/impl/CommunicationAmendmentServiceImpl.java b/src/main/java/net/gepafin/tendermanagement/service/impl/CommunicationAmendmentServiceImpl.java new file mode 100644 index 00000000..011999b0 --- /dev/null +++ b/src/main/java/net/gepafin/tendermanagement/service/impl/CommunicationAmendmentServiceImpl.java @@ -0,0 +1,38 @@ +package net.gepafin.tendermanagement.service.impl; + +import net.gepafin.tendermanagement.dao.CommunicationAmendmentDao; +import net.gepafin.tendermanagement.entities.CommunicationAmendmentEntity; +import net.gepafin.tendermanagement.model.request.CommunicationRequestBean; +import net.gepafin.tendermanagement.model.response.CommunicationResponseBean; +import net.gepafin.tendermanagement.service.CommunicationAmendmentService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Optional; + +@Service +public class CommunicationAmendmentServiceImpl implements CommunicationAmendmentService { + + @Autowired + CommunicationAmendmentDao communicationAmendmentDao; + + @Override + public CommunicationResponseBean addCommentToAmendmentRequest(CommunicationRequestBean communicationRequestBean) { + return communicationAmendmentDao.addCommentToAmendmentRequest(communicationRequestBean); + } + @Override + public String deleteCommunicationAmendmentComment(Long amendmentId, Long commentId) { + + return communicationAmendmentDao.deleteCommunicationAmendmentComment(amendmentId, commentId); + } + @Override + public CommunicationResponseBean updateCommunicationAmendment(CommunicationRequestBean communicationRequestBean) { + + return communicationAmendmentDao.updateCommunicationAmendment(communicationRequestBean); + } + @Override + public CommunicationResponseBean getAmendmentComments(Long id, Long commentId) { + + return communicationAmendmentDao.getAmendmentComments(id, commentId); + } +} diff --git a/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationAmendmentRepository.java b/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationAmendmentRepository.java new file mode 100644 index 00000000..d2a3984e --- /dev/null +++ b/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationAmendmentRepository.java @@ -0,0 +1,15 @@ +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 { + + @Query("SELECT app FROM ApplicationAmendmentRequestEntity app WHERE app.id = :id") + ApplicationAmendmentRequestEntity findAmendmentById(@Param("id") Long id); + +} diff --git a/src/main/java/net/gepafin/tendermanagement/web/rest/api/CommunicationAmendmentApi.java b/src/main/java/net/gepafin/tendermanagement/web/rest/api/CommunicationAmendmentApi.java new file mode 100644 index 00000000..35ff7d51 --- /dev/null +++ b/src/main/java/net/gepafin/tendermanagement/web/rest/api/CommunicationAmendmentApi.java @@ -0,0 +1,67 @@ +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 net.gepafin.tendermanagement.entities.CommunicationAmendmentEntity; +import net.gepafin.tendermanagement.model.request.CommunicationRequestBean; +import net.gepafin.tendermanagement.model.response.CommunicationResponseBean; +import net.gepafin.tendermanagement.model.util.Response; +import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants; +import org.springframework.data.repository.query.Param; +import org.springframework.http.MediaType; +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.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; + +import java.util.Optional; + +@Validated +public interface CommunicationAmendmentApi { + @Operation(summary = "Api to create communication amendment 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) })) }) + @PostMapping(value = "", produces = { "application/json" }) + ResponseEntity> addCommentToAmendmentRequest(HttpServletRequest request, @Parameter CommunicationRequestBean communicationResponseBean); + + @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> getAmendmentComments(HttpServletRequest request, @Param(value = "amendmentId") Long id, + @Param(value = "commentId") Long commentId); + + @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 = { + @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) })) }) + @PutMapping(value = "", produces = { "application/json" }) + ResponseEntity> updateCommunicationAmendment(HttpServletRequest request, @Parameter CommunicationRequestBean communicationResponseBean); + + @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 = { + @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) })) }) + @DeleteMapping(value = "/{amendmentId}/{commentId}", produces = { "application/json" }) + ResponseEntity> deleteApplicationAmendmentComment(HttpServletRequest request, @Param(value = "amendmentId")Long amendmentId, @Param(value = "commentId")Long commentId); +} diff --git a/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/CommunicationAmendmentController.java b/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/CommunicationAmendmentController.java new file mode 100644 index 00000000..8e78df76 --- /dev/null +++ b/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/CommunicationAmendmentController.java @@ -0,0 +1,57 @@ +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.CommunicationResponseBean; +import net.gepafin.tendermanagement.model.util.Response; +import net.gepafin.tendermanagement.service.CommunicationAmendmentService; +import net.gepafin.tendermanagement.web.rest.api.CommunicationAmendmentApi; +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.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 { + + @Autowired + CommunicationAmendmentService communicationAmendmentService; + + @Override + public ResponseEntity> addCommentToAmendmentRequest(HttpServletRequest request, CommunicationRequestBean communicationRequestBean) { + + CommunicationResponseBean communicationResponseBean = communicationAmendmentService.addCommentToAmendmentRequest(communicationRequestBean); + return ResponseEntity.status(HttpStatus.CREATED) + .body(new Response<>(communicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMMUNICATION_ADDED_TO_AMENDMENT_REQUEST_SUCCESS))); + } + @Override + public ResponseEntity> getAmendmentComments(HttpServletRequest request, Long id, Long commentId) { + + 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))); + } + @Override + public ResponseEntity> updateCommunicationAmendment(HttpServletRequest request, CommunicationRequestBean communicationRequestBean) { + + 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))); + } + @Override + public ResponseEntity> 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))); + } + +} diff --git a/src/main/resources/db/changelog/db.changelog-1.0.0.xml b/src/main/resources/db/changelog/db.changelog-1.0.0.xml index 72224de3..133473c0 100644 --- a/src/main/resources/db/changelog/db.changelog-1.0.0.xml +++ b/src/main/resources/db/changelog/db.changelog-1.0.0.xml @@ -1483,6 +1483,62 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +