package net.educoder.ecsonar.model;

import java.util.List;

/**
 * @Author: youys
 * @Date: 2022/1/18
 * @Description:
 */
public class RollPage<T> {

    private static final Integer DEFAULT_PAGE_SIZE = 50;

    private Integer pageSize;

    private Integer currentPage = 1;

    private Integer pageSum = 0;

    private Integer recordSum = 0;

    private List<T> recordList;

    public RollPage() {
        pageSize = DEFAULT_PAGE_SIZE;
    }

    public Integer getPageSum() {
        if (this.pageSum == 0) {
            this.pageSum = (int) Math.ceil(this.recordSum / this.pageSize) + ((this.recordSum % this.pageSize == 0) ? 0 : 1);
        }
        return pageSum;
    }


    public Integer getPageSize() {
        return pageSize;
    }

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

    public Integer getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(Integer currentPage) {
        this.currentPage = currentPage;
    }

    public void setPageSum(Integer pageSum) {
        this.pageSum = pageSum;
    }

    public Integer getRecordSum() {
        return recordSum;
    }

    public void setRecordSum(Integer recordSum) {
        this.recordSum = recordSum;
    }

    public List<T> getRecordList() {
        return recordList;
    }

    public void setRecordList(List<T> recordList) {
        this.recordList = recordList;
    }
}
