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.CmcBudgetDevice;
import com.ruoyi.oa.service.ICmcBudgetDeviceService;
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/budgetDevice")
public class CmcBudgetDeviceController extends BaseController
{
    @Autowired
    private ICmcBudgetDeviceService cmcBudgetDeviceService;

    /**
     * 查询cmc设备预算列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmcBudgetDevice cmcBudgetDevice)
    {
        startPage();
        List<CmcBudgetDevice> list = cmcBudgetDeviceService.selectCmcBudgetDeviceList(cmcBudgetDevice);
        return getDataTable(list);
    }

    /**
     * 导出cmc设备预算列表
     */
    @Log(title = "cmc设备预算", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcBudgetDevice cmcBudgetDevice)
    {
        List<CmcBudgetDevice> list = cmcBudgetDeviceService.selectCmcBudgetDeviceList(cmcBudgetDevice);
        ExcelUtil<CmcBudgetDevice> util = new ExcelUtil<CmcBudgetDevice>(CmcBudgetDevice.class);
        util.exportExcel(response, list, "cmc设备预算数据");
    }

    /**
     * 获取cmc设备预算详细信息
     */
    @GetMapping(value = "/{budgetId}")
    public AjaxResult getInfo(@PathVariable("budgetId") String budgetId)
    {
        return success(cmcBudgetDeviceService.selectCmcBudgetDeviceByBudgetId(budgetId));
    }

    /**
     * 新增cmc设备预算
     */
    @Log(title = "cmc设备预算", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcBudgetDevice cmcBudgetDevice)
    {
        return toAjax(cmcBudgetDeviceService.insertCmcBudgetDevice(cmcBudgetDevice));
    }

    /**
     * 修改cmc设备预算
     */
    @Log(title = "cmc设备预算", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcBudgetDevice cmcBudgetDevice)
    {
        return toAjax(cmcBudgetDeviceService.updateCmcBudgetDevice(cmcBudgetDevice));
    }

    /**
     * 删除cmc设备预算
     */
    @Log(title = "cmc设备预算", businessType = BusinessType.DELETE)
	@DeleteMapping("/{budgetIds}")
    public AjaxResult remove(@PathVariable String[] budgetIds)
    {
        return success(cmcBudgetDeviceService.deleteCmcBudgetDeviceByBudgetIds(budgetIds));
    }
}
