package com.aiotagro.common.core.web.domain;

import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;



@Data
@EqualsAndHashCode(callSuper=false)
public class PageResultResponse<T> extends BaseResponse{
	 /**
     * 业务状态编码
     */
    private int code = 200;
    /**
     * 消息内容
     */
    private String msg = "success"; 
    TableData<T> data;
   
    public PageResultResponse(int code, String msg) {
    	this.code = code;
    	this.msg = msg ;	
    }
    public PageResultResponse(long total, List<T> rows) {
        this.data = new TableData<T>(total, rows);
    }

    public PageResultResponse() {
        this.data = new TableData<T>();
    }

    public PageResultResponse(Integer type, long total, List<T> rows) {
        this.data = new TableData<T>(type, total, rows);
    }

    PageResultResponse<T> total(int total) {
        this.data.setTotal(total);
        return this;
    }

    PageResultResponse<T> total(List<T> rows) {
        this.data.setRows(rows);
        return this;
    }

    public TableData<T> getData() {
        return data;
    }

    public void setData(TableData<T> data) {
        this.data = data;
    }

    @SuppressWarnings("hiding")
	public class TableData<T> {
        long total;
        List<?> rows;
		public TableData(long total, List<?> rows) {
            this.total = total;
            this.rows = rows;
        }
        public TableData(Integer type ,long total, List<?> rows) {
            this.total = total;
            this.rows = rows;
        }
        
        public TableData() {
        }

        public long getTotal() {
            return total;
        }

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

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

        public void setRows(List<?> rows) {
            this.rows = rows;
        }

    }
}
