package com.yxcheng.token.common.model;

import com.yxcheng.token.common.enumutil.ResultEnum;

/**
 * Created by waitupon17 on 2017/2/16.
 */
public class CrRpcResult<T> {
    private String code = "0";

    private String message = "成功";

    private T data;

    public CrRpcResult()
    {
    }

    private T error(String code, String message) {
        this.code = code;
        this.message = message;
        return (T)this;
    }

    public CrRpcResult(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public CrRpcResult(String code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public T errorResponse(ResultEnum resultEnum) {
        return error(resultEnum.getCode(), resultEnum.getMessage());
    }


    public String getCode()
    {
        return code;
    }

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

    public String getMessage()
    {
        return message;
    }

    public void setMessage(String message)
    {
        this.message = message;
    }

    public T getData() {
        return data;
    }

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


    public boolean isSuccess(){
        return "0".equals(code);
    }

}
