-
Notifications
You must be signed in to change notification settings - Fork 2
[Location] kakaomap api, tmap api 연동 및 구현 및 환경변수 추가 #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c132b4a
feat: kakao api 연동 및 주변 반경 리스트
tobbot16 fd58167
Merge branch 'main' into feat/#34
tobbot16 8a1b3bb
feat: Tmap 대중교통 경로추천 api 연동
tobbot16 2fed0f8
feat: 스프링 시큐리티 gradle 추가
tobbot16 e31d5b8
Merge branch 'main' into feat/#34
Creamcheesepie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| import org.gradle.kotlin.dsl.implementation | ||
|
|
||
| plugins { | ||
| java | ||
| id("org.springframework.boot") version "3.5.8" | ||
|
|
||
28 changes: 28 additions & 0 deletions
28
...ain/java/com/back/web7_9_codecrete_be/domain/location/controller/KakaoTestController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package com.back.web7_9_codecrete_be.domain.location.controller; | ||
|
|
||
| import com.back.web7_9_codecrete_be.domain.location.dto.KakaoLocalResponse; | ||
| import com.back.web7_9_codecrete_be.domain.location.service.KakaoLocalService; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/api/test") | ||
| @RequiredArgsConstructor | ||
| public class KakaoTestController { | ||
|
|
||
| private final KakaoLocalService kakaoLocalService; | ||
|
|
||
| @GetMapping("/kakao-restaurants") | ||
| public List<KakaoLocalResponse.Document> testKakaoRestaurants() { | ||
|
|
||
| // ✅ 테스트용 하드코딩 좌표 (서울 시청 근처) | ||
| double lat = 37.5665; | ||
| double lng = 126.9780; | ||
|
|
||
| return kakaoLocalService.searchNearbyRestaurants(lat, lng); | ||
| } | ||
| } |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/back/web7_9_codecrete_be/domain/location/controller/TmapController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package com.back.web7_9_codecrete_be.domain.location.controller; | ||
|
|
||
| import com.back.web7_9_codecrete_be.domain.location.service.TmapService; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RequestParam; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @RequestMapping("/api/tmap") | ||
| public class TmapController { | ||
|
|
||
| private final TmapService tmapService; | ||
|
|
||
| @GetMapping("/transit") | ||
| public String getTransit( | ||
| @RequestParam double startX, | ||
| @RequestParam double startY, | ||
| @RequestParam double endX, | ||
| @RequestParam double endY | ||
| ) { | ||
| return tmapService.getRoute(startX, startY, endX, endY); | ||
| } | ||
| } | ||
20 changes: 20 additions & 0 deletions
20
src/main/java/com/back/web7_9_codecrete_be/domain/location/dto/KakaoLocalResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package com.back.web7_9_codecrete_be.domain.location.dto; | ||
|
|
||
| import lombok.Data; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Data | ||
| public class KakaoLocalResponse { | ||
| private List<Document> documents; | ||
|
|
||
| @Data | ||
| public static class Document { | ||
| private String place_name; | ||
| private String x; // longitude | ||
| private String y; // latitude | ||
| private String road_address_name; | ||
| private String address_name; | ||
| private String place_url; | ||
| } | ||
| } |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/back/web7_9_codecrete_be/domain/location/dto/TmapResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.back.web7_9_codecrete_be.domain.location.dto; | ||
|
|
||
| import lombok.Data; | ||
|
|
||
| @Data | ||
| public class TmapResponse { | ||
|
|
||
| private String startX; | ||
| private String startY; | ||
| private String endX; | ||
| private String endY; | ||
| private int count; //최대 응답 결과 개수 | ||
| private String format; //출력포멧 : jsom, xml | ||
|
|
||
| } |
Empty file.
32 changes: 32 additions & 0 deletions
32
src/main/java/com/back/web7_9_codecrete_be/domain/location/service/KakaoLocalService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package com.back.web7_9_codecrete_be.domain.location.service; | ||
|
|
||
| import com.back.web7_9_codecrete_be.domain.location.dto.KakaoLocalResponse; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.web.reactive.function.client.WebClient; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class KakaoLocalService { | ||
|
|
||
| private final WebClient kakaoWebClient; | ||
|
|
||
| public List<KakaoLocalResponse.Document> searchNearbyRestaurants(double lat, double lng) { | ||
|
|
||
| return kakaoWebClient.get() | ||
| .uri(uriBuilder -> uriBuilder | ||
| .path("/v2/local/search/keyword.json") | ||
| .queryParam("query", "음식점") | ||
| .queryParam("y", lat) | ||
| .queryParam("x", lng) | ||
| .queryParam("radius", 1000) // 반경 1km | ||
| .build() | ||
| ) | ||
| .retrieve() | ||
| .bodyToMono(KakaoLocalResponse.class) | ||
| .block() // 동기 호출 (필요하면 비동기로 변경 가능) | ||
| .getDocuments(); | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/back/web7_9_codecrete_be/domain/location/service/TmapService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package com.back.web7_9_codecrete_be.domain.location.service; | ||
|
|
||
| import com.back.web7_9_codecrete_be.domain.location.dto.KakaoLocalResponse; | ||
| import com.back.web7_9_codecrete_be.domain.location.dto.TmapResponse; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.web.reactive.function.client.WebClient; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class TmapService { | ||
|
|
||
| private final WebClient TmapClient; | ||
|
|
||
| public String getRoute(double startX, double startY, double endX, double endY) { | ||
|
|
||
| TmapResponse request = new TmapResponse(); | ||
| request.setStartX(String.valueOf(startX)); | ||
| request.setStartY(String.valueOf(startY)); | ||
| request.setEndX(String.valueOf(endX)); | ||
| request.setEndY(String.valueOf(endY)); | ||
| request.setFormat("json"); | ||
| request.setCount(5); | ||
|
|
||
| return TmapClient.post() | ||
| .uri("/transit/routes") | ||
| .bodyValue(request) | ||
| .retrieve() | ||
| .bodyToMono(String.class) | ||
| .block(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletions
5
src/test/java/com/back/web7_9_codecrete_be/domain/location/service/dummy.txt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
URL 에 v1 추가해주시면 감사하겠습니당
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵! 까먹고 있었는데 말씀해주셔서 감사합니다