package tech.easyflow.admin.controller.ai;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.alibaba.fastjson2.JSONObject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.easyflow.admin.service.ai.WorkflowDesignerOptionService;
import tech.easyflow.common.domain.Result;

import java.math.BigInteger;

/**
 * 工作流节点兼容接口。
 */
@RequestMapping("/api/v1/workflowNode")
@RestController
public class WorkFlowNodeController {

    private final WorkflowDesignerOptionService workflowDesignerOptionService;

    /**
     * 创建工作流节点兼容控制器。
     *
     * @param workflowDesignerOptionService 工作流设计器选项服务
     */
    public WorkFlowNodeController(WorkflowDesignerOptionService workflowDesignerOptionService) {
        this.workflowDesignerOptionService = workflowDesignerOptionService;
    }

    /**
     * 查询子流程输入输出定义。
     *
     * @param currentId 当前工作流 ID
     * @param workflowId 子流程 ID
     * @return 子流程节点配置
     * @deprecated 请使用 {@code /api/v1/workflow/designer/childWorkflow}
     */
    @Deprecated
    @GetMapping("/getChainParams")
    @SaCheckPermission("/api/v1/workflow/query")
    public Result<JSONObject> getChainParams(BigInteger currentId, BigInteger workflowId) {
        return Result.ok(workflowDesignerOptionService.getChildWorkflowNodeData(currentId, workflowId));
    }
}
