/*
 * @Author: ysh
 * @Date: 2025-05-09 10:35:47
 * @LastEditors: 
 * @LastEditTime: 2025-05-16 11:23:17
 */
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.CmcBudgetOther;
import com.ruoyi.oa.service.ICmcBudgetOtherService;
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/budgetOther")
public class CmcBudgetOtherController extends BaseController
{
    @Autowired
    private ICmcBudgetOtherService cmcBudgetOtherService;

    /**
     * 查询cmc预算外开支列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmcBudgetOther cmcBudgetOther)
    {
        startPage();
        List<CmcBudgetOther> list = cmcBudgetOtherService.selectCmcBudgetOtherList(cmcBudgetOther);
        return getDataTable(list);
    }

    /**
     * 导出cmc预算外开支列表
     */
    @Log(title = "cmc预算外开支", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcBudgetOther cmcBudgetOther)
    {
        List<CmcBudgetOther> list = cmcBudgetOtherService.selectCmcBudgetOtherList(cmcBudgetOther);
        ExcelUtil<CmcBudgetOther> util = new ExcelUtil<CmcBudgetOther>(CmcBudgetOther.class);
        util.exportExcel(response, list, "cmc预算外开支数据");
    }

    /**
     * 获取cmc预算外开支详细信息
     */
    @GetMapping(value = "/{expenseId}")
    public AjaxResult getInfo(@PathVariable("expenseId") Long expenseId)
    {
        return success(cmcBudgetOtherService.selectCmcBudgetOtherByExpenseId(expenseId));
    }

    /**
     * 新增cmc预算外开支
     */
    @Log(title = "cmc预算外开支", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcBudgetOther cmcBudgetOther)
    {
        return toAjax(cmcBudgetOtherService.insertCmcBudgetOther(cmcBudgetOther));
    }

    /**
     * 修改cmc预算外开支
     */
    @Log(title = "cmc预算外开支", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcBudgetOther cmcBudgetOther)
    {
        return toAjax(cmcBudgetOtherService.updateCmcBudgetOther(cmcBudgetOther));
    }

    /**
     * 删除cmc预算外开支
     */
    @Log(title = "cmc预算外开支", businessType = BusinessType.DELETE)
	@DeleteMapping("/{budgetId}")
    public AjaxResult remove(@PathVariable String[] budgetId)
    {
        return success(cmcBudgetOtherService.deleteCmcBudgetOtherByExpenseIds(budgetId));
    }
}
