package com.ruoyi.interfaces.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.interfaces.domain.MdModelWorkflow;
import com.ruoyi.interfaces.service.MdModelWorkflowService;
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")
public class MdModelWorkflowController extends BaseController {

    @Autowired
    private MdModelWorkflowService mdModelWorkflowService;


    @ApiOperation(value = "新增/修改工作流")
    @PostMapping("")
    public AjaxResult save(@ApiParam(name = "mdModelWorkflow", value = "MdModelWorkflow", required = true) @RequestBody MdModelWorkflow mdModelWorkflow) {
        return AjaxResult.success(mdModelWorkflowService.saveOrUpdate(mdModelWorkflow));
    }

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

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

    @ApiOperation(value = "根据ID获取工作流（单表）")
    @GetMapping("/getByModelId/{modelId}")
    public AjaxResult getByModelId(
            @ApiParam(name = "modelId", value = "modelId", required = true)
            @PathVariable String modelId
    ) {
        return AjaxResult.success(mdModelWorkflowService.getByModelId(modelId));
    }

}
