Skip to content

Commit

Permalink
Feat: Add address query
Browse files Browse the repository at this point in the history
  • Loading branch information
Minjae-vincent committed Jul 16, 2024
1 parent 878079d commit e6545ca
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
Expand Down Expand Up @@ -320,9 +322,7 @@ private List<InfraDTO.BusStation> getBusStations(String gu) {
}

public List<JeonseCheckList> recommendJeonse(RecommendRequest recommendRequest) {
String[] atclNos = getRecommendationList(recommendRequest);

// String[] atclNos = {"2430006535", "2433524070", "2433775697", "2434392198", "2431314046", "2429677439", "2432722911", "2430296803", "2433186783"};
List<String> atclNos = getRecommendationList(recommendRequest);

List<JeonseCheckList> recommendList = new ArrayList<>();

Expand All @@ -349,17 +349,24 @@ public List<JeonseCheckList> recommendJeonse(RecommendRequest recommendRequest)
return recommendList;
}

private String[] getRecommendationList(RecommendRequest recommendRequest) {
private List<String> getRecommendationList(RecommendRequest recommendRequest) {
final String FLASK_API_URL = "http://34.64.201.85:5000/run-b";

HttpHeaders headers = new HttpHeaders();
headers.set("Content-Type", "application/json");

HttpEntity<RecommendRequest> entity = new HttpEntity<>(recommendRequest, headers);

ResponseEntity<String[]> response = restTemplate.exchange(FLASK_API_URL, HttpMethod.POST, entity, String[].class);
ResponseEntity<String> response = restTemplate.exchange(FLASK_API_URL, HttpMethod.POST, entity, String.class);

String responseBody = response.getBody();
JSONObject jsonObject = new JSONObject(responseBody);

JSONArray jsonArray = jsonObject.getJSONArray("data");

return jsonArray.toList().stream().map(Object::toString).collect(Collectors.toList());


return response.getBody();
}

public List<Jeonse> getAddressList(String address) {
Expand Down

0 comments on commit e6545ca

Please sign in to comment.