package com.ruoyi.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.cs.domain.CsApprovalInfo;
import com.ruoyi.cs.service.ICsApprovalInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 审核流程发起Controller
 * 
 * @author cc
 * @date 2024-04-30
 */
@RestController
@RequestMapping("/cs/csApprovalInfo")
public class CsApprovalInfoController extends BaseController
{
    @Autowired
    private ICsApprovalInfoService csApprovalInfoService;

    /**
     * 查询审核流程发起列表
     */
    @PreAuthorize("@ss.hasPermi('cs:csApprovalInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(CsApprovalInfo csApprovalInfo)
    {
        startPage();
        List<CsApprovalInfo> list = csApprovalInfoService.selectCsApprovalInfoList(csApprovalInfo);
        return getDataTable(list);
    }

    /**
     * 导出审核流程发起列表
     */
    @PreAuthorize("@ss.hasPermi('cs:csApprovalInfo:export')")
    @Log(title = "审核流程发起", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CsApprovalInfo csApprovalInfo)
    {
        List<CsApprovalInfo> list = csApprovalInfoService.selectCsApprovalInfoList(csApprovalInfo);
        ExcelUtil<CsApprovalInfo> util = new ExcelUtil<CsApprovalInfo>(CsApprovalInfo.class);
        util.exportExcel(response, list, "审核流程发起数据");
    }

    /**
     * 获取审核流程发起详细信息
     */
    @PreAuthorize("@ss.hasPermi('cs:csApprovalInfo:query')")
    @GetMapping(value = "/{approvalInfoId}")
    public AjaxResult getInfo(@PathVariable("approvalInfoId") String approvalInfoId)
    {
        return AjaxResult.success(csApprovalInfoService.selectCsApprovalInfoByApprovalInfoId(approvalInfoId));
    }

    /**
     * 新增审核流程发起
     */
    @PreAuthorize("@ss.hasPermi('cs:csApprovalInfo:add')")
    @Log(title = "审核流程发起", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CsApprovalInfo csApprovalInfo)
    {
        return toAjax(csApprovalInfoService.insertCsApprovalInfo(csApprovalInfo));
    }

    /**
     * 修改审核流程发起
     */
    @PreAuthorize("@ss.hasPermi('cs:csApprovalInfo:edit')")
    @Log(title = "审核流程发起", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CsApprovalInfo csApprovalInfo)
    {
        return toAjax(csApprovalInfoService.updateCsApprovalInfo(csApprovalInfo));
    }

    /**
     * 删除审核流程发起
     */
    @PreAuthorize("@ss.hasPermi('cs:csApprovalInfo:remove')")
    @Log(title = "审核流程发起", businessType = BusinessType.DELETE)
	@DeleteMapping("/{approvalInfoIds}")
    public AjaxResult remove(@PathVariable String[] approvalInfoIds)
    {
        return toAjax(csApprovalInfoService.deleteCsApprovalInfoByApprovalInfoIds(approvalInfoIds));
    }


}
