forked from Loopers-dev-lab/loop-pack-be-l2-vol2-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRankingInfo.java
More file actions
40 lines (35 loc) · 1.06 KB
/
RankingInfo.java
File metadata and controls
40 lines (35 loc) · 1.06 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
package com.loopers.application.ranking;
import com.loopers.domain.common.vo.Money;
import java.util.List;
public class RankingInfo {
public record RankingPageInfo(
List<RankingItemInfo> rankings,
String date,
int page,
int size,
long totalCount,
int totalPages,
boolean hasNext
) {
public static RankingPageInfo of(
List<RankingItemInfo> rankings,
String date,
int page,
int size,
long totalCount
) {
int totalPages = size > 0 ? (int) Math.ceil((double) totalCount / size) : 0;
boolean hasNext = page < totalPages - 1;
return new RankingPageInfo(rankings, date, page, size, totalCount, totalPages, hasNext);
}
}
public record RankingItemInfo(
int rank,
Long productId,
String productName,
String brandName,
Money price,
int likeCount,
Double score
) {}
}