package com.agri.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
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.agri.common.annotation.Log;
import com.agri.common.core.controller.BaseController;
import com.agri.common.core.domain.AjaxResult;
import com.agri.common.enums.BusinessType;
import com.agri.system.domain.SysDevOperLog;
import com.agri.system.service.ISysDevOperLogService;
import com.agri.common.utils.poi.ExcelUtil;
import com.agri.common.core.page.TableDataInfo;

/**
 * 设备控制操作日志Controller
 * 
 * @author lld
 * @date 2026-01-29
 */
@RestController
@RequestMapping("/control/controllog")
public class SysDevOperLogController extends BaseController
{
    @Autowired
    private ISysDevOperLogService sysDevOperLogService;

    /**
     * 查询设备控制操作日志列表
     */
    @PreAuthorize("@ss.hasPermi('control:controllog:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysDevOperLog sysDevOperLog)
    {
        startPage();
        List<SysDevOperLog> list = sysDevOperLogService.selectSysDevOperLogList(sysDevOperLog);
        return getDataTable(list);
    }

    /**
     * 导出设备控制操作日志列表
     */
    @PreAuthorize("@ss.hasPermi('control:controllog:export')")
    @Log(title = "设备控制操作日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysDevOperLog sysDevOperLog)
    {
        List<SysDevOperLog> list = sysDevOperLogService.selectSysDevOperLogList(sysDevOperLog);
        ExcelUtil<SysDevOperLog> util = new ExcelUtil<SysDevOperLog>(SysDevOperLog.class);
        util.exportExcel(response, list, "设备控制操作日志数据");
    }

    /**
     * 获取设备控制操作日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('control:controllog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysDevOperLogService.selectSysDevOperLogById(id));
    }

    /**
     * 新增设备控制操作日志
     */
    @PreAuthorize("@ss.hasPermi('control:controllog:add')")
    @Log(title = "设备控制操作日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysDevOperLog sysDevOperLog)
    {
        return toAjax(sysDevOperLogService.insertSysDevOperLog(sysDevOperLog));
    }

    /**
     * 修改设备控制操作日志
     */
    @PreAuthorize("@ss.hasPermi('control:controllog:edit')")
    @Log(title = "设备控制操作日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysDevOperLog sysDevOperLog)
    {
        return toAjax(sysDevOperLogService.updateSysDevOperLog(sysDevOperLog));
    }

    /**
     * 删除设备控制操作日志
     */
    @PreAuthorize("@ss.hasPermi('control:controllog:remove')")
    @Log(title = "设备控制操作日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysDevOperLogService.deleteSysDevOperLogByIds(ids));
    }
}
