package net.northking.cctp.se.script.core;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import net.northking.cctp.se.script.bean.ScriptStep;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 步骤执行结果
 */
@Data
public class StepExecuteResult {
    private String retId;   // 步骤执行结果id
    private String scriptId;    // 脚本id
    private String stepId;      // 步骤id
    private ScriptStep step;    // 步骤信息

    /**
     * 调用组件库
     */
    private String componentLib;
    /**
     * 调用组件命令
     */
    private String command;

    private String nextStepId;  // 下一步骤id
    private boolean success;    // 执行结果
    private boolean isExecuted; // 是否已经执行了
    private String msg; //
    private boolean finish;    //
    private String actualImgUri;    // 实际截图地址
    private String imgUri;          // 截图地址
    private String requestId;

    private String inputMsg;
    private List<StepExecuteResult> childResult;
    private long executeTime;
    private Object keywordReturn;
    @JsonIgnore
    private boolean afterLogicExec;

    private Map<String, Object> result = new HashMap<>();

    private Map<String, Object> paramMap = new HashMap<>();

    private Map<String, Object> output = new HashMap<>();

    private String outputMsg;

    public void addChildResult(StepExecuteResult stepResult) {
        if (childResult == null) {
            childResult = new ArrayList<>();
        }
        childResult.add(stepResult);
    }
}
