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

/**
 * cmc车辆预算Controller
 * 
 * @author cmc
 * @date 2024-03-22
 */
@RestController
@RequestMapping("/oa/budgetCar")
public class CmcBudgetCarController extends BaseController
{
    @Autowired
    private ICmcBudgetCarService cmcBudgetCarService;

    /**
     * 查询cmc车辆预算列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmcBudgetCar cmcBudgetCar)
    {
        startPage();
        List<CmcBudgetCar> list = cmcBudgetCarService.selectCmcBudgetCarList(cmcBudgetCar);
        return getDataTable(list);
    }

    /**
     * 导出cmc车辆预算列表
     */
    @Log(title = "cmc车辆预算", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcBudgetCar cmcBudgetCar)
    {
        List<CmcBudgetCar> list = cmcBudgetCarService.selectCmcBudgetCarList(cmcBudgetCar);
        ExcelUtil<CmcBudgetCar> util = new ExcelUtil<CmcBudgetCar>(CmcBudgetCar.class);
        util.exportExcel(response, list, "cmc车辆预算数据");
    }

    /**
     * 获取cmc车辆预算详细信息
     */
    @GetMapping(value = "/{budgetId}")
    public AjaxResult getInfo(@PathVariable("budgetId") String budgetId)
    {
        return success(cmcBudgetCarService.selectCmcBudgetCarByBudgetId(budgetId));
    }

    /**
     * 新增cmc车辆预算
     */
    @Log(title = "cmc车辆预算", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcBudgetCar cmcBudgetCar)
    {
        return toAjax(cmcBudgetCarService.insertCmcBudgetCar(cmcBudgetCar));
    }

    /**
     * 修改cmc车辆预算
     */
    @Log(title = "cmc车辆预算", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcBudgetCar cmcBudgetCar)
    {
        return toAjax(cmcBudgetCarService.updateCmcBudgetCar(cmcBudgetCar));
    }

    /**
     * 删除cmc车辆预算
     */
    @Log(title = "cmc车辆预算", businessType = BusinessType.DELETE)
	@DeleteMapping("/{budgetCarIds}")
    public AjaxResult remove(@PathVariable String[] budgetCarIds)
    {
        return success(cmcBudgetCarService.deleteCmcBudgetCarByBudgetIds(budgetCarIds));
    }
}
