All Downloads are FREE. Search and download functionalities are using the official Maven repository.

matrix.boot.based.utils.PageUtil Maven / Gradle / Ivy

There is a newer version: 2.1.10
Show newest version
package matrix.boot.based.utils;

/**
 * 分页工具
 * @author wangcheng
 */
public class PageUtil {

    /**
     * 获取一共多少页
     *
     * @param pageCount 每页条数
     * @param totalCount 全部条数
     */
    public static Integer getTotalPage(Integer pageCount, Integer totalCount) {
        return (totalCount % pageCount) == 0 ? (totalCount / pageCount) : (totalCount / pageCount) + 1;
    }

    /**
     * 获取从第几条数据开始
     *
     * @param pageCount 每页条数
     * @param pageNum 当前页数(从1开始)
     */
    public static Integer getStartIndex(Integer pageCount, Integer pageNum) {
        return pageCount * (pageNum - 1);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy