package com.ruoyi.interfaces.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.interfaces.workflow.ExecutionResult;
import com.ruoyi.interfaces.workflow.WorkflowEngine;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author LinQiLong
 * @date 2025/7/16 10:08
 */
@RestController
@RequestMapping("/model/workflows")
public class WorkflowController extends BaseController {

    @Autowired
    private WorkflowEngine engine;

    @PostMapping("/{id}/execute")
    public AjaxResult executeWorkflow(@PathVariable Long id, @RequestBody Map<String, Object> input) {
        ExecutionResult result = engine.execute(id, input);
        return AjaxResult.success(result);
    }

    /**
     * 获取历史执行记录
     * @param id
     * @return
     */
    @GetMapping("/{id}/executions")
    public AjaxResult getExecutions(@PathVariable Long id) {
        return AjaxResult.success();
    }

}
