From e087c7df5bdff9ce7dc92a7cea3cc984a5a3934b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=8A=B9=EC=A7=84?= Date: Thu, 23 Nov 2023 15:03:01 +0900 Subject: [PATCH] =?UTF-8?q?[HOTFIX]=20=EC=9E=A5=EC=86=8C=20=EA=B2=80?= =?UTF-8?q?=EC=83=89=20=EA=B2=B0=EA=B3=BC=20=EC=97=86=EC=9D=84=EC=8B=9C=20?= =?UTF-8?q?=EC=A2=8C=ED=91=9C=20=EC=97=86=EC=9D=B4=20=EC=9A=94=EC=B2=AD?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plan/client/SearchDestinationClient.java | 15 +++++++-------- .../plan/dto/client/SearchDestinationRequest.java | 4 ++++ .../backend/domain/plan/service/PlanService.java | 6 +++++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/backend/src/main/java/com/twtw/backend/domain/plan/client/SearchDestinationClient.java b/backend/src/main/java/com/twtw/backend/domain/plan/client/SearchDestinationClient.java index a6b96169..d66aca88 100644 --- a/backend/src/main/java/com/twtw/backend/domain/plan/client/SearchDestinationClient.java +++ b/backend/src/main/java/com/twtw/backend/domain/plan/client/SearchDestinationClient.java @@ -4,17 +4,14 @@ import com.twtw.backend.domain.plan.dto.client.SearchDestinationRequest; import com.twtw.backend.domain.plan.dto.client.SearchDestinationResponse; import com.twtw.backend.global.client.KakaoMapClient; -import com.twtw.backend.global.exception.WebClientResponseException; import com.twtw.backend.global.properties.KakaoProperties; - +import java.net.URI; +import java.nio.charset.StandardCharsets; import org.springframework.http.MediaType; import org.springframework.stereotype.Component; import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.util.UriBuilder; -import java.net.URI; -import java.nio.charset.StandardCharsets; - @Component public class SearchDestinationClient extends KakaoMapClient { @@ -37,7 +34,7 @@ public SearchDestinationResponse request(final SearchDestinationRequest request) .retrieve() .bodyToMono(SearchDestinationResponse.class) .blockOptional() - .orElseThrow(WebClientResponseException::new); + .orElseGet(SearchDestinationResponse::new); } private URI getUri(final SearchDestinationRequest request, final UriBuilder uriBuilder) { @@ -45,7 +42,6 @@ private URI getUri(final SearchDestinationRequest request, final UriBuilder uriB uriBuilder .path("search/keyword") .queryParam("query", request.getQuery()) - .queryParam("radius", DEFAULT_DISTANCE_RADIUS) .queryParam("page", request.getPage()) .queryParam("size", MAX_SIZE_PER_REQUEST); @@ -54,7 +50,10 @@ private URI getUri(final SearchDestinationRequest request, final UriBuilder uriB final Double y = request.getY(); if (x != null && y != null) { - builder.queryParam("x", Double.toString(x)).queryParam("y", Double.toString(y)); + builder + .queryParam("x", Double.toString(x)) + .queryParam("y", Double.toString(y)) + .queryParam("radius", DEFAULT_DISTANCE_RADIUS); } if (categoryGroupCode.isNone()) { return builder.build(); diff --git a/backend/src/main/java/com/twtw/backend/domain/plan/dto/client/SearchDestinationRequest.java b/backend/src/main/java/com/twtw/backend/domain/plan/dto/client/SearchDestinationRequest.java index 466ce7a6..fb58379f 100644 --- a/backend/src/main/java/com/twtw/backend/domain/plan/dto/client/SearchDestinationRequest.java +++ b/backend/src/main/java/com/twtw/backend/domain/plan/dto/client/SearchDestinationRequest.java @@ -17,4 +17,8 @@ public class SearchDestinationRequest { private Double y; private Integer page; private CategoryGroupCode categoryGroupCode; + + public SearchDestinationRequest toNoDirectionRequest() { + return new SearchDestinationRequest(query, null, null, page, categoryGroupCode); + } } diff --git a/backend/src/main/java/com/twtw/backend/domain/plan/service/PlanService.java b/backend/src/main/java/com/twtw/backend/domain/plan/service/PlanService.java index 37c0e70d..ac1a7855 100644 --- a/backend/src/main/java/com/twtw/backend/domain/plan/service/PlanService.java +++ b/backend/src/main/java/com/twtw/backend/domain/plan/service/PlanService.java @@ -52,7 +52,11 @@ public PlanDestinationResponse searchPlanDestination(final SearchDestinationRequ } private SearchDestinationResponse requestMapClient(final SearchDestinationRequest request) { - return destinationClient.request(request); + final SearchDestinationResponse result = destinationClient.request(request); + if (result.getDocuments().isEmpty()) { + return destinationClient.request(request.toNoDirectionRequest()); + } + return result; } public PlanResponse savePlan(final SavePlanRequest request) {