package com.ruoyi.interfaces.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.interfaces.domain.MdAppFlow;
import com.ruoyi.interfaces.service.IMdAppFlowService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 模型应用流程Controller
 * 
 * @author 朱得糠
 * @date 2025-08-19
 */
@RestController
@RequestMapping("/app/flow")
public class MdAppFlowController extends BaseController
{
    @Autowired
    private IMdAppFlowService mdAppFlowService;

    /**
     * 查询模型应用流程列表
     */
    @GetMapping("/list")
    public AjaxResult list(MdAppFlow mdAppFlow)
    {
        List<MdAppFlow> list = mdAppFlowService.selectMdAppFlowList(mdAppFlow);
        return success(list);
    }

    /**
     * 导出模型应用流程列表
     */
    @Log(title = "模型应用流程", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MdAppFlow mdAppFlow)
    {
        List<MdAppFlow> list = mdAppFlowService.selectMdAppFlowList(mdAppFlow);
        ExcelUtil<MdAppFlow> util = new ExcelUtil<MdAppFlow>(MdAppFlow.class);
        util.exportExcel(response, list, "模型应用流程数据");
    }



    /**
     * 获取模型应用流程详细信息
     */
    @GetMapping(value = "/{flowId}")
    public AjaxResult getInfo(@PathVariable("flowId") Long flowId)
    {
        return success(mdAppFlowService.selectMdAppFlowByFlowId(flowId));
    }

    /**
     * 新增模型应用流程
     */
    @Log(title = "模型应用流程", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MdAppFlow mdAppFlow)
    {
        return toAjax(mdAppFlowService.insertMdAppFlow(mdAppFlow));
    }

    /**
     * 修改模型应用流程
     */
    @Log(title = "模型应用流程", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MdAppFlow mdAppFlow)
    {
        return toAjax(mdAppFlowService.updateMdAppFlow(mdAppFlow));
    }

    /**
     * 删除模型应用流程
     */
    @Log(title = "模型应用流程", businessType = BusinessType.DELETE)
	@DeleteMapping("/{flowIds}")
    public AjaxResult remove(@PathVariable Long[] flowIds)
    {
        return toAjax(mdAppFlowService.deleteMdAppFlowByFlowIds(flowIds));
    }
}
