package com.ruoyi.rocketmq.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.PageDomain;
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.rocketmq.domain.InitialMountPointInfo;
import com.ruoyi.rocketmq.service.IInitialMountPointInfoService;
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-08-25
 */
@RestController
@RequestMapping("/mountPointInfo")
public class InitialMountPointInfoController extends BaseController
{
    @Autowired
    private IInitialMountPointInfoService initialMountPointInfoService;

    /**
     * 查询挂载点监控信息列表
     */
    @RequiresPermissions("rocketmq:mountPointInfo:list")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody InitialMountPointInfo initialMountPointInfo)
    {
        PageDomain pageDomain = new PageDomain();
        pageDomain.setPageNum(initialMountPointInfo.getPageNum());
        pageDomain.setPageSize(initialMountPointInfo.getPageSize());
        startPage(pageDomain);
        List<InitialMountPointInfo> list = initialMountPointInfoService.selectInitialMountPointInfoList(initialMountPointInfo);
        return getDataTable(list);
    }

    /**
     * 导出挂载点监控信息列表
     */
    @RequiresPermissions("rocketmq:mountPointInfo:export")
    @Log(title = "挂载点监控信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InitialMountPointInfo initialMountPointInfo)
    {
        List<InitialMountPointInfo> list = initialMountPointInfoService.selectInitialMountPointInfoList(initialMountPointInfo);
        ExcelUtil<InitialMountPointInfo> util = new ExcelUtil<InitialMountPointInfo>(InitialMountPointInfo.class);
        util.exportExcel(response, list, "挂载点监控信息数据");
    }

    /**
     * 获取挂载点监控信息详细信息
     */
    @RequiresPermissions("rocketmq:mountPointInfo:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(initialMountPointInfoService.selectInitialMountPointInfoById(id));
    }

    /**
     * 新增挂载点监控信息
     */
    @RequiresPermissions("rocketmq:mountPointInfo:add")
    @Log(title = "挂载点监控信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InitialMountPointInfo initialMountPointInfo)
    {
        return toAjax(initialMountPointInfoService.insertInitialMountPointInfo(initialMountPointInfo));
    }

    /**
     * 修改挂载点监控信息
     */
    @RequiresPermissions("rocketmq:mountPointInfo:edit")
    @Log(title = "挂载点监控信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InitialMountPointInfo initialMountPointInfo)
    {
        return toAjax(initialMountPointInfoService.updateInitialMountPointInfo(initialMountPointInfo));
    }

    /**
     * 删除挂载点监控信息
     */
    @RequiresPermissions("rocketmq:mountPointInfo:remove")
    @Log(title = "挂载点监控信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(initialMountPointInfoService.deleteInitialMountPointInfoByIds(ids));
    }
    /**
     * 获取挂载点监控信息详细信息
     */
    @RequiresPermissions("rocketmq:mountPointInfo:query")
    @PostMapping(value = "/pointDetailsMsg")
    public AjaxResult pointDetailsMsg(@RequestBody InitialMountPointInfo initialMountPointInfo)
    {
        InitialMountPointInfo mountPointInfo = initialMountPointInfoService.pointDetailsMsg(initialMountPointInfo);
        return success(mountPointInfo);
    }
    /**
     * 获取挂载文件系统/的空间图形
     */
    @RequiresPermissions("rocketmq:mountPointInfo:query")
    @PostMapping(value = "/spaceEcharts")
    public AjaxResult spaceEcharts(@RequestBody InitialMountPointInfo initialMountPointInfo)
    {
        Map<String, Object> echartsData = initialMountPointInfoService.spaceEcharts(initialMountPointInfo);
        return success(echartsData);
    }
    /**
     * 获取挂载文件系统/的空间利用率图形
     */
    @RequiresPermissions("rocketmq:mountPointInfo:query")
    @PostMapping(value = "/spaceRateEcharts")
    public AjaxResult spaceRateEcharts(@RequestBody InitialMountPointInfo initialMountPointInfo)
    {
        Map<String, Object> echartsData = initialMountPointInfoService.spaceRateEcharts(initialMountPointInfo);
        return success(echartsData);
    }
    /**
     * 获取指定服务器的挂载文件系统名
     * @param initialMountPointInfo
     * @return
     */
    @RequiresPermissions("rocketmq:mountPointInfo:list")
    @PostMapping("/getAllMountName")
    public AjaxResult getAllMountName(@RequestBody InitialMountPointInfo initialMountPointInfo){
        List<Map> list = initialMountPointInfoService.getAllMountName(initialMountPointInfo);
        return success(list);
    }

}
