package com.ruoyi.interfaces.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.interfaces.domain.MdModelWorkflowExecution;
import com.ruoyi.interfaces.service.MdModelWorkflowExecutionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author lql
 * @date 2025-7-15
 */
@Api(value = "工作流执行记录", tags = "工作流执行记录")
@RestController
@RequestMapping("/model/workflow/execution")
public class MdModelWorkflowExecutionController extends BaseController {

    @Autowired
    private MdModelWorkflowExecutionService mdModelWorkflowExecutionService;


    @ApiOperation(value = "新增/修改工作流执行记录")
    @PostMapping("")
    public AjaxResult save(@ApiParam(name = "mdModelWorkflowExecution", value = "MdModelWorkflowExecution", required = true)
                           @RequestBody MdModelWorkflowExecution mdModelWorkflowExecution) {
        return AjaxResult.success(mdModelWorkflowExecutionService.saveOrUpdate(mdModelWorkflowExecution));
    }

    @ApiOperation(value = "根据ID删除工作流执行记录")
    @DeleteMapping(value = "/{id}")
    public AjaxResult delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
        return AjaxResult.success(mdModelWorkflowExecutionService.removeById(id));
    }

    @ApiOperation(value = "根据ID获取工作流执行记录（单表）")
    @GetMapping("/{id}")
    public AjaxResult get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
        return AjaxResult.success(mdModelWorkflowExecutionService.getById(id));
    }


}
