Conversation
Walkthrough상품 추천의 개인화 로직을 제거하고 추천 엔드포인트를 인기상품 기반으로 단순화했습니다. ProductRepository에서 개인화 관련 쿼리 메서드 2개를 삭제했고, ProductService와 ProductController에서 사용자 기반 분기·의존성·헬퍼 메서드를 제거하여 getRecommendedProducts(size)로 변경했습니다. Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/main/java/com/ongil/backend/domain/product/service/ProductService.java`:
- Around line 382-383: Update the Javadoc in ProductService that currently reads
"인기 상품 순(viewCount + cartCount) 반환 - 특가 상품(SPECIAL_SALE) 제외" to remove any
reference to cartCount (since the DTO/response no longer includes it); change
the description to indicate popularity is determined by viewCount only and keep
the note about excluding SPECIAL_SALE, and ensure the updated comment sits above
the corresponding method in ProductService that returns popular products.
- Around line 385-389: Remove the unused userId parameter from the service API
and its callers: change the method signature of
ProductService.getRecommendedProducts(Long userId, int size) to
getRecommendedProducts(int size) and update its internal use (PageRequest.of(0,
size) remains unchanged) and references in ProductController (and any other
callers/tests) to call productService.getRecommendedProducts(size) instead of
passing a userId; also remove any now-unused imports or parameter-related code
and run tests to ensure no remaining references to the old signature.
| * - 인기 상품 순(viewCount + cartCount) 반환 | ||
| * - 특가 상품(SPECIAL_SALE) 제외 |
There was a problem hiding this comment.
Javadoc 주석에서 cartCount 참조 제거 필요
cartCount는 이미 DTO/응답에서 제거된 필드인데 주석에 "viewCount + cartCount"가 여전히 명시되어 있어 혼란을 줄 수 있습니다.
📝 주석 수정 제안
- * - 인기 상품 순(viewCount + cartCount) 반환
+ * - 인기 상품 순(viewCount 기반) 반환Based on learnings: cartCount 필드는 프론트엔드에서 사용하지 않아 이미 제거된 상태입니다.
📝 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.
| * - 인기 상품 순(viewCount + cartCount) 반환 | |
| * - 특가 상품(SPECIAL_SALE) 제외 | |
| * - 인기 상품 순(viewCount 기반) 반환 | |
| * - 특가 상품(SPECIAL_SALE) 제외 |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/main/java/com/ongil/backend/domain/product/service/ProductService.java`
around lines 382 - 383, Update the Javadoc in ProductService that currently
reads "인기 상품 순(viewCount + cartCount) 반환 - 특가 상품(SPECIAL_SALE) 제외" to remove any
reference to cartCount (since the DTO/response no longer includes it); change
the description to indicate popularity is determined by viewCount only and keep
the note about excluding SPECIAL_SALE, and ensure the updated comment sits above
the corresponding method in ProductService that returns popular products.
| public List<ProductSimpleResponse> getRecommendedProducts(Long userId, int size) { | ||
| if (userId == null) { | ||
| return getPopularProducts(size); | ||
| } | ||
| return getPersonalizedRecommendations(userId, size); | ||
| } | ||
|
|
||
| /** | ||
| * 인기 상품 조회 | ||
| */ | ||
| private List<ProductSimpleResponse> getPopularProducts(int size) { | ||
| Pageable pageable = PageRequest.of(0, size); | ||
| List<Product> products = productRepository.findPopularProducts(pageable); | ||
| return productConverter.toSimpleResponseList(products); | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
🧩 Analysis chain
🏁 Script executed:
# Find the ProductService file and check the getRecommendedProducts method
fd ProductService.java --type fRepository: IT-Cotato/12th-OnGil-BE
Length of output: 141
🏁 Script executed:
# Search for getRecommendedProducts calls in the codebase
rg -n "getRecommendedProducts" --type java -A 3 -B 3Repository: IT-Cotato/12th-OnGil-BE
Length of output: 2253
🏁 Script executed:
# Check the ProductController to see how it calls this method
fd ProductController.java --type fRepository: IT-Cotato/12th-OnGil-BE
Length of output: 147
서비스 메서드에서 사용되지 않는 userId 파라미터 제거
getRecommendedProducts(Long userId, int size) 메서드에서 userId는 메서드 본문 어디에서도 참조되지 않습니다. 컨트롤러에서 불필요하게 이 파라미터를 전달하고 있으므로, 양쪽 모두에서 제거하는 것이 코드의 명확성을 높입니다.
♻️ 리팩토링 제안
서비스:
- public List<ProductSimpleResponse> getRecommendedProducts(Long userId, int size) {
+ public List<ProductSimpleResponse> getRecommendedProducts(int size) {
Pageable pageable = PageRequest.of(0, size);
List<Product> products = productRepository.findPopularProducts(pageable);
return productConverter.toSimpleResponseList(products);
}컨트롤러:
- public DataResponse<List<ProductSimpleResponse>> getRecommendedProducts(
- `@AuthenticationPrincipal` Long userId,
- `@RequestParam`(defaultValue = "10") `@Min`(1) `@Max`(100) int size
- ) {
- List<ProductSimpleResponse> products = productService.getRecommendedProducts(userId, size);
+ public DataResponse<List<ProductSimpleResponse>> getRecommendedProducts(
+ `@RequestParam`(defaultValue = "10") `@Min`(1) `@Max`(100) int size
+ ) {
+ List<ProductSimpleResponse> products = productService.getRecommendedProducts(size);
return DataResponse.from(products);
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/main/java/com/ongil/backend/domain/product/service/ProductService.java`
around lines 385 - 389, Remove the unused userId parameter from the service API
and its callers: change the method signature of
ProductService.getRecommendedProducts(Long userId, int size) to
getRecommendedProducts(int size) and update its internal use (PageRequest.of(0,
size) remains unchanged) and references in ProductController (and any other
callers/tests) to call productService.getRecommendedProducts(size) instead of
passing a userId; also remove any now-unused imports or parameter-related code
and run tests to ensure no remaining references to the old signature.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/java/com/ongil/backend/domain/product/controller/ProductController.java (1)
142-149:⚠️ Potential issue | 🟡 Minor
@Operation설명이 리팩토링 내용을 반영하지 않아 Swagger 문서가 부정확합니다개인화 로직 제거 후에도
@Operationdescription이 구버전 동작을 그대로 기술하고 있습니다:
- "로그인 사용자: 최근 30일간 조회/장바구니 상품 기준 …" → 해당 로직 삭제됨
- "비로그인 사용자: 전체 인기 상품 추천" → 이제 로그인 여부 구분 없음
- "정렬 기준: 전체 고객의 조회수 + 장바구니 담긴 횟수 순" →
cartCount기준 제거됨API를 소비하는 프론트엔드나 Swagger 사용자가 잘못된 동작을 기대할 수 있습니다.
📝 설명 수정 제안
`@Operation`( summary = "홈화면 추천 상품 조회", description = """ - 로그인 사용자: 최근 30일간 조회/장바구니 상품 기준 같은 카테고리 + 비슷한 가격대(±10,000원) 상품 추천 - 비로그인 사용자: 전체 인기 상품 추천 - - 정렬 기준: 전체 고객의 조회수 + 장바구니 담긴 횟수 순 + 전체 인기 상품을 조회합니다. + + 정렬 기준: 전체 고객의 조회수(viewCount) 순 """ )🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main/java/com/ongil/backend/domain/product/controller/ProductController.java` around lines 142 - 149, Update the `@Operation` description on ProductController to reflect the refactor: remove any mention of per-user personalization ("로그인 사용자..." / "비로그인 사용자...") and remove reference to cartCount; state that the endpoint returns general recommended products (same for all users) and that sorting is based on overall view count only (or list the current actual sorting metric used by the implementation). Edit the description string in the `@Operation` annotation for the method in ProductController to match the current behavior and wording used by the implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In
`@src/main/java/com/ongil/backend/domain/product/controller/ProductController.java`:
- Around line 142-149: Update the `@Operation` description on ProductController to
reflect the refactor: remove any mention of per-user personalization ("로그인
사용자..." / "비로그인 사용자...") and remove reference to cartCount; state that the
endpoint returns general recommended products (same for all users) and that
sorting is based on overall view count only (or list the current actual sorting
metric used by the implementation). Edit the description string in the
`@Operation` annotation for the method in ProductController to match the current
behavior and wording used by the implementation.
---
Duplicate comments:
In `@src/main/java/com/ongil/backend/domain/product/service/ProductService.java`:
- Around line 382-383: Javadoc in ProductService still mentions "인기 상품
순(viewCount + cartCount) 반환" even though cartCount is not used; update the
comment in the ProductService class (the Javadoc block containing that line) to
remove the cartCount reference and accurately state the sorting criterion (e.g.,
"인기 상품 순(viewCount 기준) 반환" or similar) and keep the note about excluding
SPECIAL_SALE; ensure the modified text reflects the actual behavior implemented
by the related method(s) in ProductService.
🔍️ 작업 내용
✨ 상세 설명
🛠️ 추후 리팩토링 및 고도화 계획
📸 스크린샷 (선택)
💬 리뷰 요구사항
Summary by CodeRabbit