Merge pull request #42 from Kitzanos/fature/GEPAFINBE-44
GEPAFINBE-44 (Beneficiario must be able to download Call Documents)
This commit is contained in:
@@ -134,4 +134,19 @@ public interface CallApi {
|
||||
public ResponseEntity<Response<CallResponse>> updateCallStatus(HttpServletRequest request,
|
||||
@Parameter(description = "The call id", required = true) @PathVariable("callId") Long callId,
|
||||
@Parameter(description = "status", required = true)@RequestParam(value = "status", required = true) CallStatusEnum status);
|
||||
|
||||
@Operation(summary = "Api to download call documents as a ZIP file",
|
||||
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 = "/{callId}/documents/zip")
|
||||
ResponseEntity<byte[]> downloadCallDocumentsAsZip(HttpServletRequest httpServletRequest,
|
||||
@Parameter(description = "The call ID", required = true) @PathVariable("callId") Long callId);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@ import java.util.List;
|
||||
|
||||
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -84,4 +86,22 @@ public class CallApiController implements CallApi {
|
||||
CallResponse updateCall = callService.updateCallStatus(request, callId, status);
|
||||
return ResponseEntity.ok(new Response<>(updateCall, Status.SUCCESS, Translator.toLocale(GepafinConstant.UPDATE_CALL_STATUS_SUCCESS_MSG)));
|
||||
}
|
||||
@Override
|
||||
public ResponseEntity<byte[]> downloadCallDocumentsAsZip(HttpServletRequest request, Long callId) {
|
||||
byte[] zipFile = callService.downloadCallDocumentsAsZip(callId);
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||
headers.setContentDispositionFormData("attachment", "documents.zip");
|
||||
|
||||
if (zipFile == null || zipFile.length == 0) {
|
||||
String notFoundMessage = Translator.toLocale(GepafinConstant.CALL_DOCUMENTS_NOT_FOUND_MSG);
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
||||
.body(notFoundMessage.getBytes());
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(zipFile, headers, HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user