40 lines
912 B
Java
40 lines
912 B
Java
package com.sgcc.utils;
|
|
|
|
/**
|
|
* 分页工具
|
|
*
|
|
* @author zhaoyuanyuan
|
|
* @version 1.0.0
|
|
* @date 2024/06/24 16:05
|
|
*/
|
|
public class PageUtils {
|
|
|
|
/**
|
|
* 根据总数计算总页数
|
|
*
|
|
* @param totalCount 总数
|
|
* @param pageSize 每页数
|
|
* @return 总页数
|
|
*/
|
|
public static int totalPage(int totalCount, int pageSize) {
|
|
if (pageSize == 0) {
|
|
return 0;
|
|
}
|
|
return totalCount % pageSize == 0 ? (totalCount / pageSize) : (totalCount / pageSize + 1);
|
|
}
|
|
|
|
/**
|
|
* 根据总数计算总页数
|
|
*
|
|
* @param totalCount 总数
|
|
* @param pageSize 每页数
|
|
* @return 总页数
|
|
*/
|
|
public static long totalPage(long totalCount, long pageSize) {
|
|
if (pageSize == 0) {
|
|
return 0;
|
|
}
|
|
return totalCount % pageSize == 0 ? (totalCount / pageSize) : (totalCount / pageSize + 1);
|
|
}
|
|
|
|
} |