-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRankingOutput.java
More file actions
51 lines (44 loc) · 1.64 KB
/
Copy pathRankingOutput.java
File metadata and controls
51 lines (44 loc) · 1.64 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
45
46
47
48
49
50
51
package com.loopers.application.ranking;
import com.loopers.domain.product.ProductResult;
import com.loopers.domain.ranking.RankingResult;
import java.util.List;
public record RankingOutput() {
public record SearchRankings(
Integer totalPages,
Long totalItems,
Integer page,
Integer size,
List<Item> items
) {
public static SearchRankings empty(RankingResult.SearchRanks result) {
return new SearchRankings(result.totalPages(), result.totalItems(), result.page(), result.size(), List.of());
}
public static SearchRankings from(RankingResult.SearchRanks ranks, List<ProductResult.GetProductDetail> details) {
return new SearchRankings(
ranks.totalPages(),
ranks.totalItems(),
ranks.page(),
ranks.size(),
details.stream()
.map(detail -> new Item(
detail.productId(),
detail.productName(),
detail.basePrice(),
detail.likeCount(),
detail.brandId(),
detail.brandName()
))
.toList()
);
}
public record Item(
Long productId,
String productName,
Integer basePrice,
Long likeCount,
Long brandId,
String brandName
) {
}
}
}