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

import java.util.List;

import com.ruoyi.common.utils.uuid.Seq;
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 com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TdPropertyNetinfo;
import com.ruoyi.system.service.ITdPropertyNetinfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 涉密网络登记Controller
 * 
 * @author ruoyi
 * @date 2024-05-09
 */
@Controller
@RequestMapping("/system/network/netinfo")
public class TdPropertyNetinfoController extends BaseController
{
    private String prefix = "system/network/netinfo";

    @Autowired
    private ITdPropertyNetinfoService tdPropertyNetinfoService;

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

    /**
     * 查询涉密网络登记列表
     */
    @RequiresPermissions("system:network:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TdPropertyNetinfo tdPropertyNetinfo)
    {
        startPage();
        List<TdPropertyNetinfo> list = tdPropertyNetinfoService.selectTdPropertyNetinfoList(tdPropertyNetinfo);
        return getDataTable(list);
    }

    /**
     * 导出涉密网络登记列表
     */
    @RequiresPermissions("system:network:export")
    @Log(title = "涉密网络登记", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TdPropertyNetinfo tdPropertyNetinfo)
    {
        List<TdPropertyNetinfo> list = tdPropertyNetinfoService.selectTdPropertyNetinfoList(tdPropertyNetinfo);
        ExcelUtil<TdPropertyNetinfo> util = new ExcelUtil<TdPropertyNetinfo>(TdPropertyNetinfo.class);
        return util.exportExcel(list, "涉密网络登记数据");
    }

    /**
     * 新增涉密网络登记
     */
    @GetMapping("/add/{netId}")
    public String add(@PathVariable("netId") String netId, ModelMap mmap)
    {
        mmap.put("netId", netId);
        mmap.put("sysuser",getSysUser());
        return prefix + "/add";
    }

    /**
     * 新增保存涉密网络登记
     */
    @RequiresPermissions("system:network:add")
    @Log(title = "涉密网络登记", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TdPropertyNetinfo tdPropertyNetinfo)
    {
        tdPropertyNetinfo.setId("NetInfo_" + Seq.getId(Seq.commSeqType));
        return toAjax(tdPropertyNetinfoService.insertTdPropertyNetinfo(tdPropertyNetinfo));
    }

    /**
     * 修改涉密网络登记
     */
    @RequiresPermissions("system:network:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        TdPropertyNetinfo tdPropertyNetinfo = tdPropertyNetinfoService.selectTdPropertyNetinfoById(id);
        mmap.put("tdPropertyNetinfo", tdPropertyNetinfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存涉密网络登记
     */
    @RequiresPermissions("system:network:edit")
    @Log(title = "涉密网络登记", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TdPropertyNetinfo tdPropertyNetinfo)
    {
        return toAjax(tdPropertyNetinfoService.updateTdPropertyNetinfo(tdPropertyNetinfo));
    }

    /**
     * 删除涉密网络登记
     */
    @RequiresPermissions("system:network:remove")
    @Log(title = "涉密网络登记", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tdPropertyNetinfoService.deleteTdPropertyNetinfoByIds(ids));
    }

    /**
     * 涉密网络登记详情
     */
    @RequiresPermissions("system:network:detail")
    @GetMapping("/detail/{id}")
    public String detail(@PathVariable("id") String id, ModelMap mmap)
    {
        mmap.put("tdPropertyNetinfo", tdPropertyNetinfoService.selectTdPropertyNetinfoById(id));
        return prefix + "/detail";
    }
}
