package com.trs.project.util;


public class PageUtil {
    private Integer pageIndex;
    private Integer pageSize;
    private Integer pageTotal;


    private long total;

    public void setPageNums(long total) {

        Double nums = total/(double)this.pageSize;
        String[] right = nums.toString().split("\\.");

        if (Integer.parseInt(right[1]) > 0){
           this.pageTotal =  Integer.parseInt(right[0]) + 1;
           return;
        }
        this.pageTotal = Integer.parseInt(right[0]);
    }


    public Integer getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(Integer pageIndex) {
        this.pageIndex = pageIndex;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public void setPageTotal(Integer pageTotal) {
        this.pageTotal = pageTotal;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public Integer getPageTotal() {
        return pageTotal;
    }


    @Override
    public String toString() {
        return "PageUtil{" +
                "pageIndex=" + pageIndex +
                ", pageSize=" + pageSize +
                ", pageTotal=" + pageTotal +
                '}';
    }
}
