Done ticket GEPAFINBE-231

This commit is contained in:
rajesh
2025-06-27 20:04:39 +05:30
parent 694b4ebe17
commit 7c1c6999a0
17 changed files with 217 additions and 15 deletions

View File

@@ -252,6 +252,21 @@ public interface ApplicationApi {
ResponseEntity<Response<ApplicationResponse>> readmitApplication(HttpServletRequest request,
@Parameter(description = "The application id", required = true) @PathVariable("applicationId") Long applicationId);
@Operation(summary = "Api to download application data as a CSV file as per ranking",
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 = "/call/{callId}/ranking-csv")
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN') || hasRole('ROLE_INSTRUCTOR_MANAGER')")
public ResponseEntity<byte[]> downloadRankingCsv(
HttpServletRequest request, @Parameter(description = "The call id", required = true) @PathVariable(value = "callId", required = true) Long callId);
}

View File

@@ -27,6 +27,8 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.slf4j.Logger;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
@@ -236,6 +238,10 @@ public class ApplicationApiController implements ApplicationApi {
}
@Override
public ResponseEntity<byte[]> exportCsv(HttpServletRequest request, Long callId) {
loggingUtil.logUserAction(
UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.DOWNLOAD).actionContext(UserActionContextEnum.DOWNLOAD_CSV_BY_CALL_ID).build());
byte[] csvBytes =applicationService.exportCsv(request,callId);
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=applications.csv")
@@ -254,4 +260,19 @@ public class ApplicationApiController implements ApplicationApi {
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(applicationResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.READMIT_APPLICATION_SUCCESS)));
}
@Override
public ResponseEntity<byte[]> downloadRankingCsv(HttpServletRequest request, Long callId) {
loggingUtil.logUserAction(
UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.DOWNLOAD).actionContext(UserActionContextEnum.DOWNLOAD_CSV_AS_PER_RANKING).build());
byte[] csvBytes =applicationService.downloadRankingCsv(request,callId);
String dateString = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
String fileName = "call_" + callId + "_" + dateString + ".csv";
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + fileName)
.contentType(MediaType.APPLICATION_OCTET_STREAM)
.body(csvBytes);
}
}