refactor: 홈화면 상품 응답 DTO를 ProductSimpleResponse로 통일#160
Conversation
WalkthroughRecommendedProductResponse DTO를 삭제하고 ProductSimpleResponse로 통합하는 리팩토링입니다. ProductController와 ProductService의 추천 상품 조회 API 반환 타입을 변경하고, 관련 import와 변수 타입을 업데이트했습니다. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 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: 1
🤖 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/controller/ProductController.java`:
- Around line 152-158: The API changed the response type in
getRecommendedProducts (ProductController#getRecommendedProducts) from
RecommendedProductResponse to ProductSimpleResponse and dropped the cartCount
field, causing a breaking change; to fix, restore backward compatibility by
returning a DTO that includes cartCount (either revert to using
RecommendedProductResponse or extend ProductSimpleResponse to include
cartCount), update productService.getRecommendedProducts to populate cartCount
alongside purchaseCount/reviewCount, and ensure DataResponse.from(...) wraps the
DTO with the original field present so clients depending on cartCount continue
to work.
| public DataResponse<List<ProductSimpleResponse>> getRecommendedProducts( | ||
| @AuthenticationPrincipal Long userId, | ||
| @RequestParam(defaultValue = "10") @Min(1) @Max(100) int size | ||
| ) { | ||
| List<RecommendedProductResponse> products = productService.getRecommendedProducts(userId, size); | ||
| List<ProductSimpleResponse> products = productService.getRecommendedProducts(userId, size); | ||
| return DataResponse.from(products); | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# 1. Git 이력에서 RecommendedProductResponse 확인
echo "=== RecommendedProductResponse Git 이력 ==="
git log --all --full-history --oneline -- "**/RecommendedProductResponse.java" 2>/dev/null || echo "파일 변경 이력 없음"
# 2. RecommendedProductResponse 삭제 여부 확인
echo -e "\n=== 현재 Repository에서 RecommendedProductResponse 검색 ==="
git ls-files | grep -i "recommendedproduct" || echo "현재 파일 없음"
# 3. 최근 commit에서 DTO 삭제 변경사항 확인
echo -e "\n=== 최근 삭제된 파일 확인 ==="
git log -1 --diff-filter=D --summary -- "*.java" | grep -i "recommend\|delete" || echo "최근 삭제 내역 없음"
# 4. ProductSimpleResponse 현재 정의 확인
echo -e "\n=== ProductSimpleResponse 필드 ==="
find . -type f -name "ProductSimpleResponse.java" 2>/dev/null | head -1 | xargs cat 2>/dev/null
# 5. RecommendedProductResponse 과거 정의 찾기
echo -e "\n=== 과거 RecommendedProductResponse 정의 (Git) ==="
git log -p --all -S "class RecommendedProductResponse" -- "*.java" 2>/dev/null | head -100 || echo "정의 찾을 수 없음"Repository: IT-Cotato/12th-OnGil-BE
Length of output: 1531
🏁 Script executed:
#!/bin/bash
# 1. 특정 commit에서 RecommendedProductResponse 내용 확인
echo "=== bd664d4 commit에서 RecommendedProductResponse 찾기 ==="
git show bd664d4 -- "**/RecommendedProductResponse.java" 2>/dev/null | head -100
# 2. commit 958546b에서도 확인
echo -e "\n=== 958546b commit에서 RecommendedProductResponse 찾기 ==="
git show 958546b --name-only | grep -i recommendedproduct
# 3. RecommendedProductResponse 마지막 존재 commit 찾기
echo -e "\n=== RecommendedProductResponse가 마지막으로 존재한 내용 ==="
git log --all -p -S "RecommendedProductResponse" -- "*.java" 2>/dev/null | head -150
# 4. ProductController 변경 이력 확인
echo -e "\n=== ProductController 최근 변경 ==="
git log --oneline -10 -- "src/main/java/com/ongil/backend/domain/product/controller/ProductController.java"
# 5. 특정 메서드 변경 확인
echo -e "\n=== getRecommendedProducts 메서드 변경 이력 ==="
git log -p -S "getRecommendedProducts" -- "*.java" 2>/dev/null | head -200Repository: IT-Cotato/12th-OnGil-BE
Length of output: 8053
getRecommendedProducts API 응답 구조 변경 — 필드 손실로 인한 하위 호환성 파괴
RecommendedProductResponse에서 ProductSimpleResponse로 변경되면서 cartCount 필드가 손실되었습니다. 이전 API는 "장바구니 담긴 횟수" 정보를 응답에 포함했으나, 현재는 해당 필드가 제거되었으므로 클라이언트가 이 데이터에 의존하고 있었다면 사일런트 브레이킹 체인지가 발생합니다.
추가로 purchaseCount(구매 횟수), reviewCount(리뷰 개수) 필드가 신규 추가되었으므로, 의도적 리팩토링이라면 변경 사유와 클라이언트 영향 범위를 명확히 하시기 바랍니다.
🤖 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 152 - 158, The API changed the response type in
getRecommendedProducts (ProductController#getRecommendedProducts) from
RecommendedProductResponse to ProductSimpleResponse and dropped the cartCount
field, causing a breaking change; to fix, restore backward compatibility by
returning a DTO that includes cartCount (either revert to using
RecommendedProductResponse or extend ProductSimpleResponse to include
cartCount), update productService.getRecommendedProducts to populate cartCount
alongside purchaseCount/reviewCount, and ensure DataResponse.from(...) wraps the
DTO with the original field present so clients depending on cartCount continue
to work.
There was a problem hiding this comment.
의도된 변경입니다. 홈화면 특가 상품 / 추천 상품 / 추천 브랜드 3개 API의 응답 DTO를
ProductSimpleResponse로 통일하는 리팩토링입니다.
- cartCount: 프론트엔드에서 사용하지 않는 필드로 확인 후 제거
- purchaseCount, reviewCount: 기존 특가 상품/추천 브랜드에는 이미 포함되어 있었고, 추천 상품에도
동일하게 포함되도록 통일
There was a problem hiding this comment.
@neibler, 명확한 설명 감사합니다! 프론트엔드 팀과 확인 후 진행한 의도적인 리팩토링이라면 전혀 문제없습니다. frontend와 backend를 동시에 업데이트할 수 있는 환경에서는 통합된 변경이 문제를 일으키지 않으며, 여러 API 응답 DTO를 하나로 통일하는 것은 유지보수성을 높이는 좋은 아키텍처 결정입니다.
특히 cartCount가 실제로 사용되지 않는 필드였고, purchaseCount/reviewCount는 다른 엔드포인트에 이미 존재했던 것을 표준화한 것이라면 일관성 있는 API 설계를 위한 올바른 접근입니다. 👍
✏️ Learnings added
Learnt from: neibler
Repo: IT-Cotato/12th-OnGil-BE PR: 160
File: src/main/java/com/ongil/backend/domain/product/controller/ProductController.java:152-158
Timestamp: 2026-02-19T10:53:05.953Z
Learning: 홈화면 상품 관련 API(특가 상품, 추천 상품, 추천 브랜드)는 ProductSimpleResponse DTO로 통일되었으며, cartCount 필드는 프론트엔드에서 사용하지 않아 제거되었습니다.
Learnt from: neibler
Repo: IT-Cotato/12th-OnGil-BE PR: 160
File: src/main/java/com/ongil/backend/domain/product/controller/ProductController.java:152-158
Timestamp: 2026-02-19T10:53:05.953Z
Learning: ProductSimpleResponse의 purchaseCount와 reviewCount 필드는 홈화면 상품 API 전반에서 표준화된 필드입니다.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
🔍️ 작업 내용
refactor: 홈화면 상품 응답 DTO를 ProductSimpleResponse로 통일
✨ 상세 설명
🛠️ 추후 리팩토링 및 고도화 계획
📸 스크린샷 (선택)
💬 리뷰 요구사항
Summary by CodeRabbit
Refactor
Word Count: 12 words
Note: This release includes internal refactoring with no visible changes to end-user functionality. The recommendation endpoint continues to operate as expected with a standardized response structure.