File tree Expand file tree Collapse file tree
apps/commerce-api/src/main/java/com/loopers/interfaces/api/product Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33import com .loopers .application .product .ProductDetailInfo ;
44import com .loopers .application .product .ProductFacade ;
55import com .loopers .application .product .ProductInfo ;
6+ import com .loopers .application .ranking .RankingFacade ;
67import com .loopers .interfaces .api .ApiResponse ;
78import lombok .RequiredArgsConstructor ;
89import org .springframework .data .domain .Page ;
1516public class ProductV1Controller implements ProductV1ApiSpec {
1617
1718 private final ProductFacade productFacade ;
19+ private final RankingFacade rankingFacade ;
1820
1921 @ Override
2022 @ GetMapping
@@ -31,7 +33,9 @@ public ApiResponse<ProductV1Dto.ProductResponse> getProducts(@RequestParam(requi
3133 public ApiResponse <ProductV1Dto .ProductDetailResponse > getProduct (@ PathVariable Long productId ) {
3234
3335 ProductDetailInfo product = productFacade .getProduct (productId );
34- ProductV1Dto .ProductDetailResponse response = ProductV1Dto .ProductDetailResponse .from (product );
36+ rankingFacade .recordView (productId );
37+ Long rank = rankingFacade .findRank (productId , null );
38+ ProductV1Dto .ProductDetailResponse response = ProductV1Dto .ProductDetailResponse .from (product , rank );
3539 return ApiResponse .success (response );
3640 }
3741}
Original file line number Diff line number Diff line change @@ -53,15 +53,17 @@ public record ProductDetailResponse(
5353 String productName ,
5454 String brandName ,
5555 Long price ,
56- Long likeCount
56+ Long likeCount ,
57+ Long rank
5758 ) {
58- public static ProductDetailResponse from (ProductDetailInfo productDetailInfo ) {
59+ public static ProductDetailResponse from (ProductDetailInfo productDetailInfo , Long rank ) {
5960 return new ProductDetailResponse (
6061 productDetailInfo .id (),
6162 productDetailInfo .name (),
6263 productDetailInfo .brandName (),
6364 productDetailInfo .price (),
64- productDetailInfo .likeCount ()
65+ productDetailInfo .likeCount (),
66+ rank
6567 );
6668 }
6769 }
You can’t perform that action at this time.
0 commit comments