diff --git a/src/main/java/com/example/fiurinee/domain/inputMessage/controller/ModelController.java b/src/main/java/com/example/fiurinee/domain/inputMessage/controller/ModelController.java index dd2e136..cc4f30d 100644 --- a/src/main/java/com/example/fiurinee/domain/inputMessage/controller/ModelController.java +++ b/src/main/java/com/example/fiurinee/domain/inputMessage/controller/ModelController.java @@ -30,7 +30,7 @@ public ResponseEntity> inputMent(@PathVariable("id") Long @RequestBody RequestMentDto mentDto){ String ment = mentDto.ment(); inputMessageService.saveInputMessage(id, ment); - String url = "http://localhost:8080/model/test"; + String url = "http://3.106.186.161/api/recommend"; int value = LocalDateTime.now().getMonth().getValue(); @@ -56,7 +56,7 @@ public ResponseEntity> inputMent(@PathVariable("id") Long @PostMapping("/ment") public ResponseEntity> inputMentNotMember(@RequestBody String ment){ - String url = "http://localhost:8080/model/test"; + String url = "http://3.106.186.161/api/recommend"; int value = LocalDateTime.now().getMonth().getValue(); @@ -107,20 +107,4 @@ public ResponseEntity selectFlowerNonMember(@PathVar return ResponseEntity.ok(new ResponseHarmonyWitnMentDto("추천은 recommend, recommend는 영어로 추천, 내 너무 피곤하다,, 인생이란 뭘까",re)); } - - @PostMapping("/test") - public List modelTest(@RequestBody MentDto mentDto) { - List re = new ArrayList<>(); - ModelMentResponseDto modelMentResponseDto0 = new ModelMentResponseDto("토레니아", "가련한 욕망"); - ModelMentResponseDto modelMentResponseDto1 = new ModelMentResponseDto("토마토", "완성된 아름다움"); - ModelMentResponseDto modelMentResponseDto2 = new ModelMentResponseDto("겹 캄파눌라", "따뜻한 사람"); - - - re.add(modelMentResponseDto0); - re.add(modelMentResponseDto1); - re.add(modelMentResponseDto2); - - return re; - - } } diff --git a/src/main/java/com/example/fiurinee/domain/inputMessage/dto/MentDto.java b/src/main/java/com/example/fiurinee/domain/inputMessage/dto/MentDto.java index 6434e6d..5ca5bc4 100644 --- a/src/main/java/com/example/fiurinee/domain/inputMessage/dto/MentDto.java +++ b/src/main/java/com/example/fiurinee/domain/inputMessage/dto/MentDto.java @@ -7,13 +7,13 @@ @Getter public class MentDto { - private String ment; - private int month; + private String user_input; + private int user_month; public MentDto(){} public MentDto(String ment, int month) { - this.ment = ment; - this.month = month; + this.user_input = ment; + this.user_month = month; } } diff --git a/src/main/java/com/example/fiurinee/domain/inputMessage/dto/ModelMentResponseDto.java b/src/main/java/com/example/fiurinee/domain/inputMessage/dto/ModelMentResponseDto.java index ffa509a..9330c1c 100644 --- a/src/main/java/com/example/fiurinee/domain/inputMessage/dto/ModelMentResponseDto.java +++ b/src/main/java/com/example/fiurinee/domain/inputMessage/dto/ModelMentResponseDto.java @@ -1,17 +1,24 @@ package com.example.fiurinee.domain.inputMessage.dto; +import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Getter; @Getter public class ModelMentResponseDto { - + @JsonProperty("꽃") private String name; + + @JsonProperty("꽃말") private String flowerLanguage; + @JsonProperty("유사도") + private Double similarity; + public ModelMentResponseDto(){} public ModelMentResponseDto(String name, String flowerLanguage) { this.name = name; this.flowerLanguage = flowerLanguage; + this.similarity = 0.1; } } diff --git a/src/main/java/com/example/fiurinee/domain/inputMessage/dto/RecommendationResponse.java b/src/main/java/com/example/fiurinee/domain/inputMessage/dto/RecommendationResponse.java new file mode 100644 index 0000000..4dfe75d --- /dev/null +++ b/src/main/java/com/example/fiurinee/domain/inputMessage/dto/RecommendationResponse.java @@ -0,0 +1,19 @@ +package com.example.fiurinee.domain.inputMessage.dto; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; + +import java.util.List; + +@Getter +public class RecommendationResponse { + @JsonProperty("recommendations") + private List recommendations; + + public RecommendationResponse() {} + + public RecommendationResponse(List recommendations) { + this.recommendations = recommendations; + } +} + diff --git a/src/main/java/com/example/fiurinee/global/api/service/CallApiService.java b/src/main/java/com/example/fiurinee/global/api/service/CallApiService.java index bf31446..2ce993d 100644 --- a/src/main/java/com/example/fiurinee/global/api/service/CallApiService.java +++ b/src/main/java/com/example/fiurinee/global/api/service/CallApiService.java @@ -2,6 +2,7 @@ import com.example.fiurinee.domain.inputMessage.dto.MentDto; import com.example.fiurinee.domain.inputMessage.dto.ModelMentResponseDto; +import com.example.fiurinee.domain.inputMessage.dto.RecommendationResponse; import com.example.fiurinee.domain.inputMessage.dto.ResponseMentDto; import com.example.fiurinee.domain.member.entity.Member; import com.example.fiurinee.domain.oauth2.dto.KakaoLogoutDto; @@ -13,6 +14,7 @@ import org.springframework.web.reactive.function.client.WebClient; import java.util.List; +import java.util.Objects; @Service @Transactional @@ -72,14 +74,15 @@ public static List mentApi(String url, MentDto mentDto) { WebClient webClient = WebClient.builder().build(); - return webClient + RecommendationResponse response = webClient .post() .uri(url) .contentType(MediaType.APPLICATION_JSON) .bodyValue(mentDto) .retrieve() - .bodyToMono(new ParameterizedTypeReference>() {}) + .bodyToMono(RecommendationResponse.class) .block(); + return Objects.requireNonNull(response).getRecommendations(); } }