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

/**
 * cmc仪器记录Controller
 * 
 * @author cmc
 * @date 2025-06-10
 */
@RestController
@RequestMapping("/oa/deviceLog")
public class CmcDeviceLogController extends BaseController
{
    @Autowired
    private ICmcDeviceLogService cmcDeviceLogService;

    /**
     * 查询cmc仪器记录列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmcDeviceLog cmcDeviceLog)
    {
        startPage();
        List<CmcDeviceLog> list = cmcDeviceLogService.selectCmcDeviceLogList(cmcDeviceLog);
        return getDataTable(list);
    }

    /**
     * 导出cmc仪器记录列表
     */
    @Log(title = "cmc仪器记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcDeviceLog cmcDeviceLog)
    {
        List<CmcDeviceLog> list = cmcDeviceLogService.selectCmcDeviceLogList(cmcDeviceLog);
        ExcelUtil<CmcDeviceLog> util = new ExcelUtil<CmcDeviceLog>(CmcDeviceLog.class);
        util.exportExcel(response, list, "cmc仪器记录数据");
    }

    /**
     * 获取cmc仪器记录详细信息
     */
    @GetMapping(value = "/{logId}")
    public AjaxResult getInfo(@PathVariable("logId") Integer logId)
    {
        return success(cmcDeviceLogService.selectCmcDeviceLogByLogId(logId));
    }

    /**
     * 新增cmc仪器记录
     */
    @Log(title = "cmc仪器记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcDeviceLog cmcDeviceLog)
    {
        return toAjax(cmcDeviceLogService.insertCmcDeviceLog(cmcDeviceLog));
    }

    /**
     * 修改cmc仪器记录
     */
    @Log(title = "cmc仪器记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcDeviceLog cmcDeviceLog)
    {
        return toAjax(cmcDeviceLogService.updateCmcDeviceLog(cmcDeviceLog));
    }

    /**
     * 删除cmc仪器记录
     */
    @Log(title = "cmc仪器记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logIds}")
    public AjaxResult remove(@PathVariable Integer[] logIds)
    {
        return success(cmcDeviceLogService.deleteCmcDeviceLogByLogIds(logIds));
    }
}
