-
Notifications
You must be signed in to change notification settings - Fork 1
[FEAT] 도보 최적 경로 API #56
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 all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
70500cb
[chore] web client 설정
zyovn e130030
[feat] tMap webClient 설정
zyovn 2a6e2b3
[refactor] tmap 패키지 global -> direction으로 이동
zyovn 1ab69ac
[feat] tmap dto, client
zyovn b299b24
Merge branch 'develop' of https://github.com/Wayble-Project/wayble-sp…
zyovn c5f5b36
[refactor] dto 관련 패키지 이동
zyovn 20e8246
[feat] tmap 보행자 api 호출
zyovn d9bdb25
Merge branch 'develop' of https://github.com/Wayble-Project/wayble-sp…
zyovn d0bed78
[docs] swagger schema 작성
zyovn d1a1dda
[fix] 피드백 반영
zyovn 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
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
27 changes: 27 additions & 0 deletions
27
src/main/java/com/wayble/server/common/config/WebClientConfig.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,27 @@ | ||
| package com.wayble.server.common.config; | ||
|
|
||
| import com.wayble.server.direction.external.tmap.TMapProperties; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.web.reactive.function.client.WebClient; | ||
|
|
||
| @Configuration | ||
| @RequiredArgsConstructor | ||
| public class WebClientConfig { | ||
|
|
||
| private final TMapProperties tMapProperties; | ||
|
|
||
| @Bean | ||
| public WebClient webClient() { | ||
| return WebClient.builder() | ||
| .build(); | ||
| } | ||
|
|
||
| @Bean | ||
| public WebClient tMapWebClient() { | ||
| return WebClient.builder() | ||
| .baseUrl(tMapProperties.baseUrl()) | ||
| .build(); | ||
| } | ||
| } |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/wayble/server/direction/controller/WalkingController.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,34 @@ | ||
| package com.wayble.server.direction.controller; | ||
|
|
||
| import com.wayble.server.common.response.CommonResponse; | ||
| import com.wayble.server.direction.controller.swagger.WalkingSwagger; | ||
| import com.wayble.server.direction.external.tmap.dto.request.TMapRequest; | ||
| import com.wayble.server.direction.external.tmap.dto.response.TMapParsingResponse; | ||
| import com.wayble.server.direction.service.WalkingService; | ||
| 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/v1/directions/walking") | ||
| public class WalkingController implements WalkingSwagger { | ||
|
|
||
| private final WalkingService walkingService; | ||
|
|
||
| @Override | ||
| @GetMapping() | ||
| public CommonResponse<TMapParsingResponse> callTMapApi( | ||
| @RequestParam double startX, | ||
| @RequestParam double startY, | ||
| @RequestParam double endX, | ||
| @RequestParam double endY, | ||
| @RequestParam String startName, | ||
| @RequestParam String endName | ||
| ) { | ||
| TMapRequest request = new TMapRequest(startX, startY, endX, endY, startName, endName); | ||
| return CommonResponse.success(walkingService.callTMapApi(request)); | ||
| } | ||
| } |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/wayble/server/direction/controller/swagger/WalkingSwagger.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,31 @@ | ||
| package com.wayble.server.direction.controller.swagger; | ||
|
|
||
| import com.wayble.server.common.response.CommonResponse; | ||
| import com.wayble.server.direction.external.tmap.dto.response.TMapParsingResponse; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import org.springframework.web.bind.annotation.RequestParam; | ||
|
|
||
| @Tag(name = "[도보]", description = "도보 길찾기 관련 API") | ||
| public interface WalkingSwagger { | ||
| @Operation( | ||
| summary = "도보 최적 경로 길찾기 API", | ||
| description = "T MAP API를 호출하여 도보 최적 경로 길찾기를 진행합니다." | ||
| ) | ||
| @ApiResponses(value = { | ||
| @ApiResponse( | ||
| responseCode = "200", | ||
| description = "T MAP API 호출이 성공적으로 실행되었습니다." | ||
| ) | ||
| }) | ||
| CommonResponse<TMapParsingResponse> callTMapApi( | ||
| @RequestParam double startX, | ||
| @RequestParam double startY, | ||
| @RequestParam double endX, | ||
| @RequestParam double endY, | ||
| @RequestParam String startName, | ||
| @RequestParam String endName | ||
| ); | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/wayble/server/direction/exception/WalkingErrorCase.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,17 @@ | ||
| package com.wayble.server.direction.exception; | ||
|
|
||
| import com.wayble.server.common.exception.ErrorCase; | ||
| import lombok.Getter; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Getter | ||
| @RequiredArgsConstructor | ||
| public enum WalkingErrorCase implements ErrorCase { | ||
|
|
||
| T_MAP_API_FAILED(500, 8001, "T MAP API 호출에 실패했습니다."), | ||
| ; | ||
|
|
||
| private final Integer httpStatusCode; | ||
| private final Integer errorCode; | ||
| private final String message; | ||
| } |
27 changes: 27 additions & 0 deletions
27
src/main/java/com/wayble/server/direction/external/tmap/TMapClient.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,27 @@ | ||
| package com.wayble.server.direction.external.tmap; | ||
|
|
||
| import com.wayble.server.direction.external.tmap.dto.request.TMapRequest; | ||
| import com.wayble.server.direction.external.tmap.dto.response.TMapResponse; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.MediaType; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.web.reactive.function.client.WebClient; | ||
|
|
||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class TMapClient { | ||
|
|
||
| private final WebClient tMapWebClient; | ||
| private final TMapProperties tMapProperties; | ||
|
|
||
| public TMapResponse response(TMapRequest request) { | ||
| return tMapWebClient.post() | ||
| .uri(tMapProperties.baseUrl()) | ||
| .header("appKey", tMapProperties.secretKey()) | ||
| .contentType(MediaType.APPLICATION_JSON) | ||
| .bodyValue(request) | ||
| .retrieve() | ||
| .bodyToMono(TMapResponse.class) | ||
| .block(); | ||
| } | ||
| } | ||
10 changes: 10 additions & 0 deletions
10
src/main/java/com/wayble/server/direction/external/tmap/TMapProperties.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,10 @@ | ||
| package com.wayble.server.direction.external.tmap; | ||
|
|
||
| import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
|
||
| @ConfigurationProperties(prefix = "tmap") | ||
| public record TMapProperties( | ||
| String secretKey, | ||
| String baseUrl | ||
| ) { | ||
| } | ||
|
zyovn marked this conversation as resolved.
|
||
14 changes: 14 additions & 0 deletions
14
src/main/java/com/wayble/server/direction/external/tmap/dto/request/TMapRequest.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,14 @@ | ||
| package com.wayble.server.direction.external.tmap.dto.request; | ||
|
|
||
| import lombok.Builder; | ||
|
|
||
| @Builder | ||
| public record TMapRequest( | ||
| double startX, | ||
| double startY, | ||
| double endX, | ||
| double endY, | ||
| String startName, | ||
| String endName | ||
| ) { | ||
| } | ||
|
zyovn marked this conversation as resolved.
|
||
74 changes: 74 additions & 0 deletions
74
...main/java/com/wayble/server/direction/external/tmap/dto/response/TMapParsingResponse.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,74 @@ | ||
| package com.wayble.server.direction.external.tmap.dto.response; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import lombok.Builder; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Builder | ||
| @Schema(description = "도보 최적 경로 T MAP API") | ||
| public record TMapParsingResponse( | ||
| @Schema(description = "총 거리", example = "909") | ||
| int totalDistance, | ||
|
|
||
| @Schema(description = "총 소요 시간", example = "676") | ||
| int totalTime, | ||
|
|
||
| @Schema( | ||
| description = "경로 단계", | ||
| example = "[{\"type\":\"point\",\"name\":\"강남역\",\"description\":\"보행자도로를 따라 32m 이동\"}]" | ||
| ) | ||
| List<Step> steps | ||
| ) { | ||
|
|
||
| @Schema(description = "경로 단계") | ||
| public record Step( | ||
| @Schema(description = "단계 타입 (point - 지점, line - 도로)", example = "point") | ||
| String type, | ||
|
|
||
| @Schema(description = "지점 또는 도로명", example = "강남역") | ||
| String name, | ||
|
|
||
| @Schema( | ||
| description = "설명", | ||
| example = "강남역에서 좌측 횡단보도를 건넌 후 보행자도로를 따라 32m 이동" | ||
| ) | ||
| String description, | ||
|
|
||
| @Schema( | ||
| description = "해당 포인트 좌표 (type - point)", | ||
| example = "{\"longitude\":127.0241571,\"latitude\":37.5037355}" | ||
| ) | ||
| Coordinate coordinate, | ||
|
|
||
| @Schema( | ||
| description = "좌표 리스트 (type - line)", | ||
| example = "[{\"longitude\":127.0241571,\"latitude\":37.5037355},{\"longitude\":127.0315678,\"latitude\":37.5067709}]" | ||
| ) | ||
| List<Coordinate> coordinates, | ||
|
|
||
| @Schema(description = "턴 타입", example = "212") | ||
| Integer turnType, | ||
|
|
||
| @Schema( | ||
| description = "포인트 타입 (SP - 출발, EP - 도착, GP - 경유지)", | ||
| example = "SP" | ||
| ) | ||
| String pointType, | ||
|
|
||
| @Schema(description = "해당 구간 거리", example = "32") | ||
| Integer distance, | ||
|
|
||
| @Schema(description = "해당 구간 소요 시간", example = "21") | ||
| Integer time | ||
| ) {} | ||
|
zyovn marked this conversation as resolved.
|
||
|
|
||
| @Schema(description = "좌표") | ||
| public record Coordinate( | ||
| @Schema(description = "경도", example = "127.02415714643489") | ||
| double longitude, | ||
|
|
||
| @Schema(description = "위도", example = "37.503735591581") | ||
| double latitude | ||
| ) {} | ||
| } | ||
43 changes: 43 additions & 0 deletions
43
src/main/java/com/wayble/server/direction/external/tmap/dto/response/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,43 @@ | ||
| package com.wayble.server.direction.external.tmap.dto.response; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public record TMapResponse( | ||
| String type, | ||
| List<Feature> features | ||
| ) { | ||
|
zyovn marked this conversation as resolved.
|
||
|
|
||
| public record Feature( | ||
| String type, | ||
| Geometry geometry, | ||
| Properties properties | ||
| ) {} | ||
|
|
||
| public record Geometry( | ||
| String type, | ||
| List<Object> coordinates | ||
| ) {} | ||
|
|
||
| public record Properties( | ||
| Integer totalDistance, | ||
| Integer totalTime, | ||
| Integer index, | ||
| Integer pointIndex, | ||
| String name, | ||
| String description, | ||
| String direction, | ||
| String nearPoiName, | ||
| String nearPoiX, | ||
| String nearPoiY, | ||
| String intersectionName, | ||
| String facilityType, | ||
| String facilityName, | ||
| Integer turnType, | ||
| String pointType, | ||
| Integer distance, | ||
| Integer time, | ||
| Integer roadType, | ||
| Integer categoryRoadType, | ||
| Integer lineIndex | ||
| ) {} | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.