package org.springblade.flow.util;

import java.util.List;

/**
 *
 * @author JNPF开发平台组
 * @version V3.1.0
 * @copyright 引迈信息技术有限公司
 * @date 2021/3/16 8:54
 */
public class PageUtil {
	/**
	 * 自定义分页
	 */
	@SuppressWarnings("rawtypes")
	public static List getListPage(int page, int pageSize, List list) {
		if (list == null || list.size() == 0) {
			return list;
		}
		int totalCount = list.size();
		page = page - 1;
		int fromIndex = page * pageSize;
		if (fromIndex >= totalCount) {
			return list;
		}
		int toIndex = ((page + 1) * pageSize);
		if (toIndex > totalCount) {
			toIndex = totalCount;
		}
		return list.subList(fromIndex, toIndex);
	}
}
