All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.rexsheng.springboot.faster.system.utils.PageConverter Maven / Gradle / Ivy

The newest version!
package com.github.rexsheng.springboot.faster.system.utils;

import com.github.rexsheng.springboot.faster.common.domain.PagedList;
import com.mybatisflex.core.paginate.Page;

import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

public class PageConverter {

    public static  PagedList convert(Page source){
        return new PagedList<>(source.getPageNumber(),source.getPageSize(), source.getTotalPage(), source.getTotalRow(),source.getRecords());
    }

    public static  PagedList convert(Page source, Function mapper){
        return new PagedList<>(source.getPageNumber(),source.getPageSize(), source.getTotalPage(), source.getTotalRow(),source.getRecords()!=null?source.getRecords().stream().map(mapper).collect(Collectors.toList()):null);
    }

    public static  PagedList convert(Page source, List dataList){
        return new PagedList<>(source.getPageNumber(),source.getPageSize(), source.getTotalPage(), source.getTotalRow(),dataList);
    }
}