package com.ruoyi.web.controller.base;

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.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.base.domain.RobotOpsSysLog;
import com.ruoyi.base.service.IRobotOpsSysLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 运行日志Controller
 *
 * @author ruoyi
 * @date 2026-05-18
 */
@RestController
@RequestMapping("/base/sysLog")
public class RobotOpsSysLogController extends BaseController
{
    @Autowired
    private IRobotOpsSysLogService robotOpsSysLogService;

    /**
     * 查询运行日志列表
     */
    @PreAuthorize("@ss.hasPermi('base:sysLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(RobotOpsSysLog robotOpsSysLog)
    {
        startPage();
        List<RobotOpsSysLog> list = robotOpsSysLogService.selectRobotOpsSysLogList(robotOpsSysLog);
        return getDataTable(list);
    }

    /**
     * 导出运行日志列表
     */
    @PreAuthorize("@ss.hasPermi('base:sysLog:export')")
    @Log(title = "运行日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RobotOpsSysLog robotOpsSysLog)
    {
        List<RobotOpsSysLog> list = robotOpsSysLogService.selectRobotOpsSysLogList(robotOpsSysLog);
        ExcelUtil<RobotOpsSysLog> util = new ExcelUtil<RobotOpsSysLog>(RobotOpsSysLog.class);
        util.exportExcel(response, list, "运行日志数据");
    }

    /**
     * 获取运行日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('base:sysLog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(robotOpsSysLogService.selectRobotOpsSysLogById(id));
    }

    /**
     * 新增运行日志
     */
    @PreAuthorize("@ss.hasPermi('base:sysLog:add')")
    @Log(title = "运行日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RobotOpsSysLog robotOpsSysLog)
    {
        return toAjax(robotOpsSysLogService.insertRobotOpsSysLog(robotOpsSysLog));
    }

    /**
     * 修改运行日志
     */
    @PreAuthorize("@ss.hasPermi('base:sysLog:edit')")
    @Log(title = "运行日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RobotOpsSysLog robotOpsSysLog)
    {
        return toAjax(robotOpsSysLogService.updateRobotOpsSysLog(robotOpsSysLog));
    }

    /**
     * 删除运行日志
     */
    @PreAuthorize("@ss.hasPermi('base:sysLog:remove')")
    @Log(title = "运行日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(robotOpsSysLogService.deleteRobotOpsSysLogByIds(ids));
    }
}
