-
Notifications
You must be signed in to change notification settings - Fork 0
feat(Store): 예약 개수 정렬 로직 반환타입 추가 #159
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
The head ref may contain hidden characters: "feature/#158_Store\uC608\uC57D\uB9CE\uC740\uC21C\uBC18\uD658\uD0C0\uC785\uAC1C\uC120"
Conversation
- storeImageUrl 추가 - 학과명 추가
Walkthrough보안 설정에서 새로운 URL 패턴이 인증 없이 접근 가능하도록 추가되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant StoreServiceImpl
participant Redis
participant StoreRepository
participant DepartmentRepository
participant StoreImageRepository
Client->>StoreServiceImpl: getStoresByWaitingCount(desc)
StoreServiceImpl->>Redis: scan for store waiting keys
loop for each storeId
StoreServiceImpl->>StoreRepository: findById(storeId)
StoreServiceImpl->>DepartmentRepository: findById(store.departmentId)
StoreServiceImpl->>StoreImageRepository: findByStoreAndImageType(store, BANNER)
end
StoreServiceImpl-->>Client: List<StoreWaitingInfo> (포함: bannerImageUrl, departmentName)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests
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: 2
🧹 Nitpick comments (1)
nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/store/repository/StoreImageRepository.java (1)
3-3: 불필요한 static import 제거 권장현재 파일에서
ImageType.*의 static import를 사용하지 않고 있습니다.-import static com.nowait.domaincorerdb.store.entity.ImageType.*;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/config/security/SecurityConfig.java(1 hunks)nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StoreWaitingInfo.java(1 hunks)nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/service/StoreServiceImpl.java(2 hunks)nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/store/repository/StoreImageRepository.java(2 hunks)
🔇 Additional comments (3)
nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/store/repository/StoreImageRepository.java (1)
24-24: 새로운 리포지토리 메서드 승인Store 엔티티와 ImageType을 직접 받는 새로운 메서드가 추가되어 기존 메서드들과 일관성을 유지하며 사용성을 개선합니다.
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StoreWaitingInfo.java (1)
11-15: 생성자 인자 순서 확인 완료 및 코드 변경 승인
StoreWaitingInfo클래스 필드 선언 순서
(bannerImageUrl → departmentName → storeId → storeName → waitingCount)
와 생성자 호출 인자 순서
(imageUrl, department.getName(), storeId, storeName, count != null ? count : 0)
가 일치함을 확인했습니다.nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/service/StoreServiceImpl.java (1)
29-29: Import 추가 승인ImageType 사용을 위한 적절한 import 추가입니다.
| "/webjars/**", | ||
| "/demo-ui.html" | ||
| "/demo-ui.html", | ||
| "/v1/menus//all-menus/stores/**" |
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
URL 패턴의 이중 슬래시 검증 필요
URL 패턴에 이중 슬래시(//)가 포함되어 있습니다. 이것이 의도된 것인지 확인이 필요합니다.
다음 스크립트로 실제 컨트롤러 엔드포인트와 일치하는지 확인해주세요:
🏁 Script executed:
#!/bin/bash
# 실제 메뉴 관련 엔드포인트 패턴 확인
ast-grep --pattern '@RequestMapping($$$)' | grep -i menu
ast-grep --pattern '@GetMapping($$$)' | grep -i menu
rg -A 2 -B 2 "v1/menus.*all-menus.*stores"Length of output: 1855
이중 슬래시 오타 수정 필요
보안 설정에서 등록한 패턴
"/v1/menus//all-menus/stores/**"는 실제 컨트롤러의 엔드포인트
@RequestMapping("/v1/menus")
@GetMapping("/all-menus/stores/{storeId}")가 제공하는 /v1/menus/all-menus/stores/{storeId} 경로와 매칭되지 않습니다.
결과적으로 해당 API가 인증 없이 접근 허용 목록에 들어가지 않아 의도와 다르게 인증이 요구될 수 있습니다.
수정 제안:
- 파일: nowait-app-user-api/src/main/java/com/nowait/applicationuser/config/security/SecurityConfig.java
- 줄 70
- "/v1/menus//all-menus/stores/**"
- "/v1/menus/all-menus/stores/**"
해당 패턴을 위와 같이 변경하여 실제 엔드포인트와 일치시키고, 의도한 대로 인증 없이 접근 가능하도록 해주세요.
<details>
<summary>🤖 Prompt for AI Agents</summary>
In
nowait-app-user-api/src/main/java/com/nowait/applicationuser/config/security/SecurityConfig.java
at line 70, fix the double slash typo in the URL pattern
"/v1/menus//all-menus/stores/" by changing it to
"/v1/menus/all-menus/stores/" so it correctly matches the controller endpoint
and allows unauthenticated access as intended.
</details>
<!-- fingerprinting:phantom:poseidon:panther -->
<!-- This is an auto-generated comment by CodeRabbit -->
| Store store = storeRepository.findById(Long.valueOf(storeId)) | ||
| .orElseThrow(StoreNotFoundException::new); | ||
| Department department = departmentRepository.getReferenceById(store.getDepartmentId()); | ||
| List<StoreImage> storeImageList = storeImageRepository.findByStoreAndImageType(store, ImageType.BANNER); | ||
|
|
||
| String imageUrl = storeImageList.isEmpty() ? null : storeImageList.get(0).getImageUrl(); | ||
|
|
||
| result.add(new StoreWaitingInfo( | ||
| imageUrl, | ||
| department.getName(), | ||
| storeId, | ||
| storeName, | ||
| count != null ? count : 0 | ||
| )); |
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
성능 최적화 및 예외 처리 개선 필요
현재 구현에서 다음 문제점들이 있습니다:
- Store 엔티티를 두 번 조회하는 비효율성 (238라인과 242라인)
getReferenceById사용으로 인한 잠재적 LazyInitializationException- Department가 존재하지 않을 경우의 예외 처리 부재
다음과 같이 리팩토링을 권장합니다:
- // DB에서 storeName 조회
- String storeName = storeRepository.findById(Long.valueOf(storeId))
- .map(Store::getName)
- .orElse(UNKNOWN_STORE_NAME);
-
- Store store = storeRepository.findById(Long.valueOf(storeId))
- .orElseThrow(StoreNotFoundException::new);
- Department department = departmentRepository.getReferenceById(store.getDepartmentId());
- List<StoreImage> storeImageList = storeImageRepository.findByStoreAndImageType(store, ImageType.BANNER);
-
- String imageUrl = storeImageList.isEmpty() ? null : storeImageList.get(0).getImageUrl();
-
- result.add(new StoreWaitingInfo(
- imageUrl,
- department.getName(),
- storeId,
- storeName,
- count != null ? count : 0
- ));
+ Store store = storeRepository.findById(Long.valueOf(storeId))
+ .orElseThrow(StoreNotFoundException::new);
+
+ String departmentName = departmentRepository.findById(store.getDepartmentId())
+ .map(Department::getName)
+ .orElse("Unknown Department");
+
+ List<StoreImage> storeImageList = storeImageRepository.findByStoreAndImageType(store, ImageType.BANNER);
+ String imageUrl = storeImageList.isEmpty() ? null : storeImageList.get(0).getImageUrl();
+
+ result.add(new StoreWaitingInfo(
+ imageUrl,
+ departmentName,
+ storeId,
+ store.getName(),
+ count != null ? count : 0
+ ));📝 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.
| Store store = storeRepository.findById(Long.valueOf(storeId)) | |
| .orElseThrow(StoreNotFoundException::new); | |
| Department department = departmentRepository.getReferenceById(store.getDepartmentId()); | |
| List<StoreImage> storeImageList = storeImageRepository.findByStoreAndImageType(store, ImageType.BANNER); | |
| String imageUrl = storeImageList.isEmpty() ? null : storeImageList.get(0).getImageUrl(); | |
| result.add(new StoreWaitingInfo( | |
| imageUrl, | |
| department.getName(), | |
| storeId, | |
| storeName, | |
| count != null ? count : 0 | |
| )); | |
| Store store = storeRepository.findById(Long.valueOf(storeId)) | |
| .orElseThrow(StoreNotFoundException::new); | |
| String departmentName = departmentRepository.findById(store.getDepartmentId()) | |
| .map(Department::getName) | |
| .orElse("Unknown Department"); | |
| List<StoreImage> storeImageList = storeImageRepository.findByStoreAndImageType(store, ImageType.BANNER); | |
| String imageUrl = storeImageList.isEmpty() ? null : storeImageList.get(0).getImageUrl(); | |
| result.add(new StoreWaitingInfo( | |
| imageUrl, | |
| departmentName, | |
| storeId, | |
| store.getName(), | |
| count != null ? count : 0 | |
| )); |
🤖 Prompt for AI Agents
In
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/service/StoreServiceImpl.java
around lines 242 to 255, avoid fetching the Store entity twice by reusing the
initially retrieved Store object. Replace getReferenceById for Department with a
safe fetch method like findById to prevent LazyInitializationException, and add
proper exception handling if the Department is not found. This will optimize
performance and improve robustness by ensuring all entities are properly loaded
and exceptions are handled gracefully.
작업 요약
Issue Link
문제점 및 어려움
해결 방안
Reference
Summary by CodeRabbit
신규 기능
버그 수정
기타 개선