커뮤니티 qcast -> qsp 파일 다운로드 파라미터 수정

This commit is contained in:
LEEYONGJAE 2025-01-20 13:52:46 +09:00
parent 1ff3916b81
commit f61c92fddd
3 changed files with 20 additions and 7 deletions

View File

@ -42,8 +42,8 @@ public class BoardController {
@GetMapping("/file/download")
@ResponseStatus(HttpStatus.OK)
public void getFileDownload(HttpServletResponse response,
@RequestParam(required = true) String encodeFileNo) throws Exception {
boardService.getFileDownload(response, encodeFileNo);
@RequestParam(required = true) String keyNo, @RequestParam String zipYn) throws Exception {
boardService.getFileDownload(response, keyNo, zipYn);
}
}

View File

@ -71,7 +71,9 @@ public class BoardService {
.queryParam("schNoticeTpCd", boardRequest.getSchNoticeTpCd())
.queryParam("schNoticeClsCd", boardRequest.getSchNoticeClsCd())
.queryParam("startRow", boardRequest.getStartRow())
.queryParam("endRow", boardRequest.getEndRow()).build().toUriString();
.queryParam("endRow", boardRequest.getEndRow())
.queryParam("schMainYn", boardRequest.getSchMainYn()).build().toUriString();
/* [2]. QSP API CALL -> Response */
String strResponse = interfaceQsp.callApi(HttpMethod.GET, apiUrl, null);
@ -135,17 +137,24 @@ public class BoardService {
* @param encodeFileNo
* @throws Exception
*/
public void getFileDownload(HttpServletResponse response, String encodeFileNo) throws Exception {
public void getFileDownload(HttpServletResponse response, String keyNo, String zipYn)
throws Exception {
/* [0]. Validation Check */
if ("".equals(encodeFileNo)) {
if ("".equals(keyNo)) {
// [msg] {0} is required input value.
String arg = "Y".equals(zipYn) ? "Notice No" : "File No";
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "File No"));
message.getMessage("common.message.required.data", arg));
}
/* [1]. QSP API (url + fileNo) Setting */
String url = QSP_API_URL + "/api/file/downloadFile" + "?encodeFileNo=" + encodeFileNo;
String url = QSP_API_URL + "/api/file/downloadFile";
if ("Y".equals(zipYn)) {
url += "?noticeNo=" + keyNo;
} else {
url += "?fileNo=" + keyNo;
}
/* [2]. QSP API CALL -> Response */
Map<String, String> result = new HashMap<String, String>();
@ -154,6 +163,7 @@ public class BoardService {
if (byteResponse != null && byteResponse.length > 0) {
try {
/* [3]. API 응답 파일 처리 */
response.addHeader("Access-Control-Expose-Headers", "Content-Disposition");
response.setContentType(
!"".equals(result.get("type")) && result.get("type") != null ? result.get("type")
: "application/octet-stream");

View File

@ -25,4 +25,7 @@ public class BoardRequest {
/** 종료 행 */
private int endRow;
/** 메인여부 */
private String schMainYn;
}