
package com.ruoyi.common.page;

import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.core.page.TableSupport;

import java.util.List;

/**
 * 手动分页
 */
public class ManualPagination {

    public static <T> List<T> getPage(List<T> dataList) {

        PageDomain pageDomain = TableSupport.buildPageRequest();
        Integer pageNum = pageDomain.getPageNum();
        Integer pageSize = pageDomain.getPageSize();
        int startIndex = (pageNum - 1) * pageSize;
        int endIndex = Math.min(startIndex + pageSize, dataList.size());
        List<T> pageData = dataList.subList(startIndex, endIndex);
        return pageData;
    }

    public static void main(String[] args) {

    }
}
