Skip to content

refactor: 홈화면 상품 응답 DTO를 ProductSimpleResponse로 통일#160

Merged
neibler merged 1 commit intodevelopfrom
feature/158
Feb 19, 2026
Merged

refactor: 홈화면 상품 응답 DTO를 ProductSimpleResponse로 통일#160
neibler merged 1 commit intodevelopfrom
feature/158

Conversation

@neibler
Copy link
Copy Markdown
Contributor

@neibler neibler commented Feb 19, 2026

🔍️ 작업 내용

  • Closes #
    refactor: 홈화면 상품 응답 DTO를 ProductSimpleResponse로 통일

✨ 상세 설명

🛠️ 추후 리팩토링 및 고도화 계획

📸 스크린샷 (선택)

💬 리뷰 요구사항

Summary by CodeRabbit

Refactor

  • 상품 추천 API의 응답 형식을 통일하여 코드 일관성을 개선했습니다.

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.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 19, 2026

Walkthrough

RecommendedProductResponse DTO를 삭제하고 ProductSimpleResponse로 통합하는 리팩토링입니다. ProductController와 ProductService의 추천 상품 조회 API 반환 타입을 변경하고, 관련 import와 변수 타입을 업데이트했습니다.

Changes

Cohort / File(s) Summary
DTO 통합
src/main/java/com/ongil/backend/domain/product/dto/response/RecommendedProductResponse.java
RecommendedProductResponse 파일 전체 삭제. id, name, price, discountRate, finalPrice, thumbnailImageUrl, brandName, productType, viewCount, cartCount, reviewRating 필드 및 Lombok/Swagger 어노테이션 제거 (46줄).
API 레이어 업데이트
src/main/java/com/ongil/backend/domain/product/controller/ProductController.java
getRecommendedProducts 메서드의 반환 타입을 DataResponse<List>로 변경. RecommendedProductResponse import 제거 및 로컬 변수 타입 업데이트.
서비스 레이어 업데이트
src/main/java/com/ongil/backend/domain/product/service/ProductService.java
getRecommendedProducts 메서드의 반환 타입을 List로 변경. toRecommendedResponse/toRecommendedResponseList 헬퍼 메서드 제거 및 productConverter.toSimpleResponseList 사용으로 통일.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • PR #123: RecommendedProductResponse 사용처를 제거하는 HomeResDto/HomeConverter 리팩토링과 연관.
  • PR #85: 추천 상품 API의 초기 도입 당시 RecommendedProductResponse를 정의한 PR과 직접 연관.
  • PR #99: 추천 상품에서 RecommendedProductResponse를 사용하는 Home API 구현과 상충 가능성.

Suggested labels

♻️ Refactor

Suggested reviewers

  • kangcheolung
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목이 변경사항의 핵심을 명확하게 설명합니다: RecommendedProductResponse를 ProductSimpleResponse로 통일하는 리팩토링이며, 코드 변경 내용과 일치합니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/158

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a 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

🤖 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.

Comment on lines +152 to 158
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);
}
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 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 -200

Repository: 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

의도된 변경입니다. 홈화면 특가 상품 / 추천 상품 / 추천 브랜드 3개 API의 응답 DTO를
ProductSimpleResponse로 통일하는 리팩토링입니다.

  • cartCount: 프론트엔드에서 사용하지 않는 필드로 확인 후 제거
  • purchaseCount, reviewCount: 기존 특가 상품/추천 브랜드에는 이미 포함되어 있었고, 추천 상품에도
    동일하게 포함되도록 통일

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

@neibler neibler merged commit 2454bbd into develop Feb 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant