package com.ruoyi.web.controller.system.count;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TdPropertyInfo;
import com.ruoyi.system.domain.TdPropertyNet;
import com.ruoyi.system.domain.TdPropertyNetinfo;
import com.ruoyi.system.service.ITdPropertyNetService;
import com.ruoyi.system.service.ITdPropertyNetinfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/system/networknum")
public class SysNetworknumController extends BaseController {
    private String prefix = "system/network/networknum";

    @Autowired
    private ITdPropertyNetService tdPropertyNetService;
    @Autowired
    private ITdPropertyNetinfoService tdPropertyNetinfoService;

    @RequiresPermissions("system:networknum:view")
    @GetMapping()
    public String network()
    {
        return prefix + "/networknum";
    }

    /**
     * 查询涉密网络设备列表
     */
    @RequiresPermissions("system:networknum:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TdPropertyNet tdPropertyNet)
    {
        startPage();
        List<TdPropertyNet> list = tdPropertyNetService.selectTdPropertyNetList(tdPropertyNet);
        return getDataTable(list);
    }

    /**
     * 打印界面
     */
    @RequiresPermissions("system:networknum:print")
    @GetMapping("/print/{netId}")
    @Log(title = "网络设备统计", businessType = BusinessType.PRINT)
    public String print(@PathVariable("netId") String netId, ModelMap mmap)
    {
        List<TdPropertyNetinfo> tdPropertyNetinfos = tdPropertyNetinfoService.selectTdPropertyNetinfoByNetId(netId);
        TdPropertyNet tdPropertyNet = tdPropertyNetService.selectTdPropertyNetByNetId(netId);
        mmap.put("tdPropertyNetinfos", tdPropertyNetinfos);
        mmap.put("tdPropertyNet", tdPropertyNet);
        mmap.put("sysuser", getSysUser());
        return prefix + "/print";
    }

}
