package com.yiqi.common.core.domain;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * @author xiaohei
 * @date 2023/7/19
 */
public class PageVO {
    @NotNull
    @ApiModelProperty(value = "每页的大小,默认10")
    @Min(value = 1,message = "查询数量最小为1条")
    private int pageSize = 10;

    @NotNull
    @Min(value = 1,message = "页码最小为1")
    @ApiModelProperty(value = "页码，默认1")
    private int pageNum = 1;

    public int getStartRow() {
        int startRow = (pageNum - 1) * pageSize;
        if (startRow <= 0) startRow = 0;
        return startRow;
    }

    public int getPageSize() {
        return pageSize;
    }

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

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }
}
