package cn.reghao.autodop.common.msg.rpc;

import lombok.AllArgsConstructor;
import lombok.Data;

import static cn.reghao.jdkutil.result.ResultStatus.*;

/**
 * RPC 调用结果
 *
 * @author reghao
 * @date 2020-09-07 23:04:16
 */
@Data
@AllArgsConstructor
public class RpcResult {
    // 0 - 成功 1 - 失败
    private int code;
    private String msg;
    private String jsonData;

    public static  RpcResult success(String jsonData) {
        return new RpcResult(SUCCESS.getCode(), SUCCESS.getMsg(), jsonData);
    }

    public static  RpcResult fail(String msg) {
        return new RpcResult(FAIL.getCode(), msg, null);
    }

    public static  RpcResult error(String msg) {
        return new RpcResult(ERROR.getCode(), msg, null);
    }
}
