mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
Merge pull request #2442 from thebe4st/v5-dev
cn.hutool.core.util.PageUtil#totalPage增加totalCount为long类型的重载方法
This commit is contained in:
commit
071b1fcae3
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user