tj
2025-06-05 2d549a04870d1315868a7cf19952b64e8071e711
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
package com.cloudroam.common.util;
 
import com.cloudroam.vo.PageResponseVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
 
import java.util.List;
 
/**
 * @author 
 * 分页工具类
 */
public class PageUtil {
 
    private PageUtil() {
        throw new IllegalStateException("Utility class");
    }
 
    public static <T> PageResponseVO<T> build(IPage<T> iPage) {
        return new PageResponseVO<>(Math.toIntExact(iPage.getTotal()), iPage.getRecords(),
                Math.toIntExact(iPage.getCurrent()), Math.toIntExact(iPage.getSize()));
    }
 
    public static <K, T> PageResponseVO<K> build(IPage<T> iPage, List<K> records) {
        return new PageResponseVO<>(Math.toIntExact(iPage.getTotal()), records,
                Math.toIntExact(iPage.getCurrent()),
                Math.toIntExact(iPage.getSize()));
    }
 
}