package com.crm.rely.backend.core.entity.base;

public class PageEntity {
    private int current;

    private int row;

    private int offset;

    public PageEntity(int current, int row) {
        super();
        this.current = current;
        this.row = row;
    }

    public PageEntity() {
        super();
    }

    public int getCurrent() {
        return current;
    }

    public void setCurrent(int current) {

        if (current <= 0) {
            current = 1;
        }
        this.current = current;
    }

    public int getRow() {
        if (row <= 0) {
            this.row = 20;
        } else if (row >= 100) {
            this.row = 100;
        }
        return this.row;
    }

    public void setRow(int row) {
        this.row = row;
    }

    public int getOffset() {
        offset = offsetCurrent(current, row);
        return offset;
    }

    private static int offsetCurrent(int current, int row) {
        return current > 0 ? (current - 1) * row : 0;
    }

}
