package com.ruoyi.system.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.RmMonitorConfig;
import com.ruoyi.system.service.IRmMonitorConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 监控配置Controller
 * 
 * @author gyt
 * @date 2025-11-12
 */
@RestController
@RequestMapping("/monitorConfig")
public class RmMonitorConfigController extends BaseController
{
    @Autowired
    private IRmMonitorConfigService rmMonitorConfigService;

    /**
     * 查询监控配置列表
     */
    @RequiresPermissions("system:monitorConfig:list")
    @PostMapping("/list")
    public AjaxResult list(@RequestBody RmMonitorConfig rmMonitorConfig)
    {
        List<RmMonitorConfig> list = rmMonitorConfigService.selectRmMonitorConfigList(rmMonitorConfig);
        return success(list);
    }

    /**
     * 导出监控配置列表
     */
    @RequiresPermissions("system:monitorConfig:export")
    @Log(title = "监控配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RmMonitorConfig rmMonitorConfig)
    {
        List<RmMonitorConfig> list = rmMonitorConfigService.selectRmMonitorConfigList(rmMonitorConfig);
        ExcelUtil<RmMonitorConfig> util = new ExcelUtil<RmMonitorConfig>(RmMonitorConfig.class);
        util.exportExcel(response, list, "监控配置数据");
    }

    /**
     * 获取监控配置详细信息
     */
    @RequiresPermissions("system:monitorConfig:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(rmMonitorConfigService.selectRmMonitorConfigById(id));
    }

    /**
     * 新增监控配置
     */
    @RequiresPermissions("system:monitorConfig:add")
    @Log(title = "监控配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RmMonitorConfig rmMonitorConfig)
    {
        return toAjax(rmMonitorConfigService.insertRmMonitorConfig(rmMonitorConfig));
    }

    /**
     * 修改监控配置
     */
    @RequiresPermissions("system:monitorConfig:edit")
    @Log(title = "监控配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RmMonitorConfig rmMonitorConfig)
    {
        return toAjax(rmMonitorConfigService.updateRmMonitorConfig(rmMonitorConfig));
    }

    /**
     * 删除监控配置
     */
    @RequiresPermissions("system:monitorConfig:remove")
    @Log(title = "监控配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rmMonitorConfigService.deleteRmMonitorConfigByIds(ids));
    }
}
