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

/**
 * cmc项目合同Controller
 * 
 * @author cmc
 * @date 2024-04-19
 */
@RestController
@RequestMapping("/oa/projectContract")
public class CmcProjectContractController extends BaseController
{
    @Autowired
    private ICmcProjectContractService cmcProjectContractService;

    /**
     * 查询cmc项目合同列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmcProjectContract cmcProjectContract)
    {
        startPage();
        List<CmcProjectContract> list = cmcProjectContractService.selectCmcProjectContractList(cmcProjectContract);
        return getDataTable(list);
    }

    /**
     * 导出cmc项目合同列表
     */
    @Log(title = "cmc项目合同", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcProjectContract cmcProjectContract)
    {
        List<CmcProjectContract> list = cmcProjectContractService.selectCmcProjectContractList(cmcProjectContract);
        ExcelUtil<CmcProjectContract> util = new ExcelUtil<CmcProjectContract>(CmcProjectContract.class);
        util.exportExcel(response, list, "cmc项目合同数据");
    }

    /**
     * 获取cmc项目合同详细信息
     */
    @GetMapping(value = "/{projectId}")
    public AjaxResult getInfo(@PathVariable("projectId") String projectId)
    {
        return success(cmcProjectContractService.selectCmcProjectContractByProjectId(projectId));
    }

    /**
     * 新增cmc项目合同
     */
    @Log(title = "cmc项目合同", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcProjectContract cmcProjectContract)
    {
        return toAjax(cmcProjectContractService.insertCmcProjectContract(cmcProjectContract));
    }

    /**
     * 修改cmc项目合同
     */
    @Log(title = "cmc项目合同", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcProjectContract cmcProjectContract)
    {
        return toAjax(cmcProjectContractService.updateCmcProjectContract(cmcProjectContract));
    }

    /**
     * 删除cmc项目合同
     */
    @Log(title = "cmc项目合同", businessType = BusinessType.DELETE)
	@DeleteMapping("/{contractIds}")
    public AjaxResult remove(@PathVariable String[] contractIds)
    {
        return success(cmcProjectContractService.deleteCmcProjectContractByContractIds(contractIds));
    }
    /**
     * 删除cmc项目合同
     */
    @Log(title = "cmc项目合同", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete/{projectIds}")
    public AjaxResult removeByProjectIds(@PathVariable String[] projectIds)
    {
        return success(cmcProjectContractService.deleteCmcProjectContractByProjectIds(projectIds));
    }
}
