package com.daya.live_teaching.model;

/**
 * 网络请求结果基础类
 *
 * @param <R> 请求结果的实体类
 */
public class Result<R> {
    private R data;
    private int errCode;
    private int code;
    private String nowTime;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    private String errDetail;

    private String errMsg;

    public R getData() {
        return data;
    }

    public void setData(R data) {
        this.data = data;
    }

    public int getErrCode() {
        return errCode;
    }

    public void setErrCode(int errCode) {
        this.errCode = errCode;
    }

    public String getErrDetail() {
        return errDetail;
    }

    public void setErrDetail(String errDetail) {
        this.errDetail = errDetail;
    }

    public String getErrMsg() {
        return errMsg;
    }

    public void setErrMsg(String errMsg) {
        this.errMsg = errMsg;
    }

    /**
     * 获取请求结果中的的实体类
     *
     * @return R
     */
    public R getDataResult() {
        if (data != null) {
            return data;
        }
        return null;
    }

    public static class Data<R> {
        public R result;
        public R data;

        public R getResult() {
            return data;
        }

        public void setResult(R result) {
            this.result = result;
            this.data = result;
        }
    }
}
