-
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
Conversation
Walkthrough이 변경사항은 TMap API와 연동하여 도보 최적 경로를 제공하는 새로운 워킹(도보) 경로 API 전체 레이어(컨트롤러, 서비스, 클라이언트, 매퍼, DTO, 설정 등)를 프로젝트에 추가합니다. 또한 WebFlux 의존성 및 외부 설정 바인딩을 위한 구성을 포함합니다. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant WalkingController
participant WalkingService
participant TMapClient
participant TMap (External)
participant TMapMapper
Client->>WalkingController: GET /api/v1/directions/walking (파라미터 포함)
WalkingController->>WalkingService: callTMapApi(TMapRequest)
WalkingService->>TMapClient: response(TMapRequest)
TMapClient->>TMap: POST /pedestrian route API (TMapRequest, appKey)
TMap-->>TMapClient: TMapResponse
TMapClient-->>WalkingService: TMapResponse
WalkingService->>TMapMapper: parseResponse(TMapResponse)
TMapMapper-->>WalkingService: TMapParsingResponse
WalkingService-->>WalkingController: TMapParsingResponse
WalkingController-->>Client: CommonResponse<TMapParsingResponse>
Possibly related issues
Suggested reviewers
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 10
🧹 Nitpick comments (5)
src/main/java/com/wayble/server/common/config/WebClientConfig.java (1)
17-20: 기본 WebClient Bean의 명명 개선 필요현재
webClient라는 일반적인 이름은 다른 WebClient Bean들과 충돌할 가능성이 있습니다. 더 구체적인 이름을 사용하는 것을 고려해보세요.-public WebClient webClient() { +public WebClient defaultWebClient() {src/main/java/com/wayble/server/direction/controller/WalkingController.java (1)
21-33: 입력 검증 추가 고려사항컨트롤러 구현이 깔끔하고 좋은 패턴을 따르고 있습니다. 다만 입력 검증을 추가하면 더욱 견고해질 것입니다.
입력 검증 추가 고려사항:
public CommonResponse<TMapParsingResponse> callTMapApi( - @RequestParam double startX, - @RequestParam double startY, - @RequestParam double endX, - @RequestParam double endY, - @RequestParam String startName, - @RequestParam String endName + @RequestParam @Valid @DecimalMin("-180") @DecimalMax("180") double startX, + @RequestParam @Valid @DecimalMin("-90") @DecimalMax("90") double startY, + @RequestParam @Valid @DecimalMin("-180") @DecimalMax("180") double endX, + @RequestParam @Valid @DecimalMin("-90") @DecimalMax("90") double endY, + @RequestParam @NotBlank String startName, + @RequestParam @NotBlank String endName ) {src/main/java/com/wayble/server/direction/external/tmap/dto/response/TMapParsingResponse.java (2)
8-16: (선택) 총 거리·시간은 long 으로 두는 편이 안전합니다
도보 API라도 API 스펙상totalDistance,totalTime의 최대값이 명시되어 있지 않다면int(약 21억) 을 초과할 가능성을 배제할 수 없습니다.
long으로 확장해 두면 설계 단계에서 다시 손볼 일이 줄어듭니다.
17-23: NULL 필드 제외 설정이 빠져 있습니다
steps외 다수 필드가 상황에 따라null로 반환될 수 있는데, 최상위 record 에@JsonInclude(JsonInclude.Include.NON_NULL)이 없으면 모든null필드가 그대로 노출됩니다.
API 응답 크기를 줄이고 클라이언트 파싱 오류를 예방하려면 다음과 같이 추가를 권장합니다.+import com.fasterxml.jackson.annotation.JsonInclude; ... @Builder +@JsonInclude(JsonInclude.Include.NON_NULL) @Schema(description = "도보 최적 경로 T MAP API") public record TMapParsingResponse(src/main/java/com/wayble/server/direction/external/tmap/dto/response/TMapResponse.java (1)
16-19: Geometry.coordinates 를List<Object>로 두면 타입 안정성이 크게 떨어집니다
실제 응답은[lon, lat]또는[[lon, lat], ...]형태의 숫자 배열이므로
List<List<Double>>또는List<Double>를 다루는 커스텀 DTO(예:CoordinatePath) 로 파싱한 뒤,
후속 매핑 단계에서 도메인 객체로 변환하는 쪽이 타입 에러를 줄이고 IDE 지원을 극대화할 수 있습니다.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
build.gradle(1 hunks)src/main/java/com/wayble/server/ServerApplication.java(2 hunks)src/main/java/com/wayble/server/common/config/WebClientConfig.java(1 hunks)src/main/java/com/wayble/server/direction/controller/WalkingController.java(1 hunks)src/main/java/com/wayble/server/direction/controller/swagger/WalkingSwagger.java(1 hunks)src/main/java/com/wayble/server/direction/external/tmap/TMapClient.java(1 hunks)src/main/java/com/wayble/server/direction/external/tmap/TMapProperties.java(1 hunks)src/main/java/com/wayble/server/direction/external/tmap/dto/request/TMapRequest.java(1 hunks)src/main/java/com/wayble/server/direction/external/tmap/dto/response/TMapParsingResponse.java(1 hunks)src/main/java/com/wayble/server/direction/external/tmap/dto/response/TMapResponse.java(1 hunks)src/main/java/com/wayble/server/direction/external/tmap/mapper/TMapMapper.java(1 hunks)src/main/java/com/wayble/server/direction/service/WalkingService.java(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/main/java/com/wayble/server/direction/external/tmap/dto/request/TMapRequest.java (1)
src/main/java/com/wayble/server/common/response/CommonResponse.java (1)
Builder(8-42)
src/main/java/com/wayble/server/direction/external/tmap/dto/response/TMapParsingResponse.java (1)
src/main/java/com/wayble/server/common/response/CommonResponse.java (1)
Builder(8-42)
🔇 Additional comments (3)
build.gradle (1)
54-55: WebFlux 의존성 추가가 적절합니다.TMap API 호출을 위한 WebClient 사용을 위해 spring-boot-starter-webflux 의존성이 추가되었습니다. 이는 RestTemplate보다 권장되는 현대적인 HTTP 클라이언트 접근법입니다.
src/main/java/com/wayble/server/ServerApplication.java (1)
3-3: TMap 설정 속성 바인딩이 올바르게 구성되었습니다.@EnableConfigurationProperties(TMapProperties.class) 어노테이션을 통해 TMap 설정 속성 바인딩이 적절히 활성화되었습니다. Spring Boot의 표준 패턴을 잘 따르고 있습니다.
Also applies to: 7-7, 16-16
src/main/java/com/wayble/server/direction/controller/swagger/WalkingSwagger.java (1)
11-31: 잘 구성된 Swagger 인터페이스API 문서화가 잘 되어 있고, 한국어 설명이 명확합니다. 매개변수 구조도 직관적으로 설계되었습니다.
src/main/java/com/wayble/server/direction/external/tmap/dto/request/TMapRequest.java
Show resolved
Hide resolved
src/main/java/com/wayble/server/direction/external/tmap/dto/response/TMapParsingResponse.java
Show resolved
Hide resolved
src/main/java/com/wayble/server/direction/external/tmap/dto/response/TMapResponse.java
Show resolved
Hide resolved
src/main/java/com/wayble/server/direction/external/tmap/mapper/TMapMapper.java
Show resolved
Hide resolved
src/main/java/com/wayble/server/direction/external/tmap/mapper/TMapMapper.java
Outdated
Show resolved
Hide resolved
src/main/java/com/wayble/server/direction/external/tmap/TMapProperties.java
Show resolved
Hide resolved
| private final TMapMapper tMapMapper; | ||
|
|
||
| public TMapParsingResponse callTMapApi(TMapRequest request) { | ||
| TMapResponse response = tMapClient.response(request); |
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.
💡 Verification agent
🧩 Analysis chain
WebClient의 동기적 사용 방식을 확인하세요.
TMapClient.response() 메서드가 WebClient를 사용하면서 동기적으로 구현되었는지 확인이 필요합니다. WebClient는 기본적으로 비동기이므로 block() 호출 시 스레드 블로킹 이슈가 발생할 수 있습니다.
다음 스크립트로 TMapClient 구현을 확인해보겠습니다:
🏁 Script executed:
#!/bin/bash
# TMapClient의 구현 방식 확인
ast-grep --pattern 'class TMapClient {
$$$
response($$$) {
$$$
}
$$$
}'Length of output: 85
🏁 Script executed:
#!/bin/bash
# TMapClient.java 파일 위치 확인 및 WebClient 사용·block() 호출 여부 검사
file=$(find . -type f -name 'TMapClient.java' | head -n1)
echo "TMapClient 경로: $file"
if [ -z "$file" ]; then
echo "TMapClient.java 파일을 찾을 수 없습니다."
exit 1
fi
echo "--- WebClient 사용 위치 ---"
grep -n "WebClient" "$file" || echo "WebClient 키워드 없음"
echo "--- block() 호출 위치 ---"
grep -n "block(" "$file" || echo "block() 호출 없음"Length of output: 886
WebClient 블로킹 호출 확인 필요
TMapClient.response() 메서드에서 WebClient의 .block() 호출이 확인되어 스레드 풀 블로킹 이슈가 발생할 수 있습니다. 가능한 비동기/reactive 흐름을 유지하거나, 별도 스레드 풀(boundedElastic 등)에서 실행되도록 변경을 검토해주세요.
- 파일: src/main/java/com/wayble/server/direction/external/tmap/TMapClient.java
- 25행:
.block()호출
- 25행:
- 제안
bodyToMono(TMapResponse.class)를 반환하도록 수정 후 호출 지점에서 비동기 처리subscribeOn(Schedulers.boundedElastic())또는publishOn사용
🤖 Prompt for AI Agents
In src/main/java/com/wayble/server/direction/service/WalkingService.java at line
19, the call to tMapClient.response() is blocking due to the use of
WebClient.block() inside that method, which can cause thread pool blocking
issues. Refactor TMapClient.response() to return a Mono<TMapResponse> instead of
blocking, then update this calling code to handle the response asynchronously by
subscribing or chaining reactive operators. Additionally, ensure the reactive
flow uses subscribeOn(Schedulers.boundedElastic()) or publishOn to offload
blocking operations to a separate thread pool.
seung-in-Yoo
left a comment
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.
수고하셨습니다!! 결과는 포인트와 라인으로 구분돼서 포인트 지점에서 실제 존재하는 도로 라인을 따라 경로를 제공해주는건가요??
네넵 맞습니다! 해당 포인트부터 실제 존재하는 도로 라인의 위도 경도를 따라 경로를 제공해주는 형태입니다!! |
Tmap API는 사용 안해봤는데 프론트 구현되고나서 실제로 어떤식으로 나오는지 직접 화면으로 보고싶네요 ㅎㅎ 수고하셨습니다 정빈님~!! |
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.
Actionable comments posted: 0
♻️ Duplicate comments (1)
src/main/java/com/wayble/server/direction/service/WalkingService.java (1)
22-31: WebClient 블로킹 호출로 인한 성능 이슈를 검토하세요.이전 리뷰에서 지적된 WebClient의
.block()호출 문제가 여전히 존재할 수 있습니다. 현재tMapClient.response(request)호출이 내부적으로 블로킹 방식으로 구현되어 있어 스레드 풀 블로킹 이슈가 발생할 수 있습니다.비동기 처리를 위한 개선을 고려해보세요:
public Mono<TMapParsingResponse> callTMapApi(TMapRequest request) { return tMapClient.response(request) .doOnNext(response -> log.info("🎉 T MAP API 호출 성공")) .map(tMapMapper::parseResponse) .doOnError(e -> log.error("🚨 T MAP API 호출 실패: {}", e.getMessage())) .onErrorMap(e -> new ApplicationException(WalkingErrorCase.T_MAP_API_FAILED)); }
🧹 Nitpick comments (1)
src/main/java/com/wayble/server/direction/service/WalkingService.java (1)
25-25: 로깅 메시지에 더 많은 컨텍스트 정보를 추가하세요.성공 로그에 요청 파라미터나 응답 시간 등의 정보를 포함하면 디버깅과 모니터링에 도움이 됩니다.
log.info("🎉 T MAP API 호출 성공 - startX: {}, startY: {}, endX: {}, endY: {}", request.startX(), request.startY(), request.endX(), request.endY());
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/main/java/com/wayble/server/common/config/WebClientConfig.java(1 hunks)src/main/java/com/wayble/server/direction/exception/WalkingErrorCase.java(1 hunks)src/main/java/com/wayble/server/direction/external/tmap/mapper/TMapMapper.java(1 hunks)src/main/java/com/wayble/server/direction/service/WalkingService.java(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- src/main/java/com/wayble/server/direction/exception/WalkingErrorCase.java
🚧 Files skipped from review as they are similar to previous changes (2)
- src/main/java/com/wayble/server/common/config/WebClientConfig.java
- src/main/java/com/wayble/server/direction/external/tmap/mapper/TMapMapper.java
🔇 Additional comments (4)
src/main/java/com/wayble/server/direction/service/WalkingService.java (4)
1-12: 임포트 구조가 잘 정리되어 있습니다.패키지 구조와 임포트가 명확하고 논리적으로 구성되어 있어 코드의 가독성이 좋습니다.
14-17: Spring 어노테이션과 Lombok 설정이 적절합니다.
@Slf4j,@Service,@RequiredArgsConstructor어노테이션이 올바르게 적용되어 있어 Spring 컨테이너에서 빈으로 관리되고 로깅과 의존성 주입이 적절히 구성되었습니다.
19-20: 의존성 주입이 올바르게 구현되었습니다.
final키워드와@RequiredArgsConstructor를 사용하여 불변성을 보장하면서 깔끔한 의존성 주입을 구현했습니다.
28-29: 예외 처리가 개선되었습니다.이전 리뷰에서 요청된 오류 처리와 로깅이 적절히 구현되어 있고, 커스텀 예외를 통한 에러 케이스 처리도 잘 되어 있습니다.
✔️ 연관 이슈
📝 작업 내용
📸 스크린샷 (선택)
Summary by CodeRabbit
신규 기능
문서화