cn.hutool.core.util.PageUtil#totalPage增加totalCount为long类型的重载方法

This commit is contained in:
cenzhongyuan 2022-07-12 17:38:29 +08:00
parent a38e3e52af
commit 312d2800c9

View File

@ -175,10 +175,21 @@ public class PageUtil {
* @return 总页数
*/
public static int totalPage(int totalCount, int pageSize) {
return totalPage((long) totalCount,pageSize);
}
/**
* 根据总数计算总页数
*
* @param totalCount 总数
* @param pageSize 每页数
* @return 总页数
*/
public static int totalPage(long totalCount, int pageSize) {
if (pageSize == 0) {
return 0;
}
return totalCount % pageSize == 0 ? (totalCount / pageSize) : (totalCount / pageSize + 1);
return Math.toIntExact(totalCount % pageSize == 0 ? (totalCount / pageSize) : (totalCount / pageSize + 1));
}
/**