package com.zyc.web.controller.api;

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.zyc.common.annotation.Log;
import com.zyc.common.core.controller.BaseController;
import com.zyc.common.core.domain.AjaxResult;
import com.zyc.common.enums.BusinessType;
import com.zyc.system.domain.NetworkMap;
import com.zyc.system.service.INetworkMapService;
import com.zyc.common.utils.poi.ExcelUtil;
import com.zyc.common.core.page.TableDataInfo;

/**
 * 网络拓扑Controller
 * 
 * @author zyc
 * @date 2024-12-26
 */
@RestController
@RequestMapping("/system/NetworkMapController")
public class NetworkMapController extends BaseController
{
    @Autowired
    private INetworkMapService networkMapService;

    /**
     * 查询网络拓扑列表
     */
    @PreAuthorize("@ss.hasPermi('system:map:list')")
    @GetMapping("/list")
    public TableDataInfo list(NetworkMap networkMap)
    {
        startPage();
        List<NetworkMap> list = networkMapService.selectNetworkMapList(networkMap);
        return getDataTable(list);
    }

    /**
     * 导出网络拓扑列表
     */
    @PreAuthorize("@ss.hasPermi('system:map:export')")
    @Log(title = "网络拓扑", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NetworkMap networkMap)
    {
        List<NetworkMap> list = networkMapService.selectNetworkMapList(networkMap);
        ExcelUtil<NetworkMap> util = new ExcelUtil<NetworkMap>(NetworkMap.class);
        util.exportExcel(response, list, "网络拓扑数据");
    }

    /**
     * 获取网络拓扑详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:map:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(networkMapService.selectNetworkMapById(id));
    }

    /**
     * 新增网络拓扑
     */
    @PreAuthorize("@ss.hasPermi('system:map:add')")
    @Log(title = "网络拓扑", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NetworkMap networkMap)
    {
        return toAjax(networkMapService.insertNetworkMap(networkMap));
    }

    /**
     * 修改网络拓扑
     */
    @PreAuthorize("@ss.hasPermi('system:map:edit')")
    @Log(title = "网络拓扑", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NetworkMap networkMap)
    {
        return toAjax(networkMapService.updateNetworkMap(networkMap));
    }

    /**
     * 删除网络拓扑
     */
    @PreAuthorize("@ss.hasPermi('system:map:remove')")
    @Log(title = "网络拓扑", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(networkMapService.deleteNetworkMapByIds(ids));
    }
}
