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

/**
 * 实际回款Controller
 * 
 * @author cmc
 * @date 2025-02-12
 */
@RestController
@RequestMapping("/oa/contractPaid")
public class CmcContractPaidController extends BaseController
{
    @Autowired
    private ICmcContractPaidService cmcContractPaidService;

    /**
     * 查询实际回款列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmcContractPaid cmcContractPaid)
    {
        startPage();
        List<CmcContractPaid> list = cmcContractPaidService.selectCmcContractPaidList(cmcContractPaid);
        return getDataTable(list);
    }

    /**
     * 导出实际回款列表
     */
    @Log(title = "实际回款", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcContractPaid cmcContractPaid)
    {
        List<CmcContractPaid> list = cmcContractPaidService.selectCmcContractPaidList(cmcContractPaid);
        ExcelUtil<CmcContractPaid> util = new ExcelUtil<CmcContractPaid>(CmcContractPaid.class);
        util.exportExcel(response, list, "实际回款数据");
    }

    /**
     * 获取实际回款详细信息
     */
    @GetMapping(value = "/{paidId}")
    public AjaxResult getInfo(@PathVariable("paidId") Long paidId)
    {
        return success(cmcContractPaidService.selectCmcContractPaidByPaidId(paidId));
    }

    /**
     * 新增实际回款
     */
    @Log(title = "实际回款", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcContractPaid cmcContractPaid)
    {
        return toAjax(cmcContractPaidService.insertCmcContractPaid(cmcContractPaid));
    }

    /**
     * 修改实际回款
     */
    @Log(title = "实际回款", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcContractPaid cmcContractPaid)
    {
        return toAjax(cmcContractPaidService.updateCmcContractPaid(cmcContractPaid));
    }

    /**
     * 删除实际回款
     */
    @Log(title = "实际回款", businessType = BusinessType.DELETE)
	@DeleteMapping("/{contractIds}")
    public AjaxResult remove(@PathVariable String[] contractIds)
    {
        return success(cmcContractPaidService.deleteCmcContractPaidByContractIds(contractIds));
    }
}
