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.SysImeiAutoLog;
import com.agri.system.service.ISysImeiAutoLogService;
import com.agri.common.utils.poi.ExcelUtil;
import com.agri.common.core.page.TableDataInfo;

/**
 * 自动模式日志Controller
 * 
 * @author lld
 * @date 2026-03-29
 */
@RestController
@RequestMapping("/warn/autolog")
public class SysImeiAutoLogController extends BaseController
{
    @Autowired
    private ISysImeiAutoLogService sysImeiAutoLogService;

    /**
     * 查询自动模式日志列表
     */
    @PreAuthorize("@ss.hasPermi('warn:autolog:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysImeiAutoLog sysImeiAutoLog)
    {
        startPage();
        List<SysImeiAutoLog> list = sysImeiAutoLogService.selectSysImeiAutoLogList(sysImeiAutoLog);
        return getDataTable(list);
    }

    /**
     * 导出自动模式日志列表
     */
    @PreAuthorize("@ss.hasPermi('warn:autolog:export')")
    @Log(title = "自动模式日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysImeiAutoLog sysImeiAutoLog)
    {
        List<SysImeiAutoLog> list = sysImeiAutoLogService.selectSysImeiAutoLogList(sysImeiAutoLog);
        ExcelUtil<SysImeiAutoLog> util = new ExcelUtil<SysImeiAutoLog>(SysImeiAutoLog.class);
        util.exportExcel(response, list, "自动模式日志数据");
    }

    /**
     * 获取自动模式日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('warn:autolog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysImeiAutoLogService.selectSysImeiAutoLogById(id));
    }

    /**
     * 新增自动模式日志
     */
    @PreAuthorize("@ss.hasPermi('warn:autolog:add')")
    @Log(title = "自动模式日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysImeiAutoLog sysImeiAutoLog)
    {
        return toAjax(sysImeiAutoLogService.insertSysImeiAutoLog(sysImeiAutoLog));
    }

    /**
     * 修改自动模式日志
     */
    @PreAuthorize("@ss.hasPermi('warn:autolog:edit')")
    @Log(title = "自动模式日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysImeiAutoLog sysImeiAutoLog)
    {
        return toAjax(sysImeiAutoLogService.updateSysImeiAutoLog(sysImeiAutoLog));
    }

    /**
     * 删除自动模式日志
     */
    @PreAuthorize("@ss.hasPermi('warn:autolog:remove')")
    @Log(title = "自动模式日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysImeiAutoLogService.deleteSysImeiAutoLogByIds(ids));
    }


    /**
     * 查询自动模式日志列表
     */
    @PreAuthorize("@ss.hasPermi('warn:autolog:list')")
    @GetMapping("/getAutoLogList")
    public AjaxResult getAutoLogList(SysImeiAutoLog sysImeiAutoLog)
    {
        List<SysImeiAutoLog> list = sysImeiAutoLogService.selectSysImeiAutoLogList(sysImeiAutoLog);
        return success(list);
    }
}
