Browse Source

날씨 API serviceKey 및 URL 정보 관리

master
leehagjoon(이학준) 11 months ago
parent
commit
5e4a6d1f1a
  1. 9
      src/main/java/com/palnet/biz/api/bas/flight/service/BasFlightService.java
  2. 10
      src/main/java/com/palnet/biz/api/ctr/cntrl/service/CtrCntrlService.java
  3. 3
      src/main/resources/application.properties

9
src/main/java/com/palnet/biz/api/bas/flight/service/BasFlightService.java

@ -77,6 +77,11 @@ public class BasFlightService {
@Value("${spring.config.activate.on-profile:}") @Value("${spring.config.activate.on-profile:}")
private String profile; private String profile;
@Value("${weather.api.url}")
private String weatherUrl;
@Value("${weather.api.key}")
private String weatherKey;
private final FltPlanBasRepository fltPlanBasRepository; private final FltPlanBasRepository fltPlanBasRepository;
private final FltPlanArcrftRepository fltPlanArcrftRepository; private final FltPlanArcrftRepository fltPlanArcrftRepository;
private final FltPlanAreaRepository fltPlanAreaRepository; private final FltPlanAreaRepository fltPlanAreaRepository;
@ -713,8 +718,8 @@ public class BasFlightService {
return schedule; return schedule;
} }
public JSONObject getWeather(BasFlightWeatherModel rq) throws IOException, ParseException { public JSONObject getWeather(BasFlightWeatherModel rq) throws IOException, ParseException {
StringBuilder urlBuilder = new StringBuilder("http://apis.data.go.kr/1360000/VilageFcstInfoService_2.0/getVilageFcst"); StringBuilder urlBuilder = new StringBuilder(weatherUrl);
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(rq.getPageNo(),"UTF-8")); 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("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*/ urlBuilder.append("&" + URLEncoder.encode("dataType","UTF-8") + "=" + URLEncoder.encode("JSON", "UTF-8")); /*요청자료형식(XML/JSON) Default: XML*/

10
src/main/java/com/palnet/biz/api/ctr/cntrl/service/CtrCntrlService.java

@ -24,6 +24,7 @@ import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException; import org.json.simple.parser.ParseException;
import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Coordinate;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -87,6 +88,11 @@ public class CtrCntrlService {
@Autowired @Autowired
private FltPlanCtrCntrlRelRepository relRepository; private FltPlanCtrCntrlRelRepository relRepository;
@Value("${weather.api.url}")
private String weatherUrl;
@Value("${weather.api.key}")
private String weatherKey;
private final CtrCntrlQueryRepository query; private final CtrCntrlQueryRepository query;
private final CtrCntrlBasRepository cntrlBasRepository; private final CtrCntrlBasRepository cntrlBasRepository;
private final CtrCntrlHstryRepository cntrlHstryRepository; private final CtrCntrlHstryRepository cntrlHstryRepository;
@ -617,7 +623,7 @@ public class CtrCntrlService {
public JSONObject getWeather(CtrCntrlWeatherModel rq) throws IOException, ParseException { 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"); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Calendar c1 = Calendar.getInstance(); Calendar c1 = Calendar.getInstance();
@ -697,7 +703,7 @@ public class CtrCntrlService {
String Snx = String.format("%.0f",nx); String Snx = String.format("%.0f",nx);
String Sny = String.format("%.0f",ny); 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("pageNo","UTF-8") + "=" + URLEncoder.encode("1","UTF-8"));
urlBuilder.append("&" + URLEncoder.encode("numOfRows","UTF-8") + "=" + URLEncoder.encode("14", "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*/ urlBuilder.append("&" + URLEncoder.encode("dataType","UTF-8") + "=" + URLEncoder.encode("JSON", "UTF-8")); /*요청자료형식(XML/JSON) Default: XML*/

3
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.secret=jwtsecretkey
spring.jwt.prefix=palnet 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 #### ### AWS S3 ####
#cloud.aws.credentials.accessKey=AKIAW75VMZKFTMBRXK4I #cloud.aws.credentials.accessKey=AKIAW75VMZKFTMBRXK4I

Loading…
Cancel
Save