Merge pull request #2442 from thebe4st/v5-dev

cn.hutool.core.util.PageUtil#totalPage增加totalCount为long类型的重载方法
This commit is contained in:
Golden Looly 2022-07-17 00:32:10 +08:00 committed by GitHub
commit 071b1fcae3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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));
}
/**