zhuguifei
2026-03-10 2c1fd10c6fbabb8e9f0e9f07fe66fb36c008e883
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package com.shlanbao.tzsc.base.model;
 
import java.util.List;
 
import com.alibaba.fastjson.JSONObject;
/**
 * 分页视图
 * <li>@author Leejean
 * <li>@create 2014-6-27下午03:16:55
 */
public class PageView<T> {
    /** 分页数据 **/
    private List<T> rows;
    private int total;
    private int pagesize;
    private int curpage;
    private int allpage;
    public List<T> getRows() {
        return rows;
    }
    public void setRows(List<T> rows) {
        this.rows = rows;
    }
    public int getTotal() {
        return total;
    }
    public void setTotal(int total) {
        this.total = total;
    }
    
    public int getAllpage() {
        if(total!=0&&pagesize!=0){            
            return (total-1)/pagesize+1;
        }else{
            return this.allpage;
        }
    }
    public void setAllpage(int allpage) {
        this.allpage = allpage;
    }
    public PageView(List<T> rows, int total, int pagesize, int curpage) {
        super();
        this.rows = rows;
        this.total = total;
        this.pagesize = pagesize;
        this.curpage = curpage;
    }
    public int getPagesize() {
        return pagesize;
    }
    public void setPagesize(int pagesize) {
        this.pagesize = pagesize;
    }
    public int getCurpage() {
        return curpage;
    }
    public void setCurpage(int curpage) {
        this.curpage = curpage;
    }
    public PageView(List<T> rows, int total) {
        super();
        this.rows = rows;
        this.total = total;
    }    
    public PageView() {
        // TODO Auto-generated constructor stub
    }
    public String toJSON(){
        JSONObject obj = new JSONObject();
        obj.put("rows", this.getRows());
        obj.put("total",this.getTotal());
        obj.put("pagesize", this.getPagesize());
        obj.put("curpage", this.getCurpage());
        obj.put("allpage", this.getAllpage());
        return obj.toString();
    }
}