Skip to content

Commit 0b01e1d

Browse files
committed
feat: 카카오맵 근처 음식점, 카페 불러오는 api에서 값을 post 형ì�식 추가
1 parent 0c93b28 commit 0b01e1d

2 files changed

Lines changed: 61 additions & 0 deletions

File tree

src/main/java/com/back/web7_9_codecrete_be/domain/location/controller/KakaoTestController.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class KakaoTestController {
2929
@ApiResponse(responseCode = "200", description = "조회 성공",
3030
content = @Content(schema = @Schema(implementation = KakaoLocalResponse.Document.class)))
3131
@GetMapping("/restaurants")
32+
3233
public List<KakaoLocalResponse.Document> testKakaoRestaurants() {
3334

3435
double lat = 37.5665;
@@ -37,6 +38,47 @@ public List<KakaoLocalResponse.Document> testKakaoRestaurants() {
3738
return kakaoLocalService.searchNearbyRestaurants(lat, lng);
3839
}
3940

41+
@Operation(
42+
summary = "주변 음식점 조회(테스트)",
43+
description = "테스트용 좌표(서울 시청 근처)로 카카오 로컬에서 주변 음식점을 조회합니다, 좌표는 입력하면 됩니다." +
44+
"예시 : http://localhost:8080/api/v1/location/kakao/restaurant?lat=37.5665&lng=126.9780"
45+
)
46+
@PostMapping("/restaurant")
47+
public List<KakaoLocalResponse.Document> KakaoRestaurants(
48+
@RequestParam double lat,
49+
@RequestParam double lng
50+
){
51+
return kakaoLocalService.searchNearbyRestaurants(lat, lng);
52+
}
53+
54+
@Operation(
55+
summary = "주변 카페 조회(테스트)",
56+
description = "테스트용 하드코딩 좌표(서울 시청 근처)로 카카오 로컬에서 주변 카페를 조회합니다., 하드코딩 좌표 : lat - 37.5665, lng -126.9780"
57+
)
58+
@ApiResponse(responseCode = "200", description = "조회 성공",
59+
content = @Content(schema = @Schema(implementation = KakaoLocalResponse.Document.class)))
60+
@GetMapping("/cafes")
61+
public List<KakaoLocalResponse.Document> testKakaoCafes() {
62+
63+
double lat = 37.5665;
64+
double lng = 126.9780;
65+
66+
return kakaoLocalService.searchNearbyCafes(lat, lng);
67+
}
68+
69+
@Operation(
70+
summary = "주변 카페 조회(테스트)",
71+
description = "테스트용 좌표(서울 시청 근처)로 카카오 로컬에서 주변 카페를 조회합니다, 좌표는 입력하면 됩니다." +
72+
"예시 : http://localhost:8080/api/v1/location/kakao/cafes?lat=37.5665&lng=126.9780"
73+
)
74+
@PostMapping("/cafes")
75+
public List<KakaoLocalResponse.Document> KakaoCafes(
76+
@RequestParam double lat,
77+
@RequestParam double lng
78+
){
79+
return kakaoLocalService.searchNearbyCafes(lat, lng);
80+
}
81+
4082

4183
@Operation(
4284
summary = "좌표를 주소로 변환",

src/main/java/com/back/web7_9_codecrete_be/domain/location/service/KakaoLocalService.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,25 @@ public List<KakaoLocalResponse.Document> searchNearbyRestaurants(double lat, dou
2525
.queryParam("y", lat)
2626
.queryParam("x", lng)
2727
.queryParam("radius", 1000) // 반경 1km
28+
.queryParam("sort", "distance")
29+
.build()
30+
)
31+
.retrieve()
32+
.bodyToMono(KakaoLocalResponse.class)
33+
.block() // 동기 호출 (필요하면 비동기로 변경 가능)
34+
.getDocuments();
35+
}
36+
public List<KakaoLocalResponse.Document> searchNearbyCafes(double lat, double lng) {
37+
38+
return kakaoWebClient.get()
39+
.uri(uriBuilder -> uriBuilder
40+
.path("/v2/local/search/keyword.json")
41+
.queryParam("query", "카페")
42+
.queryParam("category_group_code", "CE7")
43+
.queryParam("y", lat)
44+
.queryParam("x", lng)
45+
.queryParam("radius", 1000) // 반경 1km
46+
.queryParam("sort", "distance")
2847
.build()
2948
)
3049
.retrieve()

0 commit comments

Comments
 (0)