package com.muyu.common.core.web.page;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

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

/**
 * 表格分页数据对象
 *
 * @author muyu
 */

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DataPageResp<T> implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 总记录数
     */
    private long total;

    /**
     * 列表数据
     */
    private List<T> rows;

    public static <T> DataPageResp<T> of(PageQueryModel<T> pageQueryModel) {
        return new DataPageResp<>(pageQueryModel.getTotal(), pageQueryModel.getDataList());
    }
}
