package com.bcrjl.miwifi.common.response;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.Data;

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

/**
 * @author yanqs
 */
@Data
public class BasePageList<T> implements Serializable {

    private long total;
    private long page;
    private long pageSize;
    private List<T> rows = Collections.emptyList();

    public static <T> BasePageList<T> of(IPage<T> page) {
        BasePageList<T> bladePage = new BasePageList<>();
        bladePage.setRows(page.getRecords());
        bladePage.setTotal(page.getTotal());
        bladePage.setPageSize(page.getSize());
        bladePage.setPage(page.getCurrent());
        return bladePage;
    }
}
