added delete API for delegation

This commit is contained in:
rajesh
2024-10-09 12:52:34 +05:30
parent a244e9ef44
commit e8fc901b3f
9 changed files with 67 additions and 7 deletions

View File

@@ -131,5 +131,16 @@ public interface CompanyApi {
@GetMapping(value = "{companyId}/delegation", produces = { "application/json" })
ResponseEntity<Response<CompanyDelegationResponse>> getCompanyDelegation(HttpServletRequest request,
@Parameter(description = "The company id", required = true) @PathVariable("companyId") Long companyId);
@Operation(summary = "Api to delete company delegation", 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 = "{companyId}/delegation", produces = { "application/json" })
ResponseEntity<Response<Void>> deleteCompanyDelegation(HttpServletRequest request,
@Parameter(description = "The company id", required = true) @PathVariable("companyId") Long companyId);
}

View File

@@ -108,17 +108,24 @@ public class CompanyApiController implements CompanyApi{
MultipartFile file) {
log.info("upload company delegation with companyId: {}", companyId);
CompanyDelegationResponse companyDelegationResponse = companyService.uploadCompanyDelegation(request, companyId, file);
return ResponseEntity.status(HttpStatus.OK)
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(companyDelegationResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.DELEGATION_FILE_UPLOAD_SUCCESS)));
}
@Override
public ResponseEntity<Response<CompanyDelegationResponse>> getCompanyDelegation(HttpServletRequest request,
Long companyId) {
log.info("get company delegation with companyId: {}", companyId);
CompanyDelegationResponse companyDelegationResponse = companyService.getCompanyDelegation(request, companyId);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(companyDelegationResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.DELEGATION_FETCH_SUCCESS)));
}
@Override
public ResponseEntity<Response<Void>> deleteCompanyDelegation(HttpServletRequest request,
Long companyId) {
log.info("delete company delegation with companyId: {}", companyId);
companyService.deleteCompanyDelegation(request, companyId);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.DELEGATION_DELETE_SUCCESS)));
}
}