Skip to content

Commit

Permalink
Merge pull request #2 from ri-naa/feat/message-3
Browse files Browse the repository at this point in the history
Feat/message 3
  • Loading branch information
ri-naa authored Jan 10, 2024
2 parents 91599f2 + fae197d commit 1c79779
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.io.IOException;

@RestController
@RequestMapping("/disaster")
Expand All @@ -25,13 +25,7 @@ public MessageController(MessageService messageService) {

@GetMapping("/message")
public MessageResponse getMessage(@AuthenticationPrincipal User user) throws IOException, ParseException {
// try {
// messageService.message();
// } catch (IOException e) {
// e.printStackTrace();
// } catch (ParseException e) {
// throw new RuntimeException(e);
// }

return messageService.message(user);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@ public class MessageResponse {
private String MSG_CN; //메세지 내용
private String CREAT_DT; //생성일
private List<String> RCV_AREA_ID; //수신지역 id
private List<String> RCV_AREA_NM; //수신지역명
private String EMRGNCY_STEP_ID; //긴급단계 id
private String DSSTR_SE_ID; //재해구분 id
private String DSSTR_SE_NM; //재해구분 명

public MessageResponse(String MSG_CN, String CREAT_DT, List<String> RCV_AREA_ID, String EMRGNCY_STEP_ID, String DSSTR_SE_ID){
public MessageResponse(String MSG_CN, String CREAT_DT, List<String> RCV_AREA_ID, List<String> RCV_AREA_NM, String EMRGNCY_STEP_ID, String DSSTR_SE_ID, String DSSTR_SE_NM){
this.MSG_CN = MSG_CN;
this.CREAT_DT = CREAT_DT;
this.RCV_AREA_ID = RCV_AREA_ID;
this.RCV_AREA_NM = RCV_AREA_NM;
this.EMRGNCY_STEP_ID = EMRGNCY_STEP_ID;
this.DSSTR_SE_ID = DSSTR_SE_ID;
this.DSSTR_SE_NM = DSSTR_SE_NM;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,25 @@ public MessageResponse message(User user) throws IOException, ParseException {

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();

List<String> areaArr = Arrays.stream(RCV_AREA_ID.split(",")).toList();
for(int i=0;i<areaArr.size();i++){
String a = areaArr.get(i);
List<String> areaIdArr = Arrays.stream(RCV_AREA_ID.split(",")).toList();
for(int i=0;i<areaIdArr.size();i++){
String a = areaIdArr.get(i);
}

List<String> areaNmArr = Arrays.stream(RCV_AREA_NM.split(",")).toList();
for(int i=0;i<areaNmArr.size();i++){
String a = areaNmArr.get(i);
}


String translatedMSG = naverTransService.getTransSentence(MSG_CN, user);
MessageResponse response = new MessageResponse(translatedMSG, CREAT_DT, areaArr, EMRGNCY_STEP_ID, DSSTR_SE_ID);
MessageResponse response = new MessageResponse(translatedMSG, CREAT_DT, areaIdArr, areaNmArr, EMRGNCY_STEP_ID, DSSTR_SE_ID, DSSTR_SE_NM);
return response;
}
}

0 comments on commit 1c79779

Please sign in to comment.