Skip to content

Commit ee72acc

Browse files
committed
feat: RankingPageInfo 클래스 추가 및 페이지 정보 처리 유틸리티 구현
1 parent c5ff2ee commit ee72acc

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.loopers.application.ranking;
2+
3+
import com.loopers.domain.ranking.RankingInfo;
4+
5+
import java.time.LocalDate;
6+
import java.util.List;
7+
8+
public record RankingPageInfo(
9+
List<RankingInfo> rankings,
10+
LocalDate date,
11+
int page,
12+
int size,
13+
Long totalCount,
14+
int totalPages
15+
) {
16+
public static RankingPageInfo of(
17+
List<RankingInfo> rankings,
18+
LocalDate date,
19+
int page,
20+
int size,
21+
Long totalCount
22+
) {
23+
int totalPages = (int) Math.ceil((double) totalCount / size);
24+
return new RankingPageInfo(rankings, date, page, size, totalCount, totalPages);
25+
}
26+
27+
public static RankingPageInfo empty(LocalDate date, int page, int size) {
28+
return new RankingPageInfo(List.of(), date, page, size, 0L, 0);
29+
}
30+
}

0 commit comments

Comments
 (0)