Beneficiary must be able to add to favorite a Call
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
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.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import net.gepafin.tendermanagement.enums.BeneficiaryCallStatus;
|
||||
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
||||
import net.gepafin.tendermanagement.model.request.BeneficiaryPreferredCallReq;
|
||||
|
||||
import net.gepafin.tendermanagement.model.response.BeneficiaryPreferredCallResponseBean;
|
||||
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.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Validated
|
||||
@RequestMapping("/v1/beneficiaryPreferredCall")
|
||||
public interface BeneficiaryPreferredCallApi {
|
||||
|
||||
@Operation(summary = "Create a new beneficiary preferred call",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "201", description = "Created"),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)})),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE)})),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)}))})
|
||||
@PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Response<BeneficiaryPreferredCallResponseBean>> createBeneficiaryPreferredCall(HttpServletRequest request,
|
||||
@Parameter(required = true)
|
||||
@Valid @RequestBody BeneficiaryPreferredCallReq beneficiaryPreferredCallReq);
|
||||
|
||||
/* @Operation(summary = "Update an existing beneficiary preferred call",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)})),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)}))})
|
||||
@PutMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Response<BeneficiaryPreferredCallResponseBean>> updateBeneficiaryPreferredCall(HttpServletRequest request,
|
||||
@Parameter( required = true)
|
||||
@PathVariable("id") Long id,
|
||||
@Valid @RequestBody BeneficiaryPreferredCallReq beneficiaryPreferredCallReq);
|
||||
*/
|
||||
@Operation(summary = "Get a beneficiary preferred call by ID",
|
||||
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)}))})
|
||||
@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Response<BeneficiaryPreferredCallResponseBean>> getBeneficiaryPreferredCallById(HttpServletRequest request,
|
||||
@Parameter( required = true)
|
||||
@PathVariable("id") Long id);
|
||||
|
||||
@Operation(summary = "Delete a beneficiary preferred 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)}))})
|
||||
@DeleteMapping(value = "/{id}")
|
||||
ResponseEntity<Response<Void>> deleteBeneficiaryPreferredCall(HttpServletRequest request,
|
||||
@Parameter(required = true)
|
||||
@PathVariable("id") Long id);
|
||||
|
||||
@Operation(summary = "Update status of a beneficiary preferred 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)}))})
|
||||
@PutMapping(value = "/{id}/status", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Response<Void>> updateBeneficiaryPreferredCallStatus(HttpServletRequest request,
|
||||
@Parameter( required = true)
|
||||
@PathVariable("id") Long id,
|
||||
@Parameter(description = "New status for the preferred call", required = true)
|
||||
@RequestParam(value = "status", required = true) BeneficiaryCallStatus status);
|
||||
|
||||
@Operation(summary = "Get all beneficiary preferred calls",
|
||||
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)}))})
|
||||
@GetMapping(value = "/user", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Response<List<BeneficiaryPreferredCallResponseBean>>> getBeneficiaryPreferredCallByUserId(
|
||||
HttpServletRequest request,
|
||||
@RequestParam(value = "userId",required = false) Long userId,
|
||||
@RequestParam(value = "beneficiaryId",required = false) Long beneficiaryId,
|
||||
@RequestParam(value = "companyId",required = false) Long companyId
|
||||
);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
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.enums.BeneficiaryCallStatus;
|
||||
import net.gepafin.tendermanagement.model.request.BeneficiaryPreferredCallReq;
|
||||
|
||||
import net.gepafin.tendermanagement.model.response.BeneficiaryPreferredCallResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.service.BeneficiaryPreferredCallService;
|
||||
import net.gepafin.tendermanagement.web.rest.api.BeneficiaryPreferredCallApi;
|
||||
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.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
public class BeneficiaryPreferredCallApiController implements BeneficiaryPreferredCallApi {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(BeneficiaryPreferredCallApiController.class);
|
||||
|
||||
@Autowired
|
||||
private BeneficiaryPreferredCallService beneficiaryPreferredCallService;
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<BeneficiaryPreferredCallResponseBean>> createBeneficiaryPreferredCall(HttpServletRequest request, BeneficiaryPreferredCallReq beneficiaryPreferredCallReq) {
|
||||
log.info("Creating Beneficiary Preferred Call");
|
||||
BeneficiaryPreferredCallResponseBean responseBean = beneficiaryPreferredCallService.createBeneficiaryPreferredCall(request, beneficiaryPreferredCallReq);
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(new Response<>(responseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.BENEFICIARY_PREFERRED_CALL_CREATED_SUCCESS_MSG)));
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public ResponseEntity<Response<BeneficiaryPreferredCallResponseBean>> updateBeneficiaryPreferredCall(HttpServletRequest request, Long id, BeneficiaryPreferredCallReq beneficiaryPreferredCallReq) {
|
||||
// log.info("Updating Beneficiary Preferred Call - ID: {}", id);
|
||||
// BeneficiaryPreferredCallResponseBean response = beneficiaryPreferredCallService.updateBeneficiaryPreferredCall(request, id, beneficiaryPreferredCallReq);
|
||||
// return ResponseEntity.status(HttpStatus.OK)
|
||||
// .body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.BENEFICIARY_PREFERRED_CALL_UPDATED_SUCCESS_MSG)));
|
||||
// }
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<BeneficiaryPreferredCallResponseBean>> getBeneficiaryPreferredCallById(HttpServletRequest request, Long id) {
|
||||
log.info("Fetching Beneficiary Preferred Call by ID - ID: {}", id);
|
||||
BeneficiaryPreferredCallResponseBean response = beneficiaryPreferredCallService.getBeneficiaryPreferredCallById(request, id);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_BENEFICIARY_PREFERRED_CALL_SUCCESS_MSG)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<Void>> deleteBeneficiaryPreferredCall(HttpServletRequest request, Long id) {
|
||||
log.info("Deleting Beneficiary Preferred Call - ID: {}", id);
|
||||
beneficiaryPreferredCallService.deleteBeneficiaryPreferredCall(request, id);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.DELETE_BENEFICIARY_PREFERRED_CALL_SUCCESS_MSG)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<Void>> updateBeneficiaryPreferredCallStatus(HttpServletRequest request, Long id, BeneficiaryCallStatus status) {
|
||||
log.info("Updating status of Beneficiary Preferred Call - ID: {}, Status: {}", id, status);
|
||||
beneficiaryPreferredCallService.updateBeneficiaryPreferredCallStatus(request, id, status);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.BENEFICIARY_PREFERRED_CALL_STATUS_UPDATED_SUCCESS_MSG)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<List<BeneficiaryPreferredCallResponseBean>>> getBeneficiaryPreferredCallByUserId(HttpServletRequest request,Long userId,Long beneficiaryId,Long companyId) {
|
||||
log.info("Fetching all Beneficiary Preferred Calls for User ID");
|
||||
List<BeneficiaryPreferredCallResponseBean> response = beneficiaryPreferredCallService.getBeneficiaryPreferredCallByUserId(request, userId,beneficiaryId,companyId);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_ALL_BENEFICIARY_PREFERRED_CALLS_SUCCESS_MSG)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user