Skip to content

Commit

Permalink
Merge pull request #13 from oven-2023/recommendation
Browse files Browse the repository at this point in the history
Recommendation
  • Loading branch information
see101702 authored Oct 19, 2023
2 parents 56bbb98 + 845bb05 commit af1cde0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,20 @@ public Response<List<WorkListDto>> getPopularWorkList() {

}

// /home/recommendation/provider
@GetMapping("/recommendation/works")
public Response<List<WorkListDto>> getRecommendWorkList(@AuthenticationPrincipal User user) {
String response = springToFlaskService.springToFlask(user);

try {
List<WorkListDto> recommendWorkDtoList = getRecommendWorkListService.getRecommendWorkList(response);
return Response.success(ResponseCode.SUCCESS_OK, recommendWorkDtoList);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}


// /home/recommendation/provider


}
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ public class SpringToFlaskService {
private final UserRepository userRepository;
private final WorkRepository workRepository;

public void springToFlask(User user, String csvContent) {
String flaskApiUrl = "http://43.201.68.242:5000/spring";
public String springToFlask(User user) {
String flaskApiUrl = "http://172.17.0.2:6000/spring";
String userId = String.valueOf(user.getId());

//HTTP 요청 헤더 설정
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);

//HTTP 요청 본문 설정
HttpEntity<String[]> requestEntity = new HttpEntity<>(new String[]{userId, csvContent}, headers);
HttpEntity<String> requestEntity = new HttpEntity<>(userId, headers);

//RestTemplate를 사용하여 POST 요청 보내기
RestTemplate restTemplate = new RestTemplate();
Expand All @@ -44,8 +44,10 @@ public void springToFlask(User user, String csvContent) {
if (responseEntity.getStatusCode().is2xxSuccessful()) {
String response = responseEntity.getBody();
System.out.println("플라스크 서버 응답: " + response);
return response;
} else {
System.out.println("HTTP 요청 실패 " + responseEntity.getStatusCodeValue());
return responseEntity.getStatusCode().toString();
}
}

Expand Down

0 comments on commit af1cde0

Please sign in to comment.