package com.bohuikeji.frame.module.admin.entity.web;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bohuikeji.frame.module.admin.base.EntityBase;
import com.bohuikeji.frame.module.admin.base.InterfaceBase;

import java.util.List;

/**
 * 用于支撑Bootstrap-Table数据源格式，支持组合条件查询、分页查询
 * @param <T>
 */
public class TableData<T extends EntityBase<T>> extends InterfaceBase {
    private Long total;
    List<T> rows;

    public TableData(){
        this.total=0L;
    }
    public TableData(Long total, List<T> rows){
        this.total=total;
        this.rows=rows;
    }

    public Long getTotal() {
        return total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public List<T> getRows() {
        return rows;
    }

    public void setRows(List<T> rows) {
        this.rows = rows;
    }
    public static <T> TableData success(IPage<T> page){
        return new TableData(page.getTotal(),page.getRecords());
    }
}
