diff --git a/src/main/java/com/ALGo/ALGo_server/message/controller/MessageController.java b/src/main/java/com/ALGo/ALGo_server/message/controller/MessageController.java index 863589b..05f01b7 100644 --- a/src/main/java/com/ALGo/ALGo_server/message/controller/MessageController.java +++ b/src/main/java/com/ALGo/ALGo_server/message/controller/MessageController.java @@ -25,7 +25,7 @@ public MessageController(MessageService messageService) { } @GetMapping("/message") - public List getMessage(@AuthenticationPrincipal User user) throws IOException, ParseException { + public MessageResponse getMessage(@AuthenticationPrincipal User user) throws IOException, ParseException { return messageService.message(user); } diff --git a/src/main/java/com/ALGo/ALGo_server/message/service/MessageService.java b/src/main/java/com/ALGo/ALGo_server/message/service/MessageService.java index ed62dbd..a67e277 100644 --- a/src/main/java/com/ALGo/ALGo_server/message/service/MessageService.java +++ b/src/main/java/com/ALGo/ALGo_server/message/service/MessageService.java @@ -30,14 +30,14 @@ public class MessageService { private final NaverTransService naverTransService; - public List message(User user) throws IOException, ParseException { + public MessageResponse message(User user) throws IOException, ParseException { StringBuilder urlBuilder = new StringBuilder("https://www.safetydata.go.kr/openApi"); urlBuilder.append("/" + URLEncoder.encode("행정안전부_긴급재난문자","UTF-8")); urlBuilder.append("?serviceKey=" + secretKey); urlBuilder.append("&returnType=json"); urlBuilder.append("&pageNum=1"); - urlBuilder.append("&numRowsPerPage=4"); + urlBuilder.append("&numRowsPerPage=10"); URL url = new URL(urlBuilder.toString()); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); @@ -101,33 +101,34 @@ public List message(User user) throws IOException, ParseExcepti msgResArr.add(response); } - return msgResArr; + //user 지역 + String city = user.getCity() + " "; + String gu = user.getGu() + " "; + String combinedCity = city + gu; - /* - JSONObject dataObject = (JSONObject) dataArr.get(0); + MessageResponse result = null; - String CREAT_DT = dataObject.get("CREAT_DT").toString(); - String DSSTR_SE_ID = dataObject.get("DSSTR_SE_ID").toString(); - String DSSTR_SE_NM = dataObject.get("DSSTR_SE_NM").toString(); - String EMRGNCY_STEP_ID = dataObject.get("EMRGNCY_STEP_ID").toString(); - String MSG_CN = dataObject.get("MSG_CN").toString(); - String RCV_AREA_ID = dataObject.get("RCV_AREA_ID").toString(); - String RCV_AREA_NM = dataObject.get("RCV_AREA_NM").toString(); + // 지역 찾기 + for (int i=0; i areaIdArr = Arrays.stream(RCV_AREA_ID.split(",")).toList(); - for(int i=0;i msgAreaNMArr = msgResArr.get(i).getRCV_AREA_NM(); - List areaNmArr = Arrays.stream(RCV_AREA_NM.split(",")).toList(); - for(int i=0;i