-
Notifications
You must be signed in to change notification settings - Fork 1
[chore] Elastic Search 관련 기능 디렉토리 구조 변경, 경고 문구 해결 #40
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
|
""" WalkthroughElasticsearch 관련 코드가 기존 Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant WaybleZoneRecommendController
participant WaybleZoneRecommendService
participant UserRepository
participant WaybleZoneQueryRecommendRepository
User->>WaybleZoneRecommendController: GET /api/v1/wayble-zones/recommend/{userId}
WaybleZoneRecommendController->>WaybleZoneRecommendService: getWaybleZonePersonalRecommend(userId)
WaybleZoneRecommendService->>UserRepository: findById(userId)
alt User exists
WaybleZoneRecommendService->>WaybleZoneQueryRecommendRepository: searchPersonalWaybleZone(user)
WaybleZoneQueryRecommendRepository-->>WaybleZoneRecommendService: WaybleZoneRecommendResponseDto
WaybleZoneRecommendService-->>WaybleZoneRecommendController: WaybleZoneRecommendResponseDto
WaybleZoneRecommendController-->>User: CommonResponse(success)
else User not found
WaybleZoneRecommendService-->>WaybleZoneRecommendController: throw ApplicationException(INVALID_USER)
WaybleZoneRecommendController-->>User: Error Response
end
Possibly related PRs
Suggested reviewers
Poem
""" 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ 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
🔭 Outside diff range comments (1)
src/main/java/com/wayble/server/explore/dto/search/WaybleZoneSearchResponseDto.java (1)
38-39: 잠재적 NullPointerException
waybleZoneDocument.getAddress().getLocation()호출 시address또는location이 null 이면 NPE가 발생합니다. 방어 코드 추가를 권장합니다.- .latitude(waybleZoneDocument.getAddress().getLocation().getLat()) - .longitude(waybleZoneDocument.getAddress().getLocation().getLon()) + .latitude( + waybleZoneDocument.getAddress() != null && waybleZoneDocument.getAddress().getLocation() != null + ? waybleZoneDocument.getAddress().getLocation().getLat() + : null) + .longitude( + waybleZoneDocument.getAddress() != null && waybleZoneDocument.getAddress().getLocation() != null + ? waybleZoneDocument.getAddress().getLocation().getLon() + : null)
🧹 Nitpick comments (9)
src/main/java/com/wayble/server/explore/dto/search/WaybleZoneDocumentRegisterDto.java (1)
11-12: 필드 명명 규칙 일관성 확보 필요
waybleZoneType필드명은 다른 DTO(WaybleZoneSearchResponseDto의zoneType)와 달라 가독성을 저하시킵니다. 동일 도메인 개념은 통일된 네이밍을 유지해 주세요.- WaybleZoneType waybleZoneType, + WaybleZoneType zoneType,src/main/java/com/wayble/server/explore/exception/SearchErrorCase.java (1)
11-12: HTTP 상태 코드 재검토 권장
SEARCH_EXCEPTION이 400(Bad Request)으로 매핑되어 있습니다. 내부 처리 중 발생한 예외라면 500 계열이 더 적절할 수 있으니 팀 규칙에 따라 재검토 바랍니다.src/main/java/com/wayble/server/explore/entity/WaybleZoneDocument.java (1)
15-15: indexName 상수화 고려문자열
"wayble_zone"을 클래스 내 상수로 추출하면 인덱스명 변경 시 실수를 줄일 수 있습니다.src/main/java/com/wayble/server/explore/dto/recommend/WaybleZoneRecommendResponseDto.java (1)
3-7: 추천 응답 스키마 확장 검토추천 API 결과가
username하나만 제공되면 클라이언트에서 영역 정보를 얻기 위해 추가 호출이 필요합니다. 최소한 zone ID, 이름 정도를 포함하도록 확장 여부를 논의해 보시길 권장합니다.src/main/java/com/wayble/server/explore/entity/AgeGroup.java (1)
17-42: 경계값 및 음수‧미래 생년월일 처리 고려
Period.between(birthDate, LocalDate.now()).getYears()결과가 음수(미래 날짜)거나 0~9세인 경우 모두OTHERS로 분류됩니다.
비즈니스 요구사항에 따라
- 0~9세를 별도 그룹으로 둘지,
- 미래 생년월일 입력 시 예외를 던질지
검토가 필요합니다.
현행 로직이 의도된 것이라면 주석으로 명시해 두는 편이 유지보수에 도움이 됩니다.src/main/java/com/wayble/server/explore/repository/WaybleZoneDocumentRepository.java (1)
9-12: 중복 메서드 정의 제거 권장
ElasticsearchRepository가 이미findById,findAll을 제공하므로 재정의 없이도 동일 시그니처를 사용할 수 있습니다.
불필요한 선언을 제거하면 코드가 간결해지고 인터페이스 변경 시 리스크를 줄일 수 있습니다.- Optional<WaybleZoneDocument> findById(Long waybleZoneId); - List<WaybleZoneDocument> findAll();src/test/java/com/wayble/server/search/WaybleZoneSearchApiIntegrationTest.java (1)
65-65: 테스트 데이터 규모 증가를 확인하세요.테스트 데이터가 1000개에서 5000개로 증가했습니다. 이는 테스트 실행 시간과 리소스 사용량을 증가시킬 수 있습니다.
테스트 환경에서 성능 문제가 발생할 경우 데이터 규모를 줄이거나 테스트를 분리하는 것을 고려해보세요.
src/main/java/com/wayble/server/explore/controller/WaybleZoneRecommendController.java (1)
21-26: 경로 변수 유효성 검사 추가 권장현재
@PathVariable("userId")매개변수에 대한 유효성 검사가 없습니다. 음수나 0과 같은 유효하지 않은 값이 전달될 수 있습니다.다음과 같이 유효성 검사를 추가하는 것을 고려해보세요:
@GetMapping("/{userId}") public CommonResponse<WaybleZoneRecommendResponseDto> getWaybleZonePersonalRecommend( - @PathVariable("userId") Long userId) { + @PathVariable("userId") @Min(1) Long userId) {
@Min(1)어노테이션을 사용하려면javax.validation.constraints.Min임포트가 필요합니다.src/main/java/com/wayble/server/explore/service/WaybleZoneRecommendService.java (1)
16-16: 리포지토리 필드명 일관성 검토필드명이
waybleZoneRecommendRepository인데 실제 타입은WaybleZoneQueryRecommendRepository입니다. 의미 전달을 위해waybleZoneQueryRecommendRepository로 명명하는 것이 더 명확할 수 있습니다.필드명을 다음과 같이 변경하는 것을 고려해보세요:
-private final WaybleZoneQueryRecommendRepository waybleZoneRecommendRepository; +private final WaybleZoneQueryRecommendRepository waybleZoneQueryRecommendRepository;그리고 사용 부분도 함께 변경:
-return waybleZoneRecommendRepository.searchPersonalWaybleZone(user); +return waybleZoneQueryRecommendRepository.searchPersonalWaybleZone(user);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (27)
docker-els.yml(1 hunks)src/main/java/com/wayble/server/ServerApplication.java(1 hunks)src/main/java/com/wayble/server/common/config/ElasticsearchConfig.java(0 hunks)src/main/java/com/wayble/server/common/config/SwaggerConfig.java(1 hunks)src/main/java/com/wayble/server/explore/controller/WaybleZoneRecommendController.java(1 hunks)src/main/java/com/wayble/server/explore/controller/WaybleZoneSearchController.java(2 hunks)src/main/java/com/wayble/server/explore/dto/recommend/WaybleZoneRecommendResponseDto.java(1 hunks)src/main/java/com/wayble/server/explore/dto/search/SearchSliceDto.java(1 hunks)src/main/java/com/wayble/server/explore/dto/search/WaybleZoneDocumentRegisterDto.java(1 hunks)src/main/java/com/wayble/server/explore/dto/search/WaybleZoneSearchConditionDto.java(1 hunks)src/main/java/com/wayble/server/explore/dto/search/WaybleZoneSearchResponseDto.java(1 hunks)src/main/java/com/wayble/server/explore/entity/AgeGroup.java(1 hunks)src/main/java/com/wayble/server/explore/entity/EsAddress.java(1 hunks)src/main/java/com/wayble/server/explore/entity/WaybleZoneDocument.java(1 hunks)src/main/java/com/wayble/server/explore/entity/WaybleZoneVisitLogDocument.java(1 hunks)src/main/java/com/wayble/server/explore/exception/RecommendErrorCase.java(1 hunks)src/main/java/com/wayble/server/explore/exception/SearchErrorCase.java(1 hunks)src/main/java/com/wayble/server/explore/repository/WaybleZoneDocumentRepository.java(1 hunks)src/main/java/com/wayble/server/explore/repository/WaybleZoneVisitLogDocumentRepository.java(1 hunks)src/main/java/com/wayble/server/explore/repository/recommend/WaybleZoneQueryRecommendRepository.java(1 hunks)src/main/java/com/wayble/server/explore/repository/search/WaybleZoneQuerySearchRepository.java(2 hunks)src/main/java/com/wayble/server/explore/service/SearchService.java(1 hunks)src/main/java/com/wayble/server/explore/service/WaybleZoneRecommendService.java(1 hunks)src/main/java/com/wayble/server/search/repository/WaybleZoneSearchRepository.java(0 hunks)src/main/java/com/wayble/server/search/repository/WaybleZoneSearchRepositoryCustom.java(0 hunks)src/main/java/com/wayble/server/search/service/SearchService.java(0 hunks)src/test/java/com/wayble/server/search/WaybleZoneSearchApiIntegrationTest.java(14 hunks)
💤 Files with no reviewable changes (4)
- src/main/java/com/wayble/server/common/config/ElasticsearchConfig.java
- src/main/java/com/wayble/server/search/repository/WaybleZoneSearchRepositoryCustom.java
- src/main/java/com/wayble/server/search/repository/WaybleZoneSearchRepository.java
- src/main/java/com/wayble/server/search/service/SearchService.java
🧰 Additional context used
🧠 Learnings (4)
src/main/java/com/wayble/server/explore/dto/search/SearchSliceDto.java (1)
Learnt from: seung-in-Yoo
PR: Wayble-Project/wayble-spring#37
File: src/main/java/com/wayble/server/user/entity/User.java:61-62
Timestamp: 2025-07-13T15:08:59.288Z
Learning: Java에서 같은 패키지 내의 클래스들은 import 구문 없이 서로를 참조할 수 있다. com.wayble.server.user.entity 패키지 내의 클래스들은 명시적인 import 없이 사용 가능하다.
src/main/java/com/wayble/server/explore/entity/EsAddress.java (1)
Learnt from: seung-in-Yoo
PR: Wayble-Project/wayble-spring#37
File: src/main/java/com/wayble/server/user/entity/User.java:61-62
Timestamp: 2025-07-13T15:08:59.288Z
Learning: Java에서 같은 패키지 내의 클래스들은 import 구문 없이 서로를 참조할 수 있다. com.wayble.server.user.entity 패키지 내의 클래스들은 명시적인 import 없이 사용 가능하다.
src/main/java/com/wayble/server/explore/entity/WaybleZoneDocument.java (1)
Learnt from: seung-in-Yoo
PR: Wayble-Project/wayble-spring#37
File: src/main/java/com/wayble/server/user/entity/User.java:61-62
Timestamp: 2025-07-13T15:08:59.288Z
Learning: Java에서 같은 패키지 내의 클래스들은 import 구문 없이 서로를 참조할 수 있다. com.wayble.server.user.entity 패키지 내의 클래스들은 명시적인 import 없이 사용 가능하다.
src/main/java/com/wayble/server/explore/dto/search/WaybleZoneSearchResponseDto.java (1)
Learnt from: seung-in-Yoo
PR: Wayble-Project/wayble-spring#37
File: src/main/java/com/wayble/server/user/entity/User.java:61-62
Timestamp: 2025-07-13T15:08:59.288Z
Learning: Java에서 같은 패키지 내의 클래스들은 import 구문 없이 서로를 참조할 수 있다. com.wayble.server.user.entity 패키지 내의 클래스들은 명시적인 import 없이 사용 가능하다.
🧬 Code Graph Analysis (4)
src/main/java/com/wayble/server/explore/repository/recommend/WaybleZoneQueryRecommendRepository.java (1)
src/main/java/com/wayble/server/explore/repository/search/WaybleZoneQuerySearchRepository.java (1)
Repository(23-123)
src/main/java/com/wayble/server/explore/service/WaybleZoneRecommendService.java (1)
src/main/java/com/wayble/server/explore/service/SearchService.java (1)
Service(17-48)
src/main/java/com/wayble/server/explore/controller/WaybleZoneRecommendController.java (1)
src/main/java/com/wayble/server/explore/controller/WaybleZoneSearchController.java (1)
RestController(16-43)
src/main/java/com/wayble/server/explore/service/SearchService.java (1)
src/main/java/com/wayble/server/explore/service/WaybleZoneRecommendService.java (1)
Service(12-26)
🔇 Additional comments (26)
docker-els.yml (1)
24-25:external: false는 기본값이라 중복 설정입니다. 네트워크 공유 여부를 재확인해 주세요.
external: false를 명시하면 compose 간 네트워크 재사용(예: 애플리케이션 쪽docker-compose.yml에서 같은 이름의 네트워크를external: true로 선언) 시 충돌이 발생할 수 있습니다. 실제로 다른 compose 파일에서es-network를 외부 네트워크로 참조하고 있지는 않은지 점검해 주세요. 필요 없다면external키는 제거해도 무방합니다.
attachable: true설정 자체는 컨테이너 간 동적 연결이 필요한 경우 유용하니 유지해도 좋습니다.src/main/java/com/wayble/server/common/config/SwaggerConfig.java (1)
1-1: 패키지 이동 문제 없음 – 빈 스캔 범위 내에 유지됩니다.루트 패키지가
com.wayble.server이므로common.config하위로 옮겨도 Spring Component-scan 대상에 포함됩니다. 별도 설정 변경 없으면 정상 동작합니다.
변경된 FQN을 참조하는 코드가 없는지만 한 번 grep 으로 확인해 두면 좋겠습니다.src/main/java/com/wayble/server/explore/entity/EsAddress.java (1)
1-1: 패키지 이동에 따른 import 갱신 여부 확인 필요도메인 코드에서
com.wayble.server.search.entity.EsAddress를 직접 import 하던 부분이 남아 있으면 컴파일 에러가 발생합니다. 전역 검색으로 사용처가 모두explore.entity로 변경됐는지 확인해 주세요.src/main/java/com/wayble/server/explore/dto/search/SearchSliceDto.java (1)
1-1: DTO 패키지 변경 확인 완료패키지 이동만 이뤄졌으며 제네릭 레코드 구조는 그대로입니다. 사용처 import 업데이트만 확인해 주세요.
src/main/java/com/wayble/server/explore/dto/search/WaybleZoneSearchConditionDto.java (1)
1-1: 패키지 이동만 수행 – 제약 애너테이션 유지 확인기존 유효성 제약 애너테이션이 그대로 유지되어 로직 영향은 없습니다. 마찬가지로 import 경로만 일관성 있게 업데이트됐는지 점검 부탁드립니다.
src/main/java/com/wayble/server/explore/entity/WaybleZoneDocument.java (1)
44-45: TODO 항목 처리 및 기본 이미지 경로 상수화
"thumbnail image url"하드코딩은 추후 잊혀질 위험이 있습니다. 설정 값 또는 상수로 분리하고 TODO 제거해 주세요.src/main/java/com/wayble/server/explore/exception/RecommendErrorCase.java (1)
7-16: 구현 일관성 확인 완료필드, 생성자, Lombok
@Getter적용이 올바르게 설정되어 있어ErrorCase규약을 충족합니다.
특이사항 없습니다.src/main/java/com/wayble/server/explore/repository/search/WaybleZoneQuerySearchRepository.java (3)
1-1: 패키지 구조 변경이 잘 적용되었습니다.search 패키지에서 explore 패키지로의 이동이 올바르게 처리되었습니다.
25-122: Elasticsearch 쿼리 구현이 올바릅니다.새로운 Elasticsearch 클라이언트 API를 사용한 쿼리 구현이 잘 되어 있습니다. 지역 검색, 텍스트 검색, 정렬 등의 로직이 올바르게 구현되었습니다.
35-35: 기본 검색 반경(50.0km) 변경이 코드와 테스트에 일관되게 적용됨 확인
- WaybleZoneQuerySearchRepository.java(35줄)에서 기본값이 50.0km로 설정되어 있습니다.
- WaybleZoneSearchApiIntegrationTest.java 에서도
RADIUS = 50.0을 사용해 모든 테스트가 50.0km 기준으로 동작합니다.- WaybleZoneSearchConditionDto의
radiusKm필드 사용 역시 일관되며, 100.0km 하드코딩은 더 이상 존재하지 않습니다.위 사항으로 기본 검색 반경 변경이 의도대로 일관성 있게 적용된 것을 확인했습니다.
src/main/java/com/wayble/server/explore/controller/WaybleZoneSearchController.java (3)
1-8: 패키지 구조 변경 및 임포트 업데이트가 올바릅니다.explore 패키지로의 이동과 관련 DTO, 서비스 임포트가 올바르게 업데이트되었습니다.
19-20: API 경로 개선이 잘 되었습니다.
/search에서/api/v1/wayble-zones/search로의 변경이 RESTful API 설계 원칙에 더 부합합니다. 버전 관리와 리소스 구조화가 잘 되어 있습니다.
20-20: 컨트롤러 클래스명 변경이 적절합니다.
SearchController에서WaybleZoneSearchController로의 변경이 클래스의 책임을 더 명확하게 나타냅니다.src/main/java/com/wayble/server/explore/entity/WaybleZoneVisitLogDocument.java (2)
28-35: 정적 팩토리 메서드 구현이 우수합니다.
fromEntity메서드를 통해 User 엔티티로부터 방문 로그 문서를 생성하는 로직이 잘 구현되어 있습니다. 빌더 패턴 사용과 AgeGroup 계산이 적절합니다.
14-14: Elasticsearch 문서 구성이 올바릅니다.인덱스 이름
wayble_zone_visit_log가 적절하며, 문서 구조가 잘 정의되어 있습니다.src/test/java/com/wayble/server/search/WaybleZoneSearchApiIntegrationTest.java (3)
7-10: 패키지 구조 변경이 테스트에서 올바르게 반영되었습니다.explore 패키지로의 이동이 임포트 문에서 올바르게 처리되었습니다.
46-48: 검색 반경과 API URL 업데이트가 일관적입니다.검색 반경이 50.0km로 변경되고 새로운 API 경로가 적용되어 repository 변경사항과 일치합니다.
20-20: UTF-8 인코딩 명시가 좋은 개선입니다.응답 문자열을 읽을 때 UTF-8 인코딩을 명시적으로 지정한 것이 한글 처리에 도움이 됩니다.
Also applies to: 125-125, 176-176, 229-229, 284-284
src/main/java/com/wayble/server/ServerApplication.java (3)
5-6: 필요한 임포트가 올바르게 추가되었습니다.Elasticsearch 리포지토리 구성을 위한 임포트가 적절하게 추가되었습니다.
9-11: Reactive Elasticsearch 자동 구성 제외가 적절합니다.ReactiveElasticsearchRepositoriesAutoConfiguration을 제외하여 Spring이 JPA와 Elasticsearch 리포지토리를 구분할 수 있도록 했습니다.
13-13: Elasticsearch 리포지토리 구성이 명확합니다.explore.repository 패키지에 대해 명시적으로 Elasticsearch 리포지토리를 활성화하여 PR 목표에서 언급된 경고 문제를 해결했습니다.
src/main/java/com/wayble/server/explore/service/WaybleZoneRecommendService.java (1)
20-25: 서비스 로직 구현이 적절함사용자 유효성 검사와 예외 처리가 적절하게 구현되어 있습니다.
UserRepository를 통한 사용자 조회 후ApplicationException을 던지는 패턴이 프로젝트의 다른 서비스와 일관성을 보입니다.src/main/java/com/wayble/server/explore/service/SearchService.java (4)
17-19: 서비스 구조가 적절함
@Service와@RequiredArgsConstructor를 사용한 의존성 주입 패턴이 Spring Boot 모범 사례에 따라 적절히 구현되었습니다.
29-32: 적절한 예외 처리 구현
Optional.orElseThrow()를 사용한 예외 처리가 적절하며, 커스텀 예외ApplicationException과SearchErrorCase.NO_SUCH_DOCUMENT를 사용하여 일관성 있는 에러 핸들링을 보여줍니다.
34-40: 엔티티와 DTO 변환 메서드 활용
WaybleZoneDocument.fromEntity()와WaybleZoneDocument.fromDto()정적 팩토리 메서드를 활용하여 깔끔한 변환 로직을 구현했습니다. 이는 좋은 설계 패턴입니다.
42-47: 검색 메서드 구현 확인검색 조건에 따른 페이지네이션 검색 메서드가 적절히 구현되었습니다.
Slice<T>를 사용하여 페이지네이션을 처리하는 것이 Spring Data의 모범 사례입니다.
src/main/java/com/wayble/server/explore/repository/WaybleZoneVisitLogDocumentRepository.java
Outdated
Show resolved
Hide resolved
| private final ElasticsearchOperations operations; | ||
|
|
||
| public WaybleZoneRecommendResponseDto searchPersonalWaybleZone(User user) { | ||
| return null; | ||
| } |
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.
미구현 메서드가 null을 반환하여 NPE 위험이 있습니다
searchPersonalWaybleZone가 항상 null을 반환하면 서비스·컨트롤러 계층에서 바로 NullPointerException이 발생합니다.
최소한 TODO 주석과 함께 UnsupportedOperationException을 던지거나, 빈 WaybleZoneRecommendResponseDto를 반환하도록 수정하세요.
- public WaybleZoneRecommendResponseDto searchPersonalWaybleZone(User user) {
- return null;
- }
+ public WaybleZoneRecommendResponseDto searchPersonalWaybleZone(User user) {
+ // TODO: Elasticsearch 쿼리 구현
+ throw new UnsupportedOperationException("검색 로직이 아직 구현되지 않았습니다.");
+ }📝 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.
| private final ElasticsearchOperations operations; | |
| public WaybleZoneRecommendResponseDto searchPersonalWaybleZone(User user) { | |
| return null; | |
| } | |
| private final ElasticsearchOperations operations; | |
| public WaybleZoneRecommendResponseDto searchPersonalWaybleZone(User user) { | |
| // TODO: Elasticsearch 쿼리 구현 | |
| throw new UnsupportedOperationException("검색 로직이 아직 구현되지 않았습니다."); | |
| } |
🤖 Prompt for AI Agents
In
src/main/java/com/wayble/server/explore/repository/recommend/WaybleZoneQueryRecommendRepository.java
around lines 13 to 17, the method searchPersonalWaybleZone currently returns
null, which risks causing NullPointerExceptions in higher layers. To fix this,
either throw an UnsupportedOperationException with a TODO comment indicating the
method is not yet implemented, or return an empty instance of
WaybleZoneRecommendResponseDto to avoid null returns.
|
|
||
| private Gender gender; | ||
|
|
||
| private AgeGroup ageGroup; |
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.
AgeGroup 임포트가 누락되었습니다.
AgeGroup 타입이 사용되고 있지만 임포트 문이 누락되었습니다.
다음 임포트를 추가하세요:
+import com.wayble.server.user.entity.AgeGroup;Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In
src/main/java/com/wayble/server/explore/entity/WaybleZoneVisitLogDocument.java
at line 26, the AgeGroup type is used but its import statement is missing. Add
the appropriate import statement for AgeGroup at the top of the file to resolve
the missing import issue.
src/main/java/com/wayble/server/explore/service/SearchService.java
Outdated
Show resolved
Hide resolved
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
🧹 Nitpick comments (2)
src/main/java/com/wayble/server/explore/service/WaybleZoneSearchService.java (2)
25-28: ID로 문서 조회 시 입력 검증을 추가하는 것을 고려해보세요.현재 구현은 기본적인 예외 처리를 포함하고 있지만, null 또는 음수 ID에 대한 사전 검증을 추가하면 더 안정적인 코드가 될 수 있습니다.
public WaybleZoneDocument getWaybleZoneDocumentById(Long id) { + if (id == null || id <= 0) { + throw new ApplicationException(SearchErrorCase.INVALID_DOCUMENT_ID); + } return waybleZoneDocumentRepository.findById(id) .orElseThrow(() -> new ApplicationException(SearchErrorCase.NO_SUCH_DOCUMENT)); }
38-43: 검색 메서드에서 입력 검증을 추가하는 것을 고려해보세요.현재 구현은 적절하지만, null 체크나 조건 검증을 추가하면 더 안정적인 서비스가 될 수 있습니다.
public Slice<WaybleZoneSearchResponseDto> searchWaybleZonesByCondition( WaybleZoneSearchConditionDto condition, Pageable pageable) { + if (condition == null) { + throw new ApplicationException(SearchErrorCase.INVALID_SEARCH_CONDITION); + } + if (pageable == null) { + throw new ApplicationException(SearchErrorCase.INVALID_PAGEABLE); + } return waybleZoneQuerySearchRepository.searchWaybleZonesByCondition(condition, pageable); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/main/java/com/wayble/server/explore/controller/WaybleZoneSearchController.java(4 hunks)src/main/java/com/wayble/server/explore/service/WaybleZoneSearchService.java(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/java/com/wayble/server/explore/controller/WaybleZoneSearchController.java
🔇 Additional comments (4)
src/main/java/com/wayble/server/explore/service/WaybleZoneSearchService.java (4)
1-16: 패키지 구조 및 import 문이 적절합니다.새로운
explore패키지 구조로의 리팩토링이 잘 반영되어 있고, 필요한 의존성들이 적절히 import되어 있습니다.
17-24: 서비스 클래스 구조가 Spring 모범 사례를 따르고 있습니다.
@Service어노테이션과@RequiredArgsConstructor를 사용한 생성자 주입 방식이 적절하게 구현되어 있습니다.
30-32: 엔티티에서 문서 저장 메서드가 간결하고 적절합니다.
WaybleZoneDocument.fromEntity()팩토리 메서드를 사용한 변환이 깔끔하게 구현되어 있습니다.
34-36: DTO에서 문서 저장 메서드가 간결하고 적절합니다.
WaybleZoneDocument.fromDto()팩토리 메서드를 사용한 변환이 깔끔하게 구현되어 있습니다.
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: 1
♻️ Duplicate comments (1)
src/main/java/com/wayble/server/explore/entity/WaybleZoneVisitLogDocument.java (1)
4-5: AgeGroup 임포트가 누락되었습니다.
AgeGroup타입이 30번과 37번 라인에서 사용되고 있지만 임포트 문이 누락되었습니다.다음 임포트를 추가하세요:
import com.wayble.server.user.entity.Gender; import com.wayble.server.user.entity.User; +import com.wayble.server.user.entity.AgeGroup;
🧹 Nitpick comments (1)
src/main/java/com/wayble/server/explore/entity/WaybleZoneVisitLogDocument.java (1)
34-34: UUID 생성 방식을 개선해보세요.현재
UUID.randomUUID().getMostSignificantBits() & Long.MAX_VALUE방식은 UUID의 절반만 사용하므로 충돌 가능성이 높아집니다. 더 안전한 ID 생성 방식을 고려해보세요.다음 대안들을 고려해보세요:
대안 1: 전체 UUID 사용
-.logId(UUID.randomUUID().getMostSignificantBits() & Long.MAX_VALUE) +.logId(UUID.randomUUID().toString().hashCode() & Long.MAX_VALUE)대안 2: 타임스탬프 기반 ID
-.logId(UUID.randomUUID().getMostSignificantBits() & Long.MAX_VALUE) +.logId(System.currentTimeMillis())대안 3: Elasticsearch 자동 ID 생성 사용
-.logId(UUID.randomUUID().getMostSignificantBits() & Long.MAX_VALUE) +.logId(null) // Elasticsearch가 자동으로 ID 생성
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/main/java/com/wayble/server/explore/dto/search/WaybleZoneSearchResponseDto.java(2 hunks)src/main/java/com/wayble/server/explore/entity/WaybleZoneDocument.java(4 hunks)src/main/java/com/wayble/server/explore/entity/WaybleZoneVisitLogDocument.java(1 hunks)src/main/java/com/wayble/server/explore/repository/WaybleZoneVisitLogDocumentRepository.java(1 hunks)src/test/java/com/wayble/server/search/WaybleZoneSearchApiIntegrationTest.java(13 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
- src/main/java/com/wayble/server/explore/repository/WaybleZoneVisitLogDocumentRepository.java
- src/main/java/com/wayble/server/explore/entity/WaybleZoneDocument.java
- src/main/java/com/wayble/server/explore/dto/search/WaybleZoneSearchResponseDto.java
- src/test/java/com/wayble/server/search/WaybleZoneSearchApiIntegrationTest.java
🧰 Additional context used
🧠 Learnings (1)
src/main/java/com/wayble/server/explore/entity/WaybleZoneVisitLogDocument.java (1)
Learnt from: seung-in-Yoo
PR: Wayble-Project/wayble-spring#37
File: src/main/java/com/wayble/server/user/entity/User.java:61-62
Timestamp: 2025-07-13T15:08:59.288Z
Learning: Java에서 같은 패키지 내의 클래스들은 import 구문 없이 서로를 참조할 수 있다. com.wayble.server.user.entity 패키지 내의 클래스들은 명시적인 import 없이 사용 가능하다.
🔇 Additional comments (1)
src/main/java/com/wayble/server/explore/entity/WaybleZoneVisitLogDocument.java (1)
12-17: Lombok 어노테이션 사용이 적절합니다.코드 생성을 위한 Lombok 어노테이션들이 잘 구성되어 있고, Elasticsearch 문서 엔티티에 적합한 구조입니다.
✔️ 연관 이슈
📝 작업 내용
Elastic Search 관련 기능을 모두 담당하는 Explore 패키지를 생성했습니다.
Repository를 인식할 때 스프링이 JPA, Elastic Search 중 어떤 Repository로 사용하는지 모호하다는 경고 문구를 내뱉고 있어서 이를 해결했습니다.
스크린샷 (선택)
Summary by CodeRabbit
신규 기능
버그 수정
리팩터
테스트