mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
cn.hutool.core.util.PageUtil#totalPage增加totalCount为long类型的重载方法
This commit is contained in:
parent
a38e3e52af
commit
312d2800c9
@ -175,10 +175,21 @@ public class PageUtil {
|
|||||||
* @return 总页数
|
* @return 总页数
|
||||||
*/
|
*/
|
||||||
public static int totalPage(int totalCount, int pageSize) {
|
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) {
|
if (pageSize == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return totalCount % pageSize == 0 ? (totalCount / pageSize) : (totalCount / pageSize + 1);
|
return Math.toIntExact(totalCount % pageSize == 0 ? (totalCount / pageSize) : (totalCount / pageSize + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user