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.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.system.domain.RmEpsTopologyManagement;
import com.ruoyi.system.service.IRmEpsTopologyManagementService;
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-08-12
 */
@RestController
@RequestMapping("/management")
public class RmEpsTopologyManagementController extends BaseController
{
    @Autowired
    private IRmEpsTopologyManagementService rmEpsTopologyManagementService;

    /**
     * 查询交换机/服务器名称
     */
    @RequiresPermissions("system:management:list")
    @PostMapping ("/getNamesByResoureType")
    public List<RmEpsTopologyManagement> getNamesByResoureType(@RequestBody RmEpsTopologyManagement rmEpsTopologyManagement)
    {
        List<RmEpsTopologyManagement> list = rmEpsTopologyManagementService.selectRmEpsTopologyManagementList(rmEpsTopologyManagement);
        return list;
    }
 /**
     * 查询拓扑管理列表
     */
    @RequiresPermissions("system:management:list")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody RmEpsTopologyManagement rmEpsTopologyManagement)
    {
        PageDomain pageDomain = new PageDomain();
        pageDomain.setPageNum(rmEpsTopologyManagement.getPageNum());
        pageDomain.setPageSize(rmEpsTopologyManagement.getPageSize());
        startPage(pageDomain);
        List<RmEpsTopologyManagement> list = rmEpsTopologyManagementService.selectRmEpsTopologyManagementList(rmEpsTopologyManagement);
        return getDataTable(list);
    }
    /**
     * 查询拓扑管理图形
     */
    @RequiresPermissions("system:management:list")
    @PostMapping("/getListChart")
    public AjaxResult getListChart(@RequestBody RmEpsTopologyManagement rmEpsTopologyManagement)
    {
        List<RmEpsTopologyManagement> list = rmEpsTopologyManagementService.selectRmEpsTopologyManagementList(rmEpsTopologyManagement);
        return success(list);
    }

    /**
     * 导出拓扑管理列表
     */
    @RequiresPermissions("system:management:export")
    @Log(title = "拓扑管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, @RequestBody RmEpsTopologyManagement rmEpsTopologyManagement)
    {
        List<RmEpsTopologyManagement> list = rmEpsTopologyManagementService.selectRmEpsTopologyManagementList(rmEpsTopologyManagement);
        ExcelUtil<RmEpsTopologyManagement> util = new ExcelUtil<RmEpsTopologyManagement>(RmEpsTopologyManagement.class);
        util.showColumn(rmEpsTopologyManagement.getProperties());
        util.exportExcel(response, list, "拓扑管理数据");
    }

    /**
     * 获取拓扑管理详细信息
     */
    @RequiresPermissions("system:management:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(rmEpsTopologyManagementService.selectRmEpsTopologyManagementById(id));
    }

    /**
     * 新增拓扑管理
     */
    @RequiresPermissions("system:management:add")
    @Log(title = "拓扑管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RmEpsTopologyManagement rmEpsTopologyManagement)
    {
        return toAjax(rmEpsTopologyManagementService.insertRmEpsTopologyManagement(rmEpsTopologyManagement));
    }

    /**
     * 修改拓扑管理
     */
    @RequiresPermissions("system:management:edit")
    @Log(title = "拓扑管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RmEpsTopologyManagement rmEpsTopologyManagement)
    {
        return toAjax(rmEpsTopologyManagementService.updateRmEpsTopologyManagement(rmEpsTopologyManagement));
    }

    /**
     * 删除拓扑管理
     */
    @RequiresPermissions("system:management:remove")
    @Log(title = "拓扑管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rmEpsTopologyManagementService.deleteRmEpsTopologyManagementByIds(ids));
    }
}
