package com.zkqy.execution.produce.dispersed.controller;

import javax.servlet.http.HttpServletResponse;

import com.zkqy.common.utils.poi.ExcelUtil;
import com.zkqy.execution.produce.dispersed.entity.BpmExecuteNodeForm;
import com.zkqy.execution.produce.dispersed.service.IBpmExecuteNodeFormService;
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.zkqy.common.annotation.Log;
import com.zkqy.common.core.controller.BaseController;
import com.zkqy.common.core.domain.AjaxResult;
import com.zkqy.common.enums.BusinessType;
import com.zkqy.common.core.page.TableDataInfo;

import java.util.List;

/**
 * 执行节点单Controller
 *
 * @author zkqy
 * @date 2023-12-07
 */
@RestController
@RequestMapping("/system/form")
public class BpmExecuteNodeFormController extends BaseController {
    @Autowired
    private IBpmExecuteNodeFormService bpmExecuteNodeFormService;

    /**
     * 查询执行节点单列表
     */
    @PreAuthorize("@ss.hasPermi('system:form:list')")
    @GetMapping("/list")
    public TableDataInfo list(BpmExecuteNodeForm bpmExecuteNodeForm) {
        startPage();
        List<BpmExecuteNodeForm> list = bpmExecuteNodeFormService.selectBpmExecuteNodeFormList(bpmExecuteNodeForm);
        return getDataTable(list);
    }

    /**
     * 导出执行节点单列表
     */
    @PreAuthorize("@ss.hasPermi('system:form:export')")
    @Log(title = "执行节点单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BpmExecuteNodeForm bpmExecuteNodeForm) {
        List<BpmExecuteNodeForm> list = bpmExecuteNodeFormService.selectBpmExecuteNodeFormList(bpmExecuteNodeForm);
        ExcelUtil<BpmExecuteNodeForm> util = new ExcelUtil<BpmExecuteNodeForm>(BpmExecuteNodeForm.class);
        util.exportExcel(response, list, "执行节点单数据");
    }

    /**
     * 获取执行节点单详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:form:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(bpmExecuteNodeFormService.selectBpmExecuteNodeFormById(id));
    }

    /**
     * 新增执行节点单
     */
    @PreAuthorize("@ss.hasPermi('system:form:add')")
    @Log(title = "执行节点单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BpmExecuteNodeForm bpmExecuteNodeForm) {
        return toAjax(bpmExecuteNodeFormService.insertBpmExecuteNodeForm(bpmExecuteNodeForm));
    }

    /**
     * 修改执行节点单
     */
    @PreAuthorize("@ss.hasPermi('system:form:edit')")
    @Log(title = "执行节点单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BpmExecuteNodeForm bpmExecuteNodeForm) {
        return toAjax(bpmExecuteNodeFormService.updateBpmExecuteNodeForm(bpmExecuteNodeForm));
    }

    /**
     * 删除执行节点单
     */
    @PreAuthorize("@ss.hasPermi('system:form:remove')")
    @Log(title = "执行节点单", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(bpmExecuteNodeFormService.deleteBpmExecuteNodeFormByIds(ids));
    }
}
