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.CmcContractPayment;
import com.ruoyi.oa.service.ICmcContractPaymentService;
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/contractPayment")
public class CmcContractPaymentController extends BaseController
{
    @Autowired
    private ICmcContractPaymentService cmcContractPaymentService;

    /**
     * 查询cmc合同回款列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmcContractPayment cmcContractPayment)
    {
        startPage();
        List<CmcContractPayment> list = cmcContractPaymentService.selectCmcContractPaymentList(cmcContractPayment);
        return getDataTable(list);
    }

    /**
     * 导出cmc合同回款列表
     */
    @Log(title = "cmc合同回款", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcContractPayment cmcContractPayment)
    {
        List<CmcContractPayment> list = cmcContractPaymentService.selectCmcContractPaymentList(cmcContractPayment);
        ExcelUtil<CmcContractPayment> util = new ExcelUtil<CmcContractPayment>(CmcContractPayment.class);
        util.exportExcel(response, list, "cmc合同回款数据");
    }

    /**
     * 获取cmc合同回款详细信息
     */
    @GetMapping(value = "/{contractId}")
    public AjaxResult getInfo(@PathVariable("contractId") String contractId)
    {
        return success(cmcContractPaymentService.selectCmcContractPaymentByContractId(contractId));
    }

    /**
     * 新增cmc合同回款
     */
    @Log(title = "cmc合同回款", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcContractPayment cmcContractPayment)
    {
        return toAjax(cmcContractPaymentService.insertCmcContractPayment(cmcContractPayment));
    }

    /**
     * 修改cmc合同回款
     */
    @Log(title = "cmc合同回款", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcContractPayment cmcContractPayment)
    {
        return toAjax(cmcContractPaymentService.updateCmcContractPayment(cmcContractPayment));
    }

    /**
     * 删除cmc合同回款
     */
    @Log(title = "cmc合同回款", businessType = BusinessType.DELETE)
	@DeleteMapping("/{contractIds}")
    public AjaxResult remove(@PathVariable String[] contractIds)
    {
        return success(cmcContractPaymentService.deleteCmcContractPaymentByContractIds(contractIds));
    }
}
