package com.ruoyi.web.controller.oa;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.oa.domain.CmcProcureApproval;
import com.ruoyi.oa.service.ICmcProcureApprovalService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 采购审批Controller
 * 
 * @author cmc
 * @date 2024-09-18
 */
@RestController
@RequestMapping("/oa/procureApproval")
public class CmcProcureApprovalController extends BaseController
{
    @Autowired
    private ICmcProcureApprovalService cmcProcureApprovalService;

    /**
     * 查询采购审批列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmcProcureApproval cmcProcureApproval)
    {
        startPage();
        List<CmcProcureApproval> list = cmcProcureApprovalService.selectCmcProcureApprovalList(cmcProcureApproval);
        return getDataTable(list);
    }

    /**
     * 导出采购审批列表
     */
    @Log(title = "采购审批", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcProcureApproval cmcProcureApproval)
    {
        List<CmcProcureApproval> list = cmcProcureApprovalService.selectCmcProcureApprovalList(cmcProcureApproval);
        ExcelUtil<CmcProcureApproval> util = new ExcelUtil<CmcProcureApproval>(CmcProcureApproval.class);
        util.exportExcel(response, list, "采购审批数据");
    }

    /**
     * 获取采购审批详细信息
     */
    @GetMapping(value = "/{procureApplyId}")
    public AjaxResult getInfo(@PathVariable("procureApplyId") String procureApplyId)
    {
        return success(cmcProcureApprovalService.selectCmcProcureApprovalByProcureApplyId(procureApplyId));
    }

    /**
     * 新增采购审批
     */
    @Log(title = "采购审批", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcProcureApproval cmcProcureApproval)
    {
        return toAjax(cmcProcureApprovalService.insertCmcProcureApproval(cmcProcureApproval));
    }

    /**
     * 修改采购审批
     */
    @Log(title = "采购审批", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcProcureApproval cmcProcureApproval)
    {
        return toAjax(cmcProcureApprovalService.updateCmcProcureApproval(cmcProcureApproval));
    }

    /**
     * 删除采购审批
     */
    @Log(title = "采购审批", businessType = BusinessType.DELETE)
	@DeleteMapping("/{procureApplyIds}")
    public AjaxResult remove(@PathVariable String[] procureApplyIds)
    {
        return success(cmcProcureApprovalService.deleteCmcProcureApprovalByProcureApplyIds(procureApplyIds));
    }
}
