package com.sckw.report.service.param;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

/**
 * @author yzc
 * @desc 分页请求参数
 * @date 2023/7/17 0010
 */
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
public class SpringDataPageAble implements Pageable {

    private Integer pageNumber = 1;
    private Integer pageSize = 10;
    private Sort sort;

    public void setSort(Sort sort) {
        this.sort = sort;
    }

    // 当前页面
    @Override
    public int getPageNumber() {
        return this.pageNumber;
    }

    // 每一页显示的条数

    @Override
    public int getPageSize() {
        return this.pageSize;
    }

    // 第二页所需要增加的数量

    @Override
    public long getOffset() {
        return (long) (getPageNumber() - 1) * getPageSize();
    }

    @Override
    public Sort getSort() {
        return sort;
    }

    @Override
    public Pageable next() {
        return null;
    }

    @Override
    public Pageable previousOrFirst() {
        return null;
    }

    @Override
    public Pageable first() {
        return null;
    }

    @Override
    public Pageable withPage(int pageNumber) {
        return null;
    }

    @Override
    public boolean hasPrevious() {
        return false;
    }
}
