package com.fdkankan.db.response;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PageInfo<T> {

    private long pageNum;

    private long pageSize;

    private long total;

    private T list;

    public static PageInfo PageInfo(Page page){
        return PageInfo.builder()
            .pageNum(page.getCurrent())
            .pageSize(page.getSize())
            .total(page.getTotal())
            .list(page.getRecords())
            .build();
    }

}
