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 33039c8b..e8b49987 100644 --- a/src/main/java/com/interplug/qcast/biz/community/BoardService.java +++ b/src/main/java/com/interplug/qcast/biz/community/BoardService.java @@ -4,6 +4,7 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpMethod; import org.springframework.stereotype.Service; @@ -13,6 +14,8 @@ 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; @@ -28,6 +31,9 @@ public class BoardService { private final InterfaceQsp interfaceQsp; + @Autowired + Messages message; + /** * ※ 게시판 목록 조회 QSP -> Q.CAST3 * @@ -39,7 +45,19 @@ public class BoardService { BoardResponse response = null; - /* [0]. QSP API (url + param) Setting */ + /* [0]. Validation Check */ + if ("".equals(boardRequest.getSchNoticeClsCd())) { + // [msg] {0} is required input value. + throw new BaseException( + message.getMessage("common.message.required.data", "Notice Cls Code")); + } + if ("".equals(boardRequest.getSchNoticeTpCd())) { + // [msg] {0} is required input value. + throw new BaseException( + message.getMessage("common.message.required.data", "Notice Type Code")); + } + + /* [1]. QSP API (url + param) Setting */ String encodedSchTitle = URLEncoder.encode(boardRequest.getSchTitle(), StandardCharsets.UTF_8); String url = QSP_API_URL + "/api/board/list"; @@ -50,7 +68,7 @@ public class BoardService { .queryParam("startRow", boardRequest.getStartRow()) .queryParam("endRow", boardRequest.getEndRow()).build().toUriString(); - /* [1]. QSP API CALL -> Response */ + /* [2]. QSP API CALL -> Response */ String strResponse = interfaceQsp.callApi(HttpMethod.GET, apiUrl, null); if (!"".equals(strResponse)) { @@ -58,6 +76,9 @@ public class BoardService { new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); response = om.readValue(strResponse, BoardResponse.class); + } else { + // [msg] No data + throw new BaseException(message.getMessage("common.message.no.data")); } return response; @@ -75,12 +96,18 @@ public class BoardService { BoardResponse response = null; - /* [0]. QSP API (url + param) Setting */ + /* [0]. Validation Check */ + if (boardRequest.getNoticeNo() == null) { + // [msg] {0} is required input value. + throw new BaseException(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(); - /* [1]. QSP API CALL -> Response */ + /* [2]. QSP API CALL -> Response */ String strResponse = interfaceQsp.callApi(HttpMethod.GET, apiUrl, null); if (!"".equals(strResponse)) { @@ -88,6 +115,9 @@ public class BoardService { new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); response = om.readValue(strResponse, BoardResponse.class); + } else { + // [msg] No data + throw new BaseException(message.getMessage("common.message.no.data")); } return response; @@ -102,21 +132,38 @@ public class BoardService { */ public void getFileDownload(HttpServletResponse response, String encodeFileNo) throws Exception { - /* [0]. QSP API (url + fileNo) Setting */ + /* [0]. Validation Check */ + if ("".equals(encodeFileNo)) { + // [msg] {0} is required input value. + throw new BaseException(message.getMessage("common.message.required.data", "File No")); + } + + /* [1]. QSP API (url + fileNo) Setting */ String url = QSP_API_URL + "/api/file/downloadFile" + "?encodeFileNo=" + encodeFileNo; - /* [1]. QSP API CALL -> Response */ + /* [2]. QSP API CALL -> Response */ String strResponse = interfaceQsp.callApi(HttpMethod.GET, url, null); if (!"".equals(strResponse)) { - /* [2]. API 응답 파일 처리 */ - response.setContentType("application/octet-stream"); - response.setHeader("Content-Disposition", "attachment;"); + try { + /* [3]. API 응답 파일 처리 */ + response.setContentType("application/octet-stream"); + response.setHeader("Content-Disposition", "attachment;"); - InputStream inputStream = new ByteArrayInputStream(strResponse.getBytes()); - StreamUtils.copy(inputStream, response.getOutputStream()); + InputStream inputStream = new ByteArrayInputStream(strResponse.getBytes()); + StreamUtils.copy(inputStream, response.getOutputStream()); - response.flushBuffer(); + response.flushBuffer(); + inputStream.close(); + + } catch (Exception e) { + // [msg] File download error + throw new BaseException(message.getMessage("common.message.file.download.error")); + } + + } else { + // [msg] File does not exist. + throw new BaseException(message.getMessage("common.message.file.download.exists")); } } diff --git a/src/main/java/com/interplug/qcast/biz/community/dto/BoardRequest.java b/src/main/java/com/interplug/qcast/biz/community/dto/BoardRequest.java index b690b521..1823be75 100644 --- a/src/main/java/com/interplug/qcast/biz/community/dto/BoardRequest.java +++ b/src/main/java/com/interplug/qcast/biz/community/dto/BoardRequest.java @@ -16,7 +16,7 @@ public class BoardRequest { /** Notice Type Code 검색조건 */ private String schNoticeTpCd; - /** Notice Type Code 검색조건 */ + /** Notice Cls Code 검색조건 */ private String schNoticeClsCd; /** 시작 행 */ diff --git a/src/main/resources/message/message_ja.properties b/src/main/resources/message/message_ja.properties index 5fd8a129..89218276 100644 --- a/src/main/resources/message/message_ja.properties +++ b/src/main/resources/message/message_ja.properties @@ -1 +1,90 @@ -example.msg.001=一般メッセージ \ No newline at end of file +example.msg.001=一般メッセージ + +#common message +common.message.no.data:No data +common.message.no.dataDown:ダウンロードするデータがありません +common.message.noData:表示するデータがありません +common.message.search:'search success' +common.message.insert:'insert success' +common.message.update:'update success' +common.message.delete:削除 +common.message.restoration:復元 +common.message.cancel:キャンセル +common.message.send:メールを送信しました. +common.message.no.delete:'削除するデータがありません' +common.message.save:'保存' +common.message.transfer:'転送' +common.message.batch.exec:'batch success' +common.message.not.mov:移動できません. +common.message.required.data:'{0} は入力必須項目となります。' +common.message.save.error:'データの保存中にエラーが発生しました。 サイト管理者にお問い合わせください。' +common.message.transfer.error:'データの転送中にエラーが発生しました。 サイト管理者にお問い合わせください。' +common.message.delete.error:'データの削除中にエラーが発生しました。 サイト管理者にお問い合わせください。' +common.message.batch.error:'バッチの実行中にエラーが発生しました。 サイト管理者に連絡してください。' +common.message.send.error:'データの送信中にエラーが発生しました。サイト管理者にお問い合わせください' +common.message.communication.error:'ネットワークエラーが発生しました。サイト管理者に連絡してください。' +common.message.data.error:'{0} はデータ形式が無効です。' +common.message.data.setting.error:'{0} は削除されたか、すでに構成されているデータです。' +common.message.parameter.error:'パラメータエラー' +common.message.product.parameter.error:'存在しない製品があります。' +common.message.customer.parameter.error:'存在しない顧客があります。' +common.message.file.exists.error:'ファイルが正常にアップロードされないためにエラーが発生しました' +common.message.file.download.exists:ファイルが存在しません。 +common.message.file.download.error:ァイルのダウンロードエラー +common.message.file.template.validation01:フォルダをアップロードできません +common.message.file.template.validation02:アップロードできるのはExcelファイルのみです。 +common.message.file.template.validation03:登録できない拡張子です +common.message.file.template.validation04:'容量を超えています アップロード可能な容量:{0} MB' +common.message.file.template.validation05:'アップロードファイルを選択して下さい' +common.message.multi.insert:'合計 {0} 件数 ({1}成功、 {2} 失敗 {3})' +common.message.error:'エラーが発生しました。サイト管理者に連絡してください。' +common.message.data.save:'保存しますか?' +common.message.data.delete: 削除しますか? +common.message.data.exists:'{0} はすでに存在するデータです。' +common.message.data.no.exists:'{0} は存在しないデータです。' +common.message.all:All +common.message.tab.close.all:すべてのタブを閉じますか? +common.message.transfer.save:'{0}件転送しますか?' +common.message.confirm.save:保存しますか? +common.message.confirm.confirm:承認しますか? +common.message.confirm.request:承認リクエストしますか? +common.message.confirm.delete:削除しますか? +common.message.confirm.close:閉じますか? +common.message.confirm.unclose:クローズ中止しますか? +common.message.confirm.cancel:キャンセルしますか? +common.message.confirm.uncancel:キャンセル中止しますか? +common.message.confirm.copy:コピーしますか? +common.message.confirm.createSo:S/O作成しますか? +common.message.confirm.mark:'保存完了' +common.message.confirm.mail:メールを送信しますか? +common.message.confirm.printPriceItem:価格を印刷しますか? +common.message.confirm.allAppr :Do you want to Batch approve the selected data? +common.message.confirm.deliveryFee:送料を登録しますか? +common.message.success.delete:削除完了 +common.message.success.close:閉じる +common.message.success.unclose:キャンセルしました +common.message.validation.date:終了日を開始日より前にすることはできません。 もう一度入力してください。 +common.message.no.editfield:フィールドを編集できません +common.message.success.rmmail:リスク管理チームにメールを送信しました。 +common.message.password.validation01:パスワードの変更が一致しません。 +common.message.password.validation02:'英語、数字、特殊文字を組み合わせた8桁以上を入力してください。' +common.message.password.validation03:パスワードをIDと同じにすることはできません。 +common.message.menu.validation01:'注文を保存するメニューはありません.' +common.message.menu.validation02:'The same sort order exists.' +common.message.menuCode.check01:'登録可能' +common.message.menuCode.check02:'登録できません' +common.message.pleaseSelect:'{0}を選択してください' +common.message.pleaseInput:'{0}を入力してください。' +common.message.pleaseInputOr:'{0}または{1}を入力してください。' +common.message.approved :承認済み +common.message.errorFieldExist:エラー項目が存在します +common.message.storeIdExist :既に利用されている販売店IDです +common.message.userIdExist :すでに使用しているユーザーID。 +common.message.noExists :削除された掲示物です +common.message.emailReqTo:メール宛先が必要です +common.message.downloadPeriod:ダウンロード検索期間を{0}日以内に選択してください。 +common.message.backToSubmit:販売店ブロック解除実行しますか? +common.message.backToG3:Back to G3処理実行しますか? +common.message.writeToConfirm:作成解除を実行しますか? +common.message.password.init.success:'パスワード [{0}] に初期化されました。' +common.message.no.edit.save:この文書は変更できません。 \ No newline at end of file diff --git a/src/main/resources/message/message_ko.properties b/src/main/resources/message/message_ko.properties index dc5676d9..df17569b 100644 --- a/src/main/resources/message/message_ko.properties +++ b/src/main/resources/message/message_ko.properties @@ -1 +1,90 @@ -example.msg.001=일반메시지 \ No newline at end of file +example.msg.001=일반메시지 + +#common message +common.message.no.data:No data +common.message.no.dataDown:No data to download +common.message.noData:No data to display +common.message.search:'search success' +common.message.insert:'insert success' +common.message.update:'update success' +common.message.delete:Deleted +common.message.restoration:Restored +common.message.cancel:Canceled +common.message.send:The mail has been sent. +common.message.no.delete:'There is no data to delete.' +common.message.save:'Saved.' +common.message.transfer:'Transfered' +common.message.batch.exec:'batch success' +common.message.not.mov:It's impossible to move. +common.message.required.data:'{0} is required input value.' +common.message.save.error:'An error occurred while saving the data. Please contact site administrator.' +common.message.transfer.error:'An error occurred while transfer the data. Please contact site administrator.' +common.message.delete.error:'An error occurred while deleting data. Please contact site administrator.' +common.message.batch.error:'An error occurred while executing the batch. Please contact site administrator.' +common.message.send.error:'Error sending data, please contact your administrator.' +common.message.communication.error:'Network error occurred. \n Please contact site administrator.' +common.message.data.error:'{0} The data format is not valid.' +common.message.data.setting.error:'{0} is data that has been deleted or already configured.' +common.message.parameter.error:'Parameter Error' +common.message.product.parameter.error:'존재하지 않는 제품이 있습니다.' +common.message.customer.parameter.error:'존재하지 않는 고객이 있습니다.' +common.message.file.exists.error:'Error due to file not uploading normally' +common.message.file.download.exists:File does not exist. +common.message.file.download.error:File download error +common.message.file.template.validation01:Unable to upload folder +common.message.file.template.validation02:Only Excel files can be uploaded. +common.message.file.template.validation03:Non-registerable extension +common.message.file.template.validation04:'Exceed capacity \n Uploadable capacity:{0} MB' +common.message.file.template.validation05:'업로드 파일을 선택해주세요.' +common.message.multi.insert:'Total {0} cases ({1} successes, {2} failures {3})' +common.message.error:'Error occurred, please contact site administrator.' +common.message.data.save:'Do you want to save it?' +common.message.data.delete:Do you want to delete it? +common.message.data.exists:'{0} is data that already exists.' +common.message.data.no.exists:'{0} is data that does not exist.' +common.message.all:All +common.message.tab.close.all:Close all tabs? +common.message.transfer.save:Want to {0} transfer it? +common.message.confirm.save:Want to save it? +common.message.confirm.confirm:Want to approve? +common.message.confirm.request:Would you like to request a Approval? +common.message.confirm.delete:Do you want to delete it? +common.message.confirm.close:Want to close? +common.message.confirm.unclose:Do you want to cancel the close? +common.message.confirm.cancel:Want to cancellation? +common.message.confirm.uncancel:Do you want to cancel the cancellation? +common.message.confirm.copy:Do you want to copy? +common.message.confirm.createSo:Create Sales Order? +common.message.confirm.mark:Saved. +common.message.confirm.mail:Do you want to send mail? +common.message.confirm.printPriceItem:Would you like to print item price? +common.message.confirm.allAppr :Do you want to Batch approve the selected data? +common.message.confirm.deliveryFee:Do you want to register shipping fee? +common.message.success.delete:Deleted. +common.message.success.close:Closed. +common.message.success.unclose:Cancel Closed. +common.message.validation.date:The end date cannot be earlier than the start date. Please enter it again. +common.message.no.editfield:Can not edit field +common.message.success.rmmail:You have successfully sent mail to the Risk Management team. +common.message.password.validation01:Change passwords do not match. +common.message.password.validation02:'Please enter at least 8 digits combining English, numbers, and special characters.' +common.message.password.validation03:Password cannot be the same as ID. +common.message.menu.validation01:'There is no menu to save the order.' +common.message.menu.validation02:'The same sort order exists.' +common.message.menuCode.check01:'Registerable' +common.message.menuCode.check02:'Unable to register' +common.message.pleaseSelect:Please Select {0} +common.message.pleaseInput:Please Input a {0}. +common.message.pleaseInputOr:Please Input a {0} or {1}. +common.message.approved :Approved. +common.message.errorFieldExist:Error Field Exist +common.message.storeIdExist :이미 사용하고 있는 판매점 ID 입니다. +common.message.userIdExist :이미 사용하고 있는 사용자 ID 입니다. +common.message.noExists :삭제된 게시물 입니다. +common.message.emailReqTo:Email To is required +common.message.downloadPeriod:Please select the download search period within {0} days. +common.message.backToSubmit:판매점 블록 해제를 실행하시겠습니까? +common.message.backToG3:Back to G3 처리를 실행하시겠습니까? +common.message.writeToConfirm:작성 해제를 실행하시겠습니까? +common.message.password.init.success:'비밀번호 [{0}]로 초기화 되었습니다.' +common.message.no.edit.save:This document cannot be changed. \ No newline at end of file