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

/**
 * cmc设备移交Controller
 * 
 * @author cmc
 * @date 2024-05-21
 */
@RestController
@RequestMapping("/oa/deviceHandover")
public class CmcDeviceHandoverController extends BaseController
{
    @Autowired
    private ICmcDeviceHandoverService cmcDeviceHandoverService;

    /**
     * 查询cmc设备移交列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmcDeviceHandover cmcDeviceHandover)
    {
        startPage();
        List<CmcDeviceHandover> list = cmcDeviceHandoverService.selectCmcDeviceHandoverList(cmcDeviceHandover);
        return getDataTable(list);
    }

    /**
     * 导出cmc设备移交列表
     */
    @Log(title = "cmc设备移交", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcDeviceHandover cmcDeviceHandover)
    {
        List<CmcDeviceHandover> list = cmcDeviceHandoverService.selectCmcDeviceHandoverList(cmcDeviceHandover);
        ExcelUtil<CmcDeviceHandover> util = new ExcelUtil<CmcDeviceHandover>(CmcDeviceHandover.class);
        util.exportExcel(response, list, "cmc设备移交数据");
    }

    /**
     * 获取cmc设备移交详细信息
     */
    @GetMapping(value = "/{deviceHandoverId}")
    public AjaxResult getInfo(@PathVariable("deviceHandoverId") Integer deviceHandoverId)
    {
        return success(cmcDeviceHandoverService.selectCmcDeviceHandoverByDeviceHandoverId(deviceHandoverId));
    }

    /**
     * 新增cmc设备移交
     */
    @Log(title = "cmc设备移交", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcDeviceHandover cmcDeviceHandover)
    {
        return toAjax(cmcDeviceHandoverService.insertCmcDeviceHandover(cmcDeviceHandover));
    }

    /**
     * 修改cmc设备移交
     */
    @Log(title = "cmc设备移交", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcDeviceHandover cmcDeviceHandover)
    {
        return toAjax(cmcDeviceHandoverService.updateCmcDeviceHandover(cmcDeviceHandover));
    }

    /**
     * 删除cmc设备移交
     */
    @Log(title = "cmc设备移交", businessType = BusinessType.DELETE)
	@DeleteMapping("/{deviceHandoverIds}")
    public AjaxResult remove(@PathVariable Integer[] deviceHandoverIds)
    {
        return success(cmcDeviceHandoverService.deleteCmcDeviceHandoverByDeviceHandoverIds(deviceHandoverIds));
    }
}
