package com.itsol.quantrivanphong.report.issue.common;

public class PagebleRequest implements Pageble {
    private Integer page;
    private Integer maxPageItem;
    private Sorter sorter;

    @Override
    public Integer getPage() {
        return this.page;
    }

    public PagebleRequest(Integer page, Integer maxPageItem, Sorter sorter) {
        this.page = page;
        this.maxPageItem = maxPageItem;
        this.sorter = sorter;
    }

    @Override
    public Integer getOffset() {
//        tính vị trí đầu của 1 page
        if (this.page != null && this.maxPageItem != null) {
            return ((this.page - 1) * this.maxPageItem);
        }
        return null;
    }

    @Override
    public Integer getLimit() {
        return (this.getOffset() + this.maxPageItem);
    }

    @Override
    public Sorter getSorter() {
        return this.sorter;
    }
}
