package com.ym.mec.education.base;

import com.ym.mec.education.enums.ReturnCodeEnum;
import javax.persistence.MappedSuperclass;
import java.io.Serializable;

/**
 * @author : chengp
 * @version V1.0
 * @Description: TODO
 * @date Date : 2019年09月25日 17:53
 */
@MappedSuperclass
public class BaseResponse<T> extends Response implements Serializable {
    protected T dataInfo;

    public BaseResponse() {
    }

    public T getDataInfo() {
        return this.dataInfo;
    }

    public void setDataInfo(final T dataInfo) {
        this.dataInfo = dataInfo;
    }

    @Override
    public String toString() {
        return "BaseResponse(super=" + super.toString() + ", dataInfo=" + this.getDataInfo() + ")";
    }

    public static BaseResponse success(Object dataInfo) {
        BaseResponse baseResponse = new BaseResponse<>();
        baseResponse.setReturnCode(ReturnCodeEnum.CODE_200.getCode());
        baseResponse.setMessage(ReturnCodeEnum.CODE_200.getValue());
        baseResponse.setDataInfo(dataInfo);
        return baseResponse;
    }
}
