yangys
2024-03-30 871c0fce344b24c8046ec01173eca79b9e60c1d7
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
package com.qianwen.core.mp.utils;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import com.qianwen.core.tool.utils.BeanUtil;
 
/* loaded from: blade-starter-mybatis-9.3.0.0-SNAPSHOT.jar:org/springblade/core/mp/utils/PageUtil.class */
public class PageUtil {
    public static <T> Page<T> toPage(IPage<?> page, Class<T> target) {
        List<T> records = BeanUtil.copy(page.getRecords(), target);
        return toPage(page, records);
    }
 
    public static <T> Page<T> toPage(IPage<?> page, List<T> records) {
        Page<T> pageResult = new Page<>();
        pageResult.setCurrent(page.getCurrent());
        pageResult.setSize(page.getSize());
        pageResult.setPages(page.getPages());
        pageResult.setTotal(page.getTotal());
        pageResult.setRecords(records);
        return pageResult;
    }
 
    /* JADX WARN: Multi-variable type inference failed */
    public static <T, R> Page<R> toPage(IPage<T> page, Function<T, R> function) {
        List<R> records = new ArrayList<>();
        for (T record : page.getRecords()) {
          records.add(function.apply(record)); 
        }
        return toPage(page, records);
    }
}