Conversation
Walkthrough홈 화면 API 엔드포인트를 인증된 사용자 컨텍스트 지원으로 개선했습니다. 컨트롤러가 인증 주체에서 사용자 ID를 받아 서비스로 전달하고, 서비스는 광고, 추천 상품, 추천 브랜드, 장바구니 개수를 각 서비스에서 동적으로 조회하여 반환합니다. Changes
Sequence DiagramsequenceDiagram
actor Client
participant Controller as HomeController
participant Service as HomeService
participant AdvertSvc as AdvertisementService
participant ProductSvc as ProductService
participant BrandSvc as BrandService
participant CartSvc as CartService
Client->>Controller: GET /home<br/>(`@AuthenticationPrincipal` userId)
Controller->>Service: getHomeData(userId)
Service->>AdvertSvc: getAdvertisements()
AdvertSvc-->>Service: List<AdvertisementResponse>
Service->>ProductSvc: getRecommendedProducts(RECOMMENDED_PRODUCTS_SIZE)
ProductSvc-->>Service: List<RecommendedProductResponse>
Service->>BrandSvc: getRecommendBrands()
BrandSvc-->>Service: List<BrandRecommendResponse>
alt userId != null
Service->>CartSvc: getCartCount(userId)
CartSvc-->>Service: Long cartCount
else userId == null
Service-->>Service: cartCount = null
end
Service->>Service: HomeConverter.toHomeResDto(advertisements,<br/>recommendedProducts, recommendBrands, cartCount)
Service-->>Controller: HomeResDto
Controller-->>Client: DataResponse<HomeResDto>
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
🚥 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)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
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 |
🔍️ 작업 내용
파일: HomeController.java
변경 내용: @AuthenticationPrincipal Long userId
추가
(로그인/비로그인 분기), 반환 타입
ResponseEntity →
DataResponse로 통일, @tag에 토큰 선택 설명
추가
────────────────────────────────────────
파일: HomeService.java
변경 내용: 더미 데이터 제거 →
AdvertisementService,
ProductService, BrandService, CartService
4개 서비스 호출하여 실제 데이터 조합
────────────────────────────────────────
파일: HomeResDto.java
변경 내용: 문자열 필드 → 실제 응답 DTO 타입으로
변경
(AdvertisementResponse,
RecommendedProductResponse,
BrandRecommendResponse, Long cartCount)
────────────────────────────────────────
파일: HomeConverter.java
변경 내용: 기존 문자열 변환 로직 → 실제 DTO 조합
변환
로직으로 재작성
요약
GET /api/home 하나로 홈 화면에 필요한 광고 5개 +
추천 상품 + 추천 브랜드 3개 + 장바구니 개수를 한
번에 반환하도록 리팩토링
Summary by CodeRabbit
릴리스 노트