-
Notifications
You must be signed in to change notification settings - Fork 1
[feat] 웨이블존 추천, 검색 응답 필드에 장애 시설 정보 추가 #66
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웨이블존(장소) 추천 및 검색 기능의 응답에 장애 시설 정보가 포함되도록 전체 도메인, DTO, Elasticsearch 매핑, 테스트 코드가 확장되었습니다. 이에 따라 엔티티, DTO, 매핑, 컨트롤러, 테스트 등 여러 계층에서 facility 관련 필드와 변환 로직이 추가 및 반영되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Controller
participant Service
participant Repository
participant Elasticsearch
Client->>Controller: GET /explore/maps (with JWT)
Controller->>Service: findByCondition(...)
Service->>Repository: search(...)
Repository->>Elasticsearch: Query with facility fields
Elasticsearch-->>Repository: Zone documents with facility info
Repository-->>Service: List<WaybleZoneDocument>
Service-->>Controller: List<WaybleZoneSearchResponseDto> (facility 포함)
Controller-->>Client: 응답 (facility 정보 포함)
Estimated code review effort4 (~90분) Possibly related PRs
Suggested labels
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: 4
🧹 Nitpick comments (3)
src/main/java/com/wayble/server/common/entity/BaseEntity.java (1)
27-29: 방어적 프로그래밍을 위한 검증 로직 추가를 고려해보세요.현재 구현은 엔티티가 실제로 삭제된 상태인지 확인하지 않고 복원을 수행합니다. 더 안전한 구현을 위해 다음과 같은 개선을 고려해보세요:
public void restore() { + if (this.deletedAt == null) { + return; // 이미 복원된 상태이므로 아무것도 하지 않음 + } this.deletedAt = null; }또는 복원 가능 여부를 확인하는 헬퍼 메서드와 함께:
public boolean isDeleted() { return this.deletedAt != null; } public void restore() { if (!isDeleted()) { return; } this.deletedAt = null; }src/test/java/com/wayble/server/explore/WaybleZoneSearchApiIntegrationTest.java (1)
186-194: facility 검증 로직 중복여러 테스트 메서드에서 동일한 facility 검증 로직이 반복됩니다. 가독성과 유지보수성을 위해 별도의 메서드로 추출하는 것을 고려해보세요.
다음과 같은 헬퍼 메서드를 추가하여 중복을 제거할 수 있습니다:
private void assertFacilityNotNull(FacilityResponseDto facility) { assertThat(facility).isNotNull(); assertThat(facility.hasSlope()).isNotNull(); assertThat(facility.hasNoDoorStep()).isNotNull(); assertThat(facility.hasElevator()).isNotNull(); assertThat(facility.hasTableSeat()).isNotNull(); assertThat(facility.hasDisabledToilet()).isNotNull(); assertThat(facility.floorInfo()).isNotNull(); }src/test/java/com/wayble/server/explore/WaybleZoneRecommendApiIntegrationTest.java (1)
271-277: facility 검증 로직 중복
WaybleZoneSearchApiIntegrationTest와 동일하게 facility 검증 로직이 반복됩니다. 공통 테스트 유틸리티 클래스에 추출하면 두 테스트 클래스에서 재사용할 수 있습니다.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (16)
build.gradle(1 hunks)src/main/java/com/wayble/server/common/entity/BaseEntity.java(1 hunks)src/main/java/com/wayble/server/explore/controller/WaybleZoneSearchController.java(1 hunks)src/main/java/com/wayble/server/explore/dto/FacilityResponseDto.java(1 hunks)src/main/java/com/wayble/server/explore/dto/recommend/WaybleZoneRecommendResponseDto.java(3 hunks)src/main/java/com/wayble/server/explore/dto/search/WaybleZoneDocumentRegisterDto.java(2 hunks)src/main/java/com/wayble/server/explore/dto/search/WaybleZoneSearchResponseDto.java(3 hunks)src/main/java/com/wayble/server/explore/entity/EsWaybleZoneFacility.java(1 hunks)src/main/java/com/wayble/server/explore/entity/WaybleZoneDocument.java(3 hunks)src/main/java/com/wayble/server/explore/repository/recommend/WaybleZoneQueryRecommendRepository.java(1 hunks)src/main/java/com/wayble/server/explore/service/WaybleZoneRecommendService.java(3 hunks)src/main/java/com/wayble/server/user/repository/UserRepository.java(1 hunks)src/main/java/com/wayble/server/wayblezone/controller/WaybleZoneController.java(2 hunks)src/main/resources/elasticsearch/settings/wayble_zone_mappings.json(1 hunks)src/test/java/com/wayble/server/explore/WaybleZoneRecommendApiIntegrationTest.java(12 hunks)src/test/java/com/wayble/server/explore/WaybleZoneSearchApiIntegrationTest.java(11 hunks)
🧰 Additional context used
🧠 Learnings (3)
src/main/java/com/wayble/server/user/repository/UserRepository.java (1)
Learnt from: seung-in-Yoo
PR: #37
File: src/main/java/com/wayble/server/user/entity/User.java:61-62
Timestamp: 2025-07-13T15:08:59.318Z
Learning: Java에서 같은 패키지 내의 클래스들은 import 구문 없이 서로를 참조할 수 있다. com.wayble.server.user.entity 패키지 내의 클래스들은 명시적인 import 없이 사용 가능하다.
src/test/java/com/wayble/server/explore/WaybleZoneSearchApiIntegrationTest.java (1)
Learnt from: seung-in-Yoo
PR: #37
File: src/main/java/com/wayble/server/user/entity/User.java:61-62
Timestamp: 2025-07-13T15:08:59.318Z
Learning: Java에서 같은 패키지 내의 클래스들은 import 구문 없이 서로를 참조할 수 있다. com.wayble.server.user.entity 패키지 내의 클래스들은 명시적인 import 없이 사용 가능하다.
src/test/java/com/wayble/server/explore/WaybleZoneRecommendApiIntegrationTest.java (1)
Learnt from: seung-in-Yoo
PR: #37
File: src/main/java/com/wayble/server/user/entity/User.java:61-62
Timestamp: 2025-07-13T15:08:59.318Z
Learning: Java에서 같은 패키지 내의 클래스들은 import 구문 없이 서로를 참조할 수 있다. com.wayble.server.user.entity 패키지 내의 클래스들은 명시적인 import 없이 사용 가능하다.
🔇 Additional comments (18)
src/main/java/com/wayble/server/common/entity/BaseEntity.java (1)
27-29: soft deletion 복원 기능이 올바르게 구현되었습니다.
restore()메서드가 soft deletion 패턴에 맞게deletedAt필드를 null로 설정하여 엔티티를 복원하는 기능을 정확히 구현했습니다.src/main/java/com/wayble/server/explore/dto/search/WaybleZoneDocumentRegisterDto.java (1)
4-4: 시설 정보 필드 추가 잘 구현됨
WaybleZoneFacilityimport와facility필드 추가가 PR 목표에 맞게 적절히 구현되었습니다. 레코드 패턴을 잘 따르고 있습니다.Also applies to: 15-15
src/main/java/com/wayble/server/explore/controller/WaybleZoneSearchController.java (1)
24-24: 엔드포인트 경로 변경 승인지도 기반 검색 기능을
/maps로 분리하는 변경사항이 PR 목표와 일치합니다. 이는 향후 특정 지역(XX-동) 주변 상위 3개 매장 조회 기능과의 분리를 위한 적절한 변경입니다.참고: 이는 API 호출자에게 영향을 주는 breaking change입니다.
src/main/java/com/wayble/server/explore/repository/recommend/WaybleZoneQueryRecommendRepository.java (1)
142-142: 시설 정보 추가가 올바르게 구현되었습니다.FacilityResponseDto.from() 메서드를 사용하여 Elasticsearch 문서의 facility 정보를 응답 DTO로 변환하는 로직이 적절하게 구현되었습니다. 다른 필드들과 동일한 패턴을 따르고 있어 일관성이 유지됩니다.
src/main/resources/elasticsearch/settings/wayble_zone_mappings.json (1)
11-33: 장애 시설 정보 매핑이 적절하게 설계되었습니다.새로 추가된 facility 객체의 매핑 구조가 잘 설계되었습니다:
- 접근성 기능들(경사로, 문턱 없음, 엘리베이터 등)에 대해 boolean 타입을 사용한 것이 적절합니다
- floorInfo에 keyword 타입을 사용하여 정확한 매칭을 지원합니다
- 객체 구조로 관련 필드들을 논리적으로 그룹화했습니다
이 매핑은 장애 시설 정보에 대한 효율적인 검색과 필터링을 지원할 것입니다.
src/main/java/com/wayble/server/explore/dto/recommend/WaybleZoneRecommendResponseDto.java (3)
3-3: 적절한 import 추가입니다.FacilityResponseDto import가 올바르게 추가되었습니다.
27-27: 시설 정보 필드가 올바르게 추가되었습니다.FacilityResponseDto 타입의 facility 필드가 적절하게 추가되어 추천 응답에 장애 시설 정보를 포함할 수 있게 되었습니다.
48-48: from() 메서드에서 시설 정보 변환이 올바르게 구현되었습니다.FacilityResponseDto.from()을 사용하여 WaybleZoneDocument의 facility 정보를 적절하게 변환하고 있습니다. null 처리도 FacilityResponseDto.from() 메서드 내에서 처리되므로 안전합니다.
src/main/java/com/wayble/server/explore/dto/search/WaybleZoneSearchResponseDto.java (3)
3-3: 적절한 import 추가입니다.FacilityResponseDto import가 올바르게 추가되었습니다.
30-30: 시설 정보 필드가 올바르게 추가되었습니다.검색 응답 DTO에 FacilityResponseDto 타입의 facility 필드가 적절하게 추가되어 검색 결과에 장애 시설 정보를 포함할 수 있게 되었습니다.
43-43: from() 메서드에서 시설 정보 변환이 올바르게 구현되었습니다.WaybleZoneDocument의 facility 정보를 FacilityResponseDto.from()을 사용하여 적절하게 변환하고 있습니다. 추천 DTO와 동일한 패턴을 따라 일관성이 유지됩니다.
src/main/java/com/wayble/server/explore/dto/FacilityResponseDto.java (1)
1-29: 새로운 FacilityResponseDto가 잘 설계되었습니다.장애 시설 정보를 담는 DTO가 적절하게 구현되었습니다:
좋은 점:
- Record 사용으로 불변성과 간결성을 제공합니다
- Boolean wrapper 타입 사용으로 null 허용이 가능합니다
- 명확하고 일관된 네이밍 컨벤션을 따릅니다
- from() 메서드에서 null 체크를 적절히 수행합니다
- @builder 어노테이션으로 객체 생성의 가독성을 높입니다
구현 세부사항:
- 접근성 관련 boolean 필드들이 적절하게 정의되었습니다
- floorInfo는 층별 정보를 저장하는 용도로 String 타입이 적합합니다
- EsWaybleZoneFacility에서 변환하는 로직이 모든 필드를 올바르게 매핑합니다
src/main/java/com/wayble/server/explore/service/WaybleZoneRecommendService.java (1)
60-60: 적절한 캡슐화를 위한 좋은 변경입니다.내부에서만 사용되는 메서드들의 접근 제한자를
public에서private으로 변경한 것은 적절한 정보 은닉 원칙을 따르는 좋은 리팩토링입니다.Also applies to: 75-75, 91-91
src/main/java/com/wayble/server/explore/entity/WaybleZoneDocument.java (1)
48-48: TODO 주석 확인 필요이미
getMainImageUrl()을 사용하고 있는데 TODO 주석이 남아있습니다. 추가 작업이 필요한지 확인해주세요.src/main/java/com/wayble/server/explore/entity/EsWaybleZoneFacility.java (1)
1-34: 장애 시설 정보 엔티티가 잘 구현되었습니다.불변 객체 패턴과 null 안전성을 고려한 좋은 구현입니다. Builder 패턴의 접근 제한과 생성자 보호가 적절히 설정되어 있습니다.
src/test/java/com/wayble/server/explore/WaybleZoneSearchApiIntegrationTest.java (1)
84-128: 테스트 설정이 포괄적으로 잘 구현되었습니다.JWT 인증과 facility 데이터가 테스트에 적절히 통합되었으며, 테스트 데이터 생성 로직이 잘 구성되어 있습니다.
src/test/java/com/wayble/server/explore/WaybleZoneRecommendApiIntegrationTest.java (2)
78-78: 테스트 데이터 수 감소는 적절한 최적화입니다.1000개에서 100개로 줄인 것은 테스트 실행 시간을 단축하면서도 충분한 테스트 커버리지를 유지하는 좋은 결정입니다.
313-313: 파라미터명 변경 확인
count에서size로 파라미터명이 변경되었습니다. API 문서도 함께 업데이트되었는지 확인해주세요.
| implementation 'com.amazonaws:aws-java-sdk-core:1.12.698' | ||
| implementation 'com.amazonaws:aws-java-sdk-s3:1.12.698' |
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.
중복된 AWS SDK 의존성 제거 필요
AWS SDK 의존성이 두 번 선언되어 있습니다 (라인 38-39와 48-49). 중복 선언을 제거해야 합니다.
다음 diff를 적용하여 중복을 제거하세요:
- implementation 'com.amazonaws:aws-java-sdk-core:1.12.698'
- implementation 'com.amazonaws:aws-java-sdk-s3:1.12.698'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5'
runtimeOnly 'com.mysql:mysql-connector-j'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
//AWS S3
implementation 'com.amazonaws:aws-java-sdk-core:1.12.698'
implementation 'com.amazonaws:aws-java-sdk-s3:1.12.698'
Also applies to: 48-49
🤖 Prompt for AI Agents
In build.gradle around lines 38-39 and 48-49, the AWS SDK dependencies are
declared twice. Remove the duplicate implementation lines at 48-49 to keep only
one declaration of 'com.amazonaws:aws-java-sdk-core:1.12.698' and
'com.amazonaws:aws-java-sdk-s3:1.12.698' to avoid redundancy.
| .zoneName(waybleZone.getZoneName()) | ||
| .zoneType(waybleZone.getZoneType()) | ||
| .thumbnailImageUrl("thumbnail image url") // TODO: 이미지 경로 추가 | ||
| .thumbnailImageUrl(waybleZone.getMainImageUrl() != null ? waybleZone.getMainImageUrl() : null) // TODO: 이미지 경로 추가 |
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.
🛠️ Refactor suggestion
불필요한 삼항 연산자 사용
현재 로직은 waybleZone.getMainImageUrl() != null ? waybleZone.getMainImageUrl() : null인데, 이는 단순히 waybleZone.getMainImageUrl()과 동일합니다.
다음과 같이 수정하세요:
-.thumbnailImageUrl(waybleZone.getMainImageUrl() != null ? waybleZone.getMainImageUrl() : null) // TODO: 이미지 경로 추가
+.thumbnailImageUrl(waybleZone.getMainImageUrl()) // TODO: 이미지 경로 추가
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| .thumbnailImageUrl(waybleZone.getMainImageUrl() != null ? waybleZone.getMainImageUrl() : null) // TODO: 이미지 경로 추가 | |
| .thumbnailImageUrl(waybleZone.getMainImageUrl()) // TODO: 이미지 경로 추가 |
🤖 Prompt for AI Agents
In src/main/java/com/wayble/server/explore/entity/WaybleZoneDocument.java at
line 48, the ternary operator checking if waybleZone.getMainImageUrl() is null
and returning it or null is redundant. Replace the entire expression with just
waybleZone.getMainImageUrl() to simplify the code without changing its behavior.
| import org.springframework.data.jpa.repository.Query; | ||
| import org.springframework.data.repository.query.Param; |
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
❓ Verification inconclusive
사용되지 않는 import 구문일 가능성 확인 필요
@Query와 @Param annotation을 위한 import가 추가되었지만, 파일에서 실제 커스텀 쿼리 메서드는 보이지 않습니다. 만약 이 import들이 사용되지 않는다면 제거하는 것이 좋습니다.
다음 스크립트로 해당 annotation들이 실제로 사용되는지 확인해주세요:
🏁 Script executed:
#!/bin/bash
# UserRepository에서 @Query와 @Param이 실제로 사용되는지 확인
rg -A 10 "@Query|@Param" src/main/java/com/wayble/server/user/repository/UserRepository.java
Length of output: 94
사용되지 않는 import 제거 필요
UserRepository.java에서 @Query와 @Param 애노테이션이 실제로 사용되지 않으므로 해당 import 구문을 제거해주세요.
수정 위치:
- src/main/java/com/wayble/server/user/repository/UserRepository.java
제거할 라인: 6–7
제안된 diff:
- import org.springframework.data.jpa.repository.Query;
- import org.springframework.data.repository.query.Param;
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| import org.springframework.data.jpa.repository.Query; | |
| import org.springframework.data.repository.query.Param; |
🤖 Prompt for AI Agents
In src/main/java/com/wayble/server/user/repository/UserRepository.java at lines
6 to 7, the imports for org.springframework.data.jpa.repository.Query and
org.springframework.data.repository.query.Param are unused. Remove these two
import statements to clean up the code and avoid unnecessary imports.
| Long userId = (Long) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); | ||
| waybleZoneVisitLogService.saveVisitLog(userId, waybleZoneId); |
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.
JWT에서 사용자 ID 추출 시 안전성 검증 필요
SecurityContextHolder에서 principal을 Long으로 직접 캐스팅하는 것은 ClassCastException을 유발할 수 있습니다. JWT 토큰 검증과 타입 안전성을 보장하는 로직이 필요합니다.
다음과 같이 안전한 구현으로 수정하는 것을 권장합니다:
- Long userId = (Long) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
- waybleZoneVisitLogService.saveVisitLog(userId, waybleZoneId);
+ Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+ if (authentication != null && authentication.getPrincipal() instanceof Long userId) {
+ waybleZoneVisitLogService.saveVisitLog(userId, waybleZoneId);
+ } else {
+ // 인증되지 않은 사용자의 경우 로그 처리 방식 결정 필요
+ waybleZoneVisitLogService.saveVisitLog(null, waybleZoneId);
+ }
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| Long userId = (Long) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); | |
| waybleZoneVisitLogService.saveVisitLog(userId, waybleZoneId); | |
| Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); | |
| if (authentication != null && authentication.getPrincipal() instanceof Long userId) { | |
| waybleZoneVisitLogService.saveVisitLog(userId, waybleZoneId); | |
| } else { | |
| // 인증되지 않은 사용자의 경우 로그 처리 방식 결정 필요 | |
| waybleZoneVisitLogService.saveVisitLog(null, waybleZoneId); | |
| } |
🤖 Prompt for AI Agents
In
src/main/java/com/wayble/server/wayblezone/controller/WaybleZoneController.java
at lines 61-62, directly casting the principal from SecurityContextHolder to
Long risks ClassCastException and lacks JWT validation. Modify the code to
safely extract the user ID by first verifying the authentication object and its
principal type, then retrieving the user ID in a type-safe manner, ensuring JWT
token validation is performed before using the ID.
✔️ 연관 이슈
📝 작업 내용
웨이블존 추천, 검색 응답 필드에 장애 시설 정보를 추가했습니다.
JWT 추가로 테스트 코드 api 요청 과정에서 문제가 발생해, 해당 오류를 해결했습니다
지도 기반 검색 기능의 엔드포인트를 /search/maps로 변경했습니다.
ci/cd test하다가 pr 꼬여서 다시 올립니당 ㅎ
Summary by CodeRabbit
신규 기능
버그 수정
테스트
문서화