package com.zcxk.core.mysql.pageing;

import com.github.pagehelper.Page;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * 自定义分页
 * @param <T>
 */
/**
 * @author Andy
 * @date 2021-07-22 11:03
 */
@Data
public class Pagination<T> implements Serializable {

    private static final long serialVersionUID = -4899829840696212229L;

    @ApiModelProperty("总记录数")
    private long total;

    @ApiModelProperty("结果集")
    private List<T> list;

    public Pagination(){

    }

    /**
     * 包装Page对象
     *
     * @param list
     */
    public Pagination(List<T> list) {
        Page page = (Page) list;
        this.list = page;
        this.total = page.getTotal();
    }


    public Pagination(List<T> list , long total){
        this.list = list ;
        this.total =total ;
    }
}
