-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathRankingInfo.java
More file actions
44 lines (39 loc) · 1.01 KB
/
RankingInfo.java
File metadata and controls
44 lines (39 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.loopers.application.rank;
import com.loopers.domain.product.Product;
import com.loopers.domain.rank.monthly.MonthlyRankingMV;
import com.loopers.domain.rank.weekly.WeeklyRankingMV;
public record RankingInfo(
Long productId,
String productName,
Long price,
boolean isSoldOut,
int currentRank
) {
public static RankingInfo of(Product product, int currentRank) {
return new RankingInfo(
product.getId(),
product.getName(),
product.getPrice().getValue(),
product.getStock() <= 0,
currentRank
);
}
public static RankingInfo from(WeeklyRankingMV mv) {
return new RankingInfo(
mv.getProductId(),
mv.getProductName(),
mv.getPrice(),
mv.isSoldOut(),
mv.getCurrentRank()
);
}
public static RankingInfo from(MonthlyRankingMV mv) {
return new RankingInfo(
mv.getProductId(),
mv.getProductName(),
mv.getPrice(),
mv.isSoldOut(),
mv.getCurrentRank()
);
}
}