package com.cmvr.test.flow.runtime.message;

import com.alibaba.fastjson2.JSONObject;
import lombok.Data;

/**
 * 单个节点的执行结果
 */
@Data
public class TaskNodeExecuteResult {

    /** 是否成功执行 */
    private boolean success;

    /** 输出参数（传递给下一个节点） */
    private JSONObject outputParams;

    /** 错误信息（如果执行失败） */
    private String errorMsg;

    public static TaskNodeExecuteResult success(JSONObject output) {
        TaskNodeExecuteResult result = new TaskNodeExecuteResult();
        result.setSuccess(true);
        result.setOutputParams(output);
        return result;
    }

    public static TaskNodeExecuteResult success() {
        TaskNodeExecuteResult result = new TaskNodeExecuteResult();
        result.setOutputParams(new JSONObject());
        result.setSuccess(true);
        return result;
    }

    public static TaskNodeExecuteResult failure(String msg) {
        TaskNodeExecuteResult result = new TaskNodeExecuteResult();
        result.setSuccess(false);
        result.setErrorMsg(msg);
        return result;
    }
}
