Skip to content

Commit 8626727

Browse files
committed
feat: 상품 상세에 랭킹 정보 추가
- ProductDetailInfo: ranking, brandId 필드 추가 - ProductReadService: brandId 설정 - ProductV1Dto: ranking 응답 필드 추가
1 parent b3b3270 commit 8626727

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

apps/commerce-api/src/main/java/com/loopers/application/product/ProductDetailInfo.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,19 @@ public class ProductDetailInfo {
1414
private final Long id;
1515
private final String name;
1616
private final String description;
17+
private final Long brandId;
1718
private final String brandName;
1819
private final String brandDescription;
1920
private final Money price;
2021
private final Stock stock;
2122
private final int likeCount;
2223
private final boolean isLikedByMember;
24+
private final Integer ranking; // 순위 (1-based), 순위권 밖이면 null
2325

2426
public Long getId() { return id; }
2527
public String getName() { return name; }
2628
public String getDescription() { return description; }
29+
public Long getBrandId() { return brandId; }
2730
public String getBrandName() { return brandName; }
2831
public String getBrandDescription() { return brandDescription; }
2932
public Money getPrice() { return price; }
@@ -33,6 +36,8 @@ public class ProductDetailInfo {
3336
@JsonProperty("likedByMember")
3437
public boolean isLikedByMember() { return isLikedByMember; }
3538

39+
public Integer getRanking() { return ranking; }
40+
3641
@JsonPOJOBuilder(withPrefix = "")
3742
public static class ProductDetailInfoBuilder {
3843
}

apps/commerce-api/src/main/java/com/loopers/domain/product/service/ProductReadService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,14 @@ public ProductDetailInfo getProductDetail(Long productId, Long memberIdOrNull) {
5151
.id(product.getId())
5252
.name(product.getName())
5353
.description(product.getDescription())
54+
.brandId(product.getBrandId())
5455
.brandName(brand.getName())
5556
.brandDescription(brand.getDescription())
5657
.price(product.getPrice())
5758
.stock(product.getStock())
5859
.likeCount(product.getLikeCount())
5960
.isLikedByMember(isLikedByMember)
61+
.ranking(null) // 캐시 저장용, Facade에서 실시간 조회로 교체
6062
.build();
6163
}
6264

apps/commerce-api/src/main/java/com/loopers/interfaces/api/product/ProductV1Dto.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ public record ProductDetailResponse(
3939
BigDecimal price,
4040
int stockQuantity,
4141
int likeCount,
42-
boolean isLikedByMember
42+
boolean isLikedByMember,
43+
Integer ranking // 순위 (1-based), 순위권 밖이면 null
4344
) {
4445
public static ProductDetailResponse from(ProductDetailInfo info) {
4546
return new ProductDetailResponse(
@@ -51,7 +52,8 @@ public static ProductDetailResponse from(ProductDetailInfo info) {
5152
info.getPrice().getAmount(),
5253
info.getStock().getQuantity(),
5354
info.getLikeCount(),
54-
info.isLikedByMember()
55+
info.isLikedByMember(),
56+
info.getRanking()
5557
);
5658
}
5759
}

0 commit comments

Comments
 (0)