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

/**
 * cmc现场开支Controller
 * 
 * @author cmc
 * @date 2025-05-09
 */
@RestController
@RequestMapping("/oa/budgetSite")
public class CmcBudgetSiteController extends BaseController
{
    @Autowired
    private ICmcBudgetSiteService cmcBudgetSiteService;

    /**
     * 查询cmc现场开支列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmcBudgetSite cmcBudgetSite)
    {
        startPage();
        List<CmcBudgetSite> list = cmcBudgetSiteService.selectCmcBudgetSiteList(cmcBudgetSite);
        return getDataTable(list);
    }

    /**
     * 导出cmc现场开支列表
     */
    @Log(title = "cmc现场开支", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcBudgetSite cmcBudgetSite)
    {
        List<CmcBudgetSite> list = cmcBudgetSiteService.selectCmcBudgetSiteList(cmcBudgetSite);
        ExcelUtil<CmcBudgetSite> util = new ExcelUtil<CmcBudgetSite>(CmcBudgetSite.class);
        util.exportExcel(response, list, "cmc现场开支数据");
    }

    /**
     * 获取cmc现场开支详细信息
     */
    @GetMapping(value = "/{expenseId}")
    public AjaxResult getInfo(@PathVariable("expenseId") Long expenseId)
    {
        return success(cmcBudgetSiteService.selectCmcBudgetSiteByExpenseId(expenseId));
    }

    /**
     * 新增cmc现场开支
     */
    @Log(title = "cmc现场开支", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcBudgetSite cmcBudgetSite)
    {
        return toAjax(cmcBudgetSiteService.insertCmcBudgetSite(cmcBudgetSite));
    }

    /**
     * 修改cmc现场开支
     */
    @Log(title = "cmc现场开支", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcBudgetSite cmcBudgetSite)
    {
        return toAjax(cmcBudgetSiteService.updateCmcBudgetSite(cmcBudgetSite));
    }

    /**
     * 删除cmc现场开支
     */
    @Log(title = "cmc现场开支", businessType = BusinessType.DELETE)
	@DeleteMapping("/{budgetIds}")
    public AjaxResult remove(@PathVariable String[] budgetIds)
    {
        return success(cmcBudgetSiteService.deleteCmcBudgetSiteByExpenseIds(budgetIds));
    }
}
