From f94caa0885c4fba1fc0fee9d67fac74276181d87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?leehagjoon=28=EC=9D=B4=ED=95=99=EC=A4=80=29?= Date: Thu, 12 Oct 2023 13:56:41 +0900 Subject: [PATCH] =?UTF-8?q?=EB=82=A0=EC=94=A8=20API=20url=20=EB=B0=8F=20se?= =?UTF-8?q?rvicekey=20->=20properties=20=EA=B4=80=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../biz/api/bas/flight/service/BasFlightService.java | 11 +++++++++-- .../biz/api/ctr/cntrl/service/CtrCntrlService.java | 11 +++++++++-- pav-server/src/main/resources/application.properties | 3 +++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/pav-server/src/main/java/com/palnet/biz/api/bas/flight/service/BasFlightService.java b/pav-server/src/main/java/com/palnet/biz/api/bas/flight/service/BasFlightService.java index 06a21587..7fb263a2 100644 --- a/pav-server/src/main/java/com/palnet/biz/api/bas/flight/service/BasFlightService.java +++ b/pav-server/src/main/java/com/palnet/biz/api/bas/flight/service/BasFlightService.java @@ -23,6 +23,7 @@ import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; import org.locationtech.jts.geom.Coordinate; +import org.springframework.beans.factory.annotation.Value; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -52,6 +53,12 @@ import javax.servlet.http.HttpServletResponse; @Transactional(readOnly = true) public class BasFlightService { + @Value("${weather.api.url}") + private String weatherUrl; + + @Value("${weather.api.key}") + private String weatherKey; + private final CtrTrnsLctnService ctrTrnsLctnService; private final FltPlanBasRepository fltPlanBasRepository; private final FltPlanArcrftRepository fltPlanArcrftRepository; @@ -650,8 +657,8 @@ public class BasFlightService { } public JSONObject getWeather(BasFlightWeatherModel rq) throws IOException, ParseException { - StringBuilder urlBuilder = new StringBuilder("http://apis.data.go.kr/1360000/VilageFcstInfoService_2.0/getVilageFcst"); - urlBuilder.append("?" + URLEncoder.encode("serviceKey", "UTF-8") + "=r6RMUsk3Vtama7D6uq7MiWV9dTC9MwfIIr4%2F45y0uVNw6BaYbgpKmL%2BLUDFVTfIYUmEe4K%2FaniEjdV9mg5t82Q%3D%3D"); + StringBuilder urlBuilder = new StringBuilder(weatherUrl); + urlBuilder.append("?" + URLEncoder.encode("serviceKey", "UTF-8") + weatherKey); urlBuilder.append("&" + URLEncoder.encode("pageNo", "UTF-8") + "=" + URLEncoder.encode(rq.getPageNo(), "UTF-8")); urlBuilder.append("&" + URLEncoder.encode("numOfRows", "UTF-8") + "=" + URLEncoder.encode(rq.getNumOfRows(), "UTF-8")); /*한 페이지 결과 수*/ urlBuilder.append("&" + URLEncoder.encode("dataType", "UTF-8") + "=" + URLEncoder.encode("JSON", "UTF-8")); /*요청자료형식(XML/JSON) Default: XML*/ diff --git a/pav-server/src/main/java/com/palnet/biz/api/ctr/cntrl/service/CtrCntrlService.java b/pav-server/src/main/java/com/palnet/biz/api/ctr/cntrl/service/CtrCntrlService.java index 809c0250..1cd32f3e 100644 --- a/pav-server/src/main/java/com/palnet/biz/api/ctr/cntrl/service/CtrCntrlService.java +++ b/pav-server/src/main/java/com/palnet/biz/api/ctr/cntrl/service/CtrCntrlService.java @@ -29,6 +29,7 @@ import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; import org.locationtech.jts.geom.Coordinate; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -47,6 +48,12 @@ import java.util.*; @Service public class CtrCntrlService { + @Value("${weather.api.url}") + private String weatherUrl; + + @Value("${weather.api.key}") + private String weatherKey; + private final JwtTokenUtil jwtTokenUtil; private final CtrTrnsLctnService ctrTrnsLctnService; private final FltPlanCtrCntrlRelRepository relRepository; @@ -556,7 +563,7 @@ public class CtrCntrlService { public JSONObject getWeather(CtrCntrlWeatherModel rq) throws IOException, ParseException { - StringBuilder urlBuilder = new StringBuilder("http://apis.data.go.kr/1360000/VilageFcstInfoService_2.0/getVilageFcst"); + StringBuilder urlBuilder = new StringBuilder(weatherUrl); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); Calendar c1 = Calendar.getInstance(); @@ -636,7 +643,7 @@ public class CtrCntrlService { String Snx = String.format("%.0f",nx); String Sny = String.format("%.0f",ny); - urlBuilder.append("?" + URLEncoder.encode("serviceKey","UTF-8") + "=r6RMUsk3Vtama7D6uq7MiWV9dTC9MwfIIr4%2F45y0uVNw6BaYbgpKmL%2BLUDFVTfIYUmEe4K%2FaniEjdV9mg5t82Q%3D%3D"); + urlBuilder.append("?" + URLEncoder.encode("serviceKey","UTF-8") + weatherKey); urlBuilder.append("&" + URLEncoder.encode("pageNo","UTF-8") + "=" + URLEncoder.encode("1","UTF-8")); urlBuilder.append("&" + URLEncoder.encode("numOfRows","UTF-8") + "=" + URLEncoder.encode("14", "UTF-8")); /*한 페이지 결과 수*/ urlBuilder.append("&" + URLEncoder.encode("dataType","UTF-8") + "=" + URLEncoder.encode("JSON", "UTF-8")); /*요청자료형식(XML/JSON) Default: XML*/ diff --git a/pav-server/src/main/resources/application.properties b/pav-server/src/main/resources/application.properties index 572c3e1e..e16c2b40 100644 --- a/pav-server/src/main/resources/application.properties +++ b/pav-server/src/main/resources/application.properties @@ -14,6 +14,9 @@ naver.api.url=https://naveropenapi.apigw.ntruss.com/map-reversegeocode/v2/gc spring.jwt.secret=jwtsecretkey spring.jwt.prefix=palnet +### Weather key ### +weather.api.url = http://apis.data.go.kr/1360000/VilageFcstInfoService_2.0/getVilageFcst +weather.api.key = =r6RMUsk3Vtama7D6uq7MiWV9dTC9MwfIIr4%2F45y0uVNw6BaYbgpKmL%2BLUDFVTfIYUmEe4K%2FaniEjdV9mg5t82Q%3D%3D ### AWS S3 #### #cloud.aws.credentials.accessKey=AKIAW75VMZKFTMBRXK4I