package com.zksy.common.utils.result;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

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

/**
 * @Author sy
 * @Date 2022/04/11
 * @Description
 */
@ApiModel
public class PageReq {

    @ApiModelProperty(name = "pageNumber", value = "请求页数", required = true, dataType = "Integer", example = "1")
    @NotNull(message = "请求页数不为空")
    @Min(value = 1, message = "请求页数有误")
    private Integer pageNumber;

    @ApiModelProperty(name = "pageSize", value = "分页大小", required = true, dataType = "Integer", example = "10")
    @NotNull(message = "页数不为空")
    @Min(value = 1, message = "页数有误")
    private Integer pageSize;

    private Integer startRow;

    public PageReq() {

    }

    public Integer getPageNumber() {
        return pageNumber;
    }

    public void setPageNumber(Integer pageNumber) {
        this.pageNumber = pageNumber;
    }

    public Integer getPageSize() {
        return pageSize;
    }

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

    public Integer getStartRow() {
        if (pageNumber != null && pageSize != null) {
            this.startRow = (pageNumber - 1) * pageSize;
        }
        return startRow;
    }

    public void setStartRow(Integer startRow) {
        if (pageNumber != null && pageSize != null) {
            this.startRow = (pageNumber - 1) * pageSize;
        }
        this.startRow = startRow;
    }

    @Override
    public String toString() {
        return "[pageNumber:" + this.pageNumber + ",pageSize:" + this.pageSize + ",startRow:" + this.startRow + "]";
    }

}
