package com.gic.haoban.manage.api.dto.statistics;

import com.gic.api.base.commons.Constant;
import org.apache.commons.collections.CollectionUtils;

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

/**
 * @author BaiShan
 * @since 2022-01-06 14:15
 */
public class StatisticsDTO<T> implements Serializable {

    private static final long serialVersionUID = -1988630310497970760L;

    private List<T> data;
    private Boolean success;
    private Integer errorCode;
    private String errorInfo;
    private StatisticsPage page;
    private Integer space;

    public T getOne() {
        if (CollectionUtils.isEmpty(data)) {
            return null;
        }
        return data.get(Constant.NUMBER_0);
    }

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

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

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public Integer getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(Integer errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorInfo() {
        return errorInfo;
    }

    public void setErrorInfo(String errorInfo) {
        this.errorInfo = errorInfo;
    }

    public StatisticsPage getPage() {
        return page;
    }

    public void setPage(StatisticsPage page) {
        this.page = page;
    }

    public Integer getSpace() {
        return space;
    }

    public void setSpace(Integer space) {
        this.space = space;
    }

    @Override
    public String toString() {
        return "StatisticsDTO{" +
                "data=" + data +
                ", success=" + success +
                ", errorCode=" + errorCode +
                ", errorInfo='" + errorInfo + '\'' +
                ", page=" + page +
                ", space=" + space +
                '}';
    }
}
