package cn.com.ty.lift.ud.common;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
public abstract class BasePageQuery {

    @ApiModelProperty(value = "页")
    private long pageNum = 1;

    @ApiModelProperty(value = "每一页多少条数据")
    private long pageSize = 10;

    public abstract Wrapper condition();

    public abstract IPage page();

    @ApiModelProperty("排序对象")
    private Sorting sort;

    // 用于原生mybatis分页
    public long getPageIndex() {
        return pageNum > 0 ? (pageNum - 1) * pageSize : 0;
    }
}
