Commit 675396ef authored by Shen's avatar Shen

1. 添加分页util工具类(暂未使用)

parent 624b77e9
package io.hmit.common.utils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @Description :
* @Author : Shen Yuanfeng
* @Date : 2021/5/7 9:49
*/
public class SubListForPageUtil {
public static <T> List<T> getSubList(Map<String, Object> params, List<T> list){
Integer pageNum = Integer.parseInt(params.get("page").toString());
Integer pageSize = Integer.parseInt(params.get("limit").toString());
Integer count = list.size();
Integer pageNo = (pageNum - 1) * pageSize;
List<T> list2 ;
if (pageNo+pageSize > count) {
if (pageNo > count){
list2 = new ArrayList<>();
}else {
list2 = list.subList(pageNo, count);
}
}else {
list2 = list.subList(pageNo, pageNo+pageSize);
}
return list2;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment