package com.ruoyi.web.controller.manage;

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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manage.domain.NetworkManage;
import com.ruoyi.manage.service.INetworkManageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 网络管理Controller
 *
 * @author boman
 * @date 2025-05-07
 */
@RestController
@RequestMapping("/manage/NetworkManage")
public class NetworkManageController extends BaseController
{
    @Autowired
    private INetworkManageService networkManageService;

/**
 * 查询网络管理列表
 */
@PreAuthorize("@ss.hasPermi('manage:NetworkManage:list')")
@GetMapping("/list")
    public TableDataInfo list(NetworkManage networkManage)
    {
        startPage();
        List<NetworkManage> list = networkManageService.selectNetworkManageList(networkManage);
        return getDataTable(list);
    }

    /**
     * 导出网络管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:NetworkManage:export')")
    @Log(title = "网络管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NetworkManage networkManage)
    {
        List<NetworkManage> list = networkManageService.selectNetworkManageList(networkManage);
        ExcelUtil<NetworkManage> util = new ExcelUtil<NetworkManage>(NetworkManage.class);
        util.exportExcel(response, list, "网络管理数据");
    }

    /**
     * 获取网络管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:NetworkManage:query')")
    @GetMapping(value = "/{networkId}")
    public AjaxResult getInfo(@PathVariable("networkId") Long networkId)
    {
        return success(networkManageService.selectNetworkManageByNetworkId(networkId));
    }

    /**
     * 新增网络管理
     */
    @PreAuthorize("@ss.hasPermi('manage:NetworkManage:add')")
    @Log(title = "网络管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NetworkManage networkManage)
    {
        return toAjax(networkManageService.insertNetworkManage(networkManage));
    }

    /**
     * 修改网络管理
     */
    @PreAuthorize("@ss.hasPermi('manage:NetworkManage:edit')")
    @Log(title = "网络管理", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody NetworkManage networkManage)
    {
        return toAjax(networkManageService.updateNetworkManage(networkManage));
    }

    /**
     * 删除网络管理
     */
    @PreAuthorize("@ss.hasPermi('manage:NetworkManage:remove')")
    @Log(title = "网络管理", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{networkIds}")
    public AjaxResult remove(@PathVariable Long[] networkIds)
    {
        return toAjax(networkManageService.deleteNetworkManageByNetworkIds(networkIds));
    }
}
