package com.ruoyi.web.controller.bpm;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.system.entity.BpmNodeScriptRelevance;
import com.ruoyi.system.service.IBpmNodeScriptRelevanceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 流程节点脚本关联Controller
 *
 * @author hzh
 * @date 2023-10-26
 */
@RestController
@RequestMapping("/system/relevance")
@Api(value = "/system/relevance", description = "流程节点脚本关联-接口")
public class BpmNodeScriptRelevanceController extends BaseController
{
    @Autowired
    private IBpmNodeScriptRelevanceService bpmNodeScriptRelevanceService;

/**
 * 查询流程节点脚本关联列表
 */
@PreAuthorize("@ss.hasPermi('system:relevance:list')")
@GetMapping("/list")
@ApiOperation(value = "查询流程节点脚本关联列表")
    public TableDataInfo list(BpmNodeScriptRelevance bpmNodeScriptRelevance)
    {
        startPage();
        List<BpmNodeScriptRelevance> list = bpmNodeScriptRelevanceService.selectBpmNodeScriptRelevanceList(bpmNodeScriptRelevance);
        return getDataTable(list);
    }

    /**
     * 导出流程节点脚本关联列表
     */
    @PreAuthorize("@ss.hasPermi('system:relevance:export')")
    @Log(title = "流程节点脚本关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出流程节点脚本关联列表")
    public void export(HttpServletResponse response, BpmNodeScriptRelevance bpmNodeScriptRelevance)
    {
        List<BpmNodeScriptRelevance> list = bpmNodeScriptRelevanceService.selectBpmNodeScriptRelevanceList(bpmNodeScriptRelevance);
        ExcelUtil<BpmNodeScriptRelevance> util = new ExcelUtil<BpmNodeScriptRelevance>(BpmNodeScriptRelevance.class);
        util.exportExcel(response, list, "流程节点脚本关联数据");
    }

    /**
     * 获取流程节点脚本关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:relevance:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取流程节点脚本关联详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bpmNodeScriptRelevanceService.selectBpmNodeScriptRelevanceById(id));
    }

    /**
     * 新增流程节点脚本关联
     */
    @PreAuthorize("@ss.hasPermi('system:relevance:add')")
    @Log(title = "流程节点脚本关联", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增流程节点脚本关联")
    public AjaxResult add(@RequestBody List<BpmNodeScriptRelevance> bpmNodeScriptRelevance)
    {
        return toAjax(bpmNodeScriptRelevanceService.insertBpmNodeScriptRelevance(bpmNodeScriptRelevance));
    }

    /**
     * 修改流程节点脚本关联
     */
    @PreAuthorize("@ss.hasPermi('system:relevance:edit')")
    @Log(title = "流程节点脚本关联", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改流程节点脚本关联")
    public AjaxResult edit(@RequestBody List<BpmNodeScriptRelevance> bpmNodeScriptRelevance)
    {
        return toAjax(bpmNodeScriptRelevanceService.updateBpmNodeScriptRelevance(bpmNodeScriptRelevance));
    }

    /**
     * 删除流程节点脚本关联
     */
    @PreAuthorize("@ss.hasPermi('system:relevance:remove')")
    @Log(title = "流程节点脚本关联", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation(value = "删除流程节点脚本关联")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bpmNodeScriptRelevanceService.deleteBpmNodeScriptRelevanceByIds(ids));
    }
}
