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

/**
 * cmc耗材信息Controller
 * 
 * @author cmc
 * @date 2024-07-31
 */
@RestController
@RequestMapping("/oa/material")
public class CmcMaterialController extends BaseController
{
    @Autowired
    private ICmcMaterialService cmcMaterialService;

    /**
     * 查询cmc耗材信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmcMaterial cmcMaterial)
    {
        startPage();
        List<CmcMaterial> list = cmcMaterialService.selectCmcMaterialList(cmcMaterial);
        return getDataTable(list);
    }

    /**
     * 导出cmc耗材信息列表
     */
    @Log(title = "cmc耗材信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcMaterial cmcMaterial)
    {
        List<CmcMaterial> list = cmcMaterialService.selectCmcMaterialList(cmcMaterial);
        ExcelUtil<CmcMaterial> util = new ExcelUtil<CmcMaterial>(CmcMaterial.class);
        util.exportExcel(response, list, "cmc耗材信息数据");
    }

    /**
     * 获取cmc耗材信息详细信息
     */
    @GetMapping(value = "/{materialId}")
    public AjaxResult getInfo(@PathVariable("materialId") Integer materialId)
    {
        return success(cmcMaterialService.selectCmcMaterialByMaterialId(materialId));
    }

    /**
     * 新增cmc耗材信息
     */
    @Log(title = "cmc耗材信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcMaterial cmcMaterial)
    {
        return toAjax(cmcMaterialService.insertCmcMaterial(cmcMaterial));
    }

    /**
     * 修改cmc耗材信息
     */
    @Log(title = "cmc耗材信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcMaterial cmcMaterial)
    {
        return toAjax(cmcMaterialService.updateCmcMaterial(cmcMaterial));
    }

    /**
     * 删除cmc耗材信息
     */
    @Log(title = "cmc耗材信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{materialIds}")
    public AjaxResult remove(@PathVariable Integer[] materialIds)
    {
        return success(cmcMaterialService.deleteCmcMaterialByMaterialIds(materialIds));
    }
}
