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.core.web.page.TableDataInfo;
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.RmMonitorConfigDetails;
import com.ruoyi.system.service.IRmMonitorConfigDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * 监控看板详情Controller
 * 
 * @author gyt
 * @date 2025-11-14
 */
@RestController
@RequestMapping("/monitorConfigDetails")
public class RmMonitorConfigDetailsController extends BaseController
{
    @Autowired
    private IRmMonitorConfigDetailsService rmMonitorConfigDetailsService;

    /**
     * 查询监控看板详情列表
     */
    @RequiresPermissions("system:monitorConfigDetails:list")
    @GetMapping("/list")
    public TableDataInfo list(RmMonitorConfigDetails rmMonitorConfigDetails)
    {
        startPage();
        List<RmMonitorConfigDetails> list = rmMonitorConfigDetailsService.selectRmMonitorConfigDetailsList(rmMonitorConfigDetails);
        return getDataTable(list);
    }

    /**
     * 导出监控看板详情列表
     */
    @RequiresPermissions("system:monitorConfigDetails:export")
    @Log(title = "监控看板详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RmMonitorConfigDetails rmMonitorConfigDetails)
    {
        List<RmMonitorConfigDetails> list = rmMonitorConfigDetailsService.selectRmMonitorConfigDetailsList(rmMonitorConfigDetails);
        ExcelUtil<RmMonitorConfigDetails> util = new ExcelUtil<RmMonitorConfigDetails>(RmMonitorConfigDetails.class);
        util.exportExcel(response, list, "监控看板详情数据");
    }

    /**
     * 获取监控看板详情详细信息
     */
    @RequiresPermissions("system:monitorConfigDetails:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(rmMonitorConfigDetailsService.selectRmMonitorConfigDetailsById(id));
    }

    /**
     * 新增监控看板详情
     */
    @RequiresPermissions("system:monitorConfigDetails:add")
    @Log(title = "监控看板详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RmMonitorConfigDetails rmMonitorConfigDetails)
    {
        return toAjax(rmMonitorConfigDetailsService.insertRmMonitorConfigDetails(rmMonitorConfigDetails));
    }

    /**
     * 修改监控看板详情
     */
    @RequiresPermissions("system:monitorConfigDetails:edit")
    @Log(title = "监控看板详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RmMonitorConfigDetails rmMonitorConfigDetails)
    {
        return toAjax(rmMonitorConfigDetailsService.updateRmMonitorConfigDetails(rmMonitorConfigDetails));
    }

    /**
     * 删除监控看板详情
     */
    @RequiresPermissions("system:monitorConfigDetails:remove")
    @Log(title = "监控看板详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rmMonitorConfigDetailsService.deleteRmMonitorConfigDetailsByIds(ids));
    }
    /**
     * 监控看板-详情视图 出入流量
     */
    @RequiresPermissions("system:bandwidth:list")
    @PostMapping("/getTrafficByMonitorView")
    public AjaxResult getTrafficByMonitorView(@RequestBody RmMonitorConfigDetails queryParam)
    {
        Map<String, Object> echartsData = rmMonitorConfigDetailsService.getTrafficByMonitorView(queryParam);
        return success(echartsData);
    }
}
