package com.ruoyi.web.controller.oa;

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.oa.domain.CmcContract;
import com.ruoyi.oa.service.ICmcContractService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * cmc合同评审Controller
 * 
 * @author cmc
 * @date 2024-03-15
 */
@RestController
@RequestMapping("/oa/contract")
public class CmcContractController extends BaseController
{
    @Autowired
    private ICmcContractService cmcContractService;

    /**
     * 查询cmc合同评审列表
     */
    @PreAuthorize("@ss.hasPermi('oa:contract:list')")
    @GetMapping("/list")
    public TableDataInfo list(CmcContract cmcContract)
    {
        startPage();
        List<CmcContract> list = cmcContractService.selectCmcContractList(cmcContract);
        return getDataTable(list);
    }

    /**
     * 导出cmc合同评审列表
     */
    @PreAuthorize("@ss.hasPermi('oa:contract:export')")
    @Log(title = "cmc合同评审", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcContract cmcContract)
    {
        List<CmcContract> list = cmcContractService.selectCmcContractList(cmcContract);
        ExcelUtil<CmcContract> util = new ExcelUtil<CmcContract>(CmcContract.class);
        util.exportExcel(response, list, "cmc合同评审数据");
    }

    /**
     * 获取cmc合同评审详细信息
     */
    @PreAuthorize("@ss.hasPermi('oa:contract:query')")
    @GetMapping(value = "/{contractId}")
    public AjaxResult getInfo(@PathVariable("contractId") String contractId)
    {
        return success(cmcContractService.selectCmcContractByContractId(contractId));
    }

    /**
     * 新增cmc合同评审
     */
    @PreAuthorize("@ss.hasPermi('oa:contract:add')")
    @Log(title = "cmc合同评审", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcContract cmcContract)
    {
        return toAjax(cmcContractService.insertCmcContract(cmcContract));
    }

    /**
     * 修改cmc合同评审
     */
    @PreAuthorize("@ss.hasPermi('oa:contract:edit')")
    @Log(title = "cmc合同评审", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcContract cmcContract)
    {
        return toAjax(cmcContractService.updateCmcContract(cmcContract));
    }

    /**
     * 删除cmc合同评审
     */
    @PreAuthorize("@ss.hasPermi('oa:contract:remove')")
    @Log(title = "cmc合同评审", businessType = BusinessType.DELETE)
	@DeleteMapping("/{contractIds}")
    public AjaxResult remove(@PathVariable String[] contractIds)
    {
        return toAjax(cmcContractService.deleteCmcContractByContractIds(contractIds));
    }
}
