xuxiuxi
2017-08-01 785fd3c3e9984f301018b3b5deb91ecc2c8da124
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package cn.com.basic.face.service.sqlite;
 
import cn.com.basic.face.discern.common.CommonVariables;
 
/**
 * Created by dpy on 2017/7/20.
 */
 
public class BaseDao {
 
 
    /**
     * 获取分页开始行
     * @param pageNum
     * @return
     */
    public int getStartIndex(Integer pageNum){
        if(pageNum == null || pageNum <= 0){
            return  0;
        }
        return (pageNum-1)*Integer.parseInt(CommonVariables.Page.DEFAULT_PAGE_SIZE);
    }
 
    /**
     * 获取总页数
     * @param total
     * @return
     */
    public int getTotalPageSize(Integer total){
        if(total == null || total <= 0){
            return  1;
        }
        int pageSize = Integer.parseInt(CommonVariables.Page.DEFAULT_PAGE_SIZE);
        return total%pageSize == 0 ? total/pageSize : total/pageSize + 1;
    }
}