xuhy
2024-02-29 384bd896d3cefd65fb0bdd756ba94fd992dc6c9c
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
package com.ruoyi.common.basic;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 
import java.io.Serializable;
import java.util.List;
 
/**
 * @Author liheng
 * @Date 2019/08/26 10:28 AM
 * @Description
 */
@JsonIgnoreProperties({"orders", "optimizeCountSql", "hitCount", "countId", "maxLimit", "searchCount"})
public class PageInfo<T> extends Page<T> implements Serializable {
 
    private static final long serialVersionUID = 1L;
    private boolean hasNextPage;
    private boolean hasPrevPage;
    private long startIndex;
 
    public PageInfo(long currentPage, long pageShowCount) {
        super(currentPage, pageShowCount);
        this.startIndex = super.offset();
    }
 
    public PageInfo() {
        super();
    }
 
    private static boolean hasPrevPage(long currentPage) {
        return currentPage != 1;
    }
 
    @Override
    public PageInfo<T> setRecords(List<T> records) {
        super.setRecords(records);
        this.hasNextPage = super.hasNext();
        this.hasPrevPage = super.hasPrevious();
        return this;
    }
 
    public boolean getHasNextPage() {
        return hasNextPage;
    }
 
    public void setHasNextPage(boolean hasNextPage) {
        this.hasNextPage = hasNextPage;
    }
 
    public boolean getHasPrevPage() {
        return hasPrevPage;
    }
 
    public void setHasPrevPage(boolean hasPrevPage) {
        this.hasPrevPage = hasPrevPage;
    }
 
    private boolean hasNextPage(long currentPage, long totalPage) {
        return currentPage < totalPage && totalPage != 0;
    }
 
    public long getStartIndex() {
        return startIndex;
    }
 
    public void setStartIndex(long startIndex) {
        this.startIndex = startIndex;
    }
}