package com.sunzee.model;

import com.google.gson.annotations.SerializedName;

/**
 * Http响应实体类
 * Created by MinKin.
 */
public class HttpResult<T> {

    private int code;
    private T data;
    @SerializedName("errmsg")
    private String errorMsg;

    public int getCode() {
        return code;
    }

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

    public T getData() {
        return data;
    }

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

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    /**
     * 是否请求成功（由服务器状态码决定）
     */
    public boolean isSuccess() {
        return code == 0;
    }

    @Override
    public String toString() {
        return "HttpResult{" +
                "code=" + code +
                ", data=" + data +
                ", errorMsg='" + errorMsg + '\'' +
                '}';
    }
}