11package com.back.koreaTravelGuide.domain.ai.tour.client
22
3- import com.back.koreaTravelGuide.domain.ai.tour.dto.LocationBasedParams
3+ import com.back.koreaTravelGuide.common.logging.log
44import com.back.koreaTravelGuide.domain.ai.tour.dto.TourDetailItem
55import com.back.koreaTravelGuide.domain.ai.tour.dto.TourDetailParams
66import com.back.koreaTravelGuide.domain.ai.tour.dto.TourDetailResponse
77import com.back.koreaTravelGuide.domain.ai.tour.dto.TourItem
8+ import com.back.koreaTravelGuide.domain.ai.tour.dto.TourLocationBasedParams
89import com.back.koreaTravelGuide.domain.ai.tour.dto.TourParams
910import com.back.koreaTravelGuide.domain.ai.tour.dto.TourResponse
1011import com.fasterxml.jackson.databind.JsonNode
1112import com.fasterxml.jackson.databind.ObjectMapper
12- import org.slf4j.LoggerFactory
1313import org.springframework.beans.factory.annotation.Value
1414import org.springframework.stereotype.Component
1515import org.springframework.web.client.RestTemplate
16+ import org.springframework.web.reactive.function.server.RequestPredicates.queryParam
1617import org.springframework.web.util.UriComponentsBuilder
1718import java.net.URI
1819
@@ -24,9 +25,6 @@ class TourApiClient(
2425 @Value(" \$ {tour.api.key}" ) private val serviceKey : String ,
2526 @Value(" \$ {tour.api.base-url}" ) private val apiUrl : String ,
2627) {
27- // println 대신 SLF4J 로거 사용
28- private val logger = LoggerFactory .getLogger(TourApiClient ::class .java)
29-
3028 // 요청 URL 구성
3129 private fun buildUrl (params : TourParams ): URI =
3230 UriComponentsBuilder .fromUri(URI .create(apiUrl))
@@ -44,14 +42,11 @@ class TourApiClient(
4442
4543 // 지역 기반 관광 정보 조회 (areaBasedList2)
4644 fun fetchTourInfo (params : TourParams ): TourResponse {
47- logger.info(" 지역 기반 관광 정보 조회 시작" )
48-
4945 val url = buildUrl(params)
50- logger.info(" Tour API URL 생성 : $url " )
5146
5247 val body =
5348 runCatching { restTemplate.getForObject(url, String ::class .java) }
54- .onFailure { logger .error(" 관광 정보 조회 실패" , it) }
49+ .onFailure { log .error(" 관광 정보 조회 실패" , it) }
5550 .getOrNull()
5651
5752 return body
@@ -61,27 +56,30 @@ class TourApiClient(
6156 }
6257
6358 // 위치기반 관광정보 조회 (locationBasedList2)
64- fun fetchLocationBasedTours (params : LocationBasedParams ): TourResponse {
59+ fun fetchLocationBasedTours (
60+ tourParams : TourParams ,
61+ locationParams : TourLocationBasedParams ,
62+ ): TourResponse {
6563 val url =
6664 UriComponentsBuilder .fromUri(URI .create(apiUrl))
6765 .path(" /locationBasedList2" )
6866 .queryParam(" serviceKey" , serviceKey)
6967 .queryParam(" MobileOS" , " WEB" )
7068 .queryParam(" MobileApp" , " KoreaTravelGuide" )
7169 .queryParam(" _type" , " json" )
72- .queryParam(" mapX" , params .mapX)
73- .queryParam(" mapY" , params .mapY)
74- .queryParam(" radius" , params .radius)
75- .queryParam(" contentTypeId" , params .contentTypeId)
76- .queryParam(" areaCode" , params .areaCode)
77- .queryParam(" sigunguCode" , params .sigunguCode)
70+ .queryParam(" mapX" , locationParams .mapX)
71+ .queryParam(" mapY" , locationParams .mapY)
72+ .queryParam(" radius" , locationParams .radius)
73+ .queryParam(" contentTypeId" , tourParams .contentTypeId)
74+ .queryParam(" areaCode" , tourParams .areaCode)
75+ .queryParam(" sigunguCode" , tourParams .sigunguCode)
7876 .build()
7977 .encode()
8078 .toUri()
8179
8280 val body =
8381 runCatching { restTemplate.getForObject(url, String ::class .java) }
84- .onFailure { logger .error(" 위치기반 관광 정보 조회 실패" , it) }
82+ .onFailure { log .error(" 위치기반 관광 정보 조회 실패" , it) }
8583 .getOrNull()
8684
8785 return body
@@ -91,7 +89,7 @@ class TourApiClient(
9189 }
9290
9391 // 공통정보 조회 (detailCommon2)
94- fun fetchTourCommonDetail (params : TourDetailParams ): TourDetailResponse {
92+ fun fetchTourDetail (params : TourDetailParams ): TourDetailResponse {
9593 val url =
9694 UriComponentsBuilder .fromUri(URI .create(apiUrl))
9795 .path(" /detailCommon2" )
@@ -106,7 +104,7 @@ class TourApiClient(
106104
107105 val body =
108106 runCatching { restTemplate.getForObject(url, String ::class .java) }
109- .onFailure { logger .error(" 공통정보 조회 실패" , it) }
107+ .onFailure { log .error(" 공통정보 조회 실패" , it) }
110108 .getOrNull()
111109
112110 return body
@@ -179,7 +177,7 @@ class TourApiClient(
179177 .asText()
180178
181179 if (resultCode != " 0000" ) {
182- logger .warn(" {} API resultCode={}" , apiName, resultCode)
180+ log .warn(" {} API resultCode={}" , apiName, resultCode)
183181 return emptyList()
184182 }
185183
0 commit comments