diff --git a/src/main/java/com/interplug/qcast/biz/canvasStatus/CanvasStatusController.java b/src/main/java/com/interplug/qcast/biz/canvasStatus/CanvasStatusController.java index 462fcf02..c4af0807 100644 --- a/src/main/java/com/interplug/qcast/biz/canvasStatus/CanvasStatusController.java +++ b/src/main/java/com/interplug/qcast/biz/canvasStatus/CanvasStatusController.java @@ -3,7 +3,7 @@ package com.interplug.qcast.biz.canvasStatus; import com.interplug.qcast.biz.canvasStatus.dto.CanvasStatus; import com.interplug.qcast.biz.canvasStatus.dto.CanvasStatusResponse; import com.interplug.qcast.config.Exception.CanvasStatusException; - +import com.interplug.qcast.config.Exception.QcastException; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import java.util.List; diff --git a/src/main/java/com/interplug/qcast/biz/community/BoardService.java b/src/main/java/com/interplug/qcast/biz/community/BoardService.java index e8b49987..4040dc98 100644 --- a/src/main/java/com/interplug/qcast/biz/community/BoardService.java +++ b/src/main/java/com/interplug/qcast/biz/community/BoardService.java @@ -1,39 +1,37 @@ package com.interplug.qcast.biz.community; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.interplug.qcast.biz.community.dto.BoardRequest; +import com.interplug.qcast.biz.community.dto.BoardResponse; +import com.interplug.qcast.config.Exception.ErrorCode; +import com.interplug.qcast.config.Exception.QcastException; +import com.interplug.qcast.config.message.Messages; +import com.interplug.qcast.util.InterfaceQsp; +import jakarta.servlet.http.HttpServletResponse; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpMethod; import org.springframework.stereotype.Service; import org.springframework.util.StreamUtils; import org.springframework.web.util.UriComponentsBuilder; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.interplug.qcast.biz.community.dto.BoardRequest; -import com.interplug.qcast.biz.community.dto.BoardResponse; -import com.interplug.qcast.config.Exception.BaseException; -import com.interplug.qcast.config.message.Messages; -import com.interplug.qcast.util.InterfaceQsp; -import jakarta.servlet.http.HttpServletResponse; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; @Slf4j @Service @RequiredArgsConstructor public class BoardService { + private final InterfaceQsp interfaceQsp; + @Autowired Messages message; @Value("${qsp.url}") private String QSP_API_URL; - private final InterfaceQsp interfaceQsp; - - @Autowired - Messages message; - /** * ※ 게시판 목록 조회 QSP -> Q.CAST3 * @@ -48,12 +46,14 @@ public class BoardService { /* [0]. Validation Check */ if ("".equals(boardRequest.getSchNoticeClsCd())) { // [msg] {0} is required input value. - throw new BaseException( + throw new QcastException( + ErrorCode.NOT_FOUND, message.getMessage("common.message.required.data", "Notice Cls Code")); } if ("".equals(boardRequest.getSchNoticeTpCd())) { // [msg] {0} is required input value. - throw new BaseException( + throw new QcastException( + ErrorCode.NOT_FOUND, message.getMessage("common.message.required.data", "Notice Type Code")); } @@ -61,12 +61,16 @@ public class BoardService { String encodedSchTitle = URLEncoder.encode(boardRequest.getSchTitle(), StandardCharsets.UTF_8); String url = QSP_API_URL + "/api/board/list"; - String apiUrl = UriComponentsBuilder.fromHttpUrl(url) - .queryParam("noticeNo", boardRequest.getNoticeNo()).queryParam("schTitle", encodedSchTitle) - .queryParam("schNoticeTpCd", boardRequest.getSchNoticeTpCd()) - .queryParam("schNoticeClsCd", boardRequest.getSchNoticeClsCd()) - .queryParam("startRow", boardRequest.getStartRow()) - .queryParam("endRow", boardRequest.getEndRow()).build().toUriString(); + String apiUrl = + UriComponentsBuilder.fromHttpUrl(url) + .queryParam("noticeNo", boardRequest.getNoticeNo()) + .queryParam("schTitle", encodedSchTitle) + .queryParam("schNoticeTpCd", boardRequest.getSchNoticeTpCd()) + .queryParam("schNoticeClsCd", boardRequest.getSchNoticeClsCd()) + .queryParam("startRow", boardRequest.getStartRow()) + .queryParam("endRow", boardRequest.getEndRow()) + .build() + .toUriString(); /* [2]. QSP API CALL -> Response */ String strResponse = interfaceQsp.callApi(HttpMethod.GET, apiUrl, null); @@ -78,11 +82,10 @@ public class BoardService { response = om.readValue(strResponse, BoardResponse.class); } else { // [msg] No data - throw new BaseException(message.getMessage("common.message.no.data")); + throw new QcastException(ErrorCode.NOT_FOUND, message.getMessage("common.message.no.data")); } return response; - } /** @@ -99,13 +102,17 @@ public class BoardService { /* [0]. Validation Check */ if (boardRequest.getNoticeNo() == null) { // [msg] {0} is required input value. - throw new BaseException(message.getMessage("common.message.required.data", "Notice No")); + throw new QcastException( + ErrorCode.NOT_FOUND, message.getMessage("common.message.required.data", "Notice No")); } /* [1]. QSP API (url + param) Setting */ String url = QSP_API_URL + "/api/board/detail"; - String apiUrl = UriComponentsBuilder.fromHttpUrl(url) - .queryParam("noticeNo", boardRequest.getNoticeNo()).build().toUriString(); + String apiUrl = + UriComponentsBuilder.fromHttpUrl(url) + .queryParam("noticeNo", boardRequest.getNoticeNo()) + .build() + .toUriString(); /* [2]. QSP API CALL -> Response */ String strResponse = interfaceQsp.callApi(HttpMethod.GET, apiUrl, null); @@ -117,7 +124,7 @@ public class BoardService { response = om.readValue(strResponse, BoardResponse.class); } else { // [msg] No data - throw new BaseException(message.getMessage("common.message.no.data")); + throw new QcastException(ErrorCode.NOT_FOUND, message.getMessage("common.message.no.data")); } return response; @@ -135,7 +142,8 @@ public class BoardService { /* [0]. Validation Check */ if ("".equals(encodeFileNo)) { // [msg] {0} is required input value. - throw new BaseException(message.getMessage("common.message.required.data", "File No")); + throw new QcastException( + ErrorCode.NOT_FOUND, message.getMessage("common.message.required.data", "File No")); } /* [1]. QSP API (url + fileNo) Setting */ @@ -158,15 +166,15 @@ public class BoardService { } catch (Exception e) { // [msg] File download error - throw new BaseException(message.getMessage("common.message.file.download.error")); + throw new QcastException( + ErrorCode.INTERNAL_SERVER_ERROR, + message.getMessage("common.message.file.download.error")); } } else { // [msg] File does not exist. - throw new BaseException(message.getMessage("common.message.file.download.exists")); + throw new QcastException( + ErrorCode.NOT_FOUND, message.getMessage("common.message.file.download.exists")); } - } - - } diff --git a/src/main/java/com/interplug/qcast/biz/excelDown/ExcelDownService.java b/src/main/java/com/interplug/qcast/biz/excelDown/ExcelDownService.java index 70a1fa00..b45c2fb9 100644 --- a/src/main/java/com/interplug/qcast/biz/excelDown/ExcelDownService.java +++ b/src/main/java/com/interplug/qcast/biz/excelDown/ExcelDownService.java @@ -1,7 +1,8 @@ package com.interplug.qcast.biz.excelDown; import com.interplug.qcast.biz.excelDown.dto.*; -import com.interplug.qcast.config.Exception.BaseException; +import com.interplug.qcast.config.Exception.ErrorCode; +import com.interplug.qcast.config.Exception.QcastException; import com.interplug.qcast.config.message.Messages; import com.interplug.qcast.util.ZipFileManager; import jakarta.servlet.http.HttpServletResponse; @@ -67,7 +68,8 @@ public class ExcelDownService { zipFileManager.createZipFile(response, "Warranty-issued-completed-files", listFile); } else { - throw new BaseException(message.getMessage("common.message.no.dataDown")); + throw new QcastException( + ErrorCode.NOT_FOUND, message.getMessage("common.message.no.dataDown")); } } }