refactor: Change code baseException to QcastException
This commit is contained in:
parent
c7c90a2a5d
commit
ebf2e4592a
@ -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;
|
||||
|
||||
@ -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"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user