package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.ss.wifi.domain.Wifi;
import com.ruoyi.ss.wifi.domain.WifiQuery;
import com.ruoyi.ss.wifi.domain.WifiVO;
import com.ruoyi.ss.wifi.service.IWifiService;
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.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * wifiController
 *
 * @author qzz
 * @date 2025-01-06
 */
@RestController
@RequestMapping("/system/wifi")
public class WifiController extends BaseController
{
    @Autowired
    private IWifiService wifiService;

    /**
     * 查询wifi列表
     */
    @PreAuthorize("@ss.hasPermi('system:wifi:list')")
    @GetMapping("/list")
    public TableDataInfo list(WifiQuery query)
    {
        startPage();
        startOrderBy();
        List<WifiVO> list = wifiService.selectWifiList(query);
        return getDataTable(list);
    }

    /**
     * 导出wifi列表
     */
    @PreAuthorize("@ss.hasPermi('system:wifi:export')")
    @Log(title = "wifi", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WifiQuery query)
    {
        List<WifiVO> list = wifiService.selectWifiList(query);
        ExcelUtil<WifiVO> util = new ExcelUtil<WifiVO>(WifiVO.class);
        util.exportExcel(response, list, "wifi数据");
    }

    /**
     * 获取wifi详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:wifi:query')")
    @GetMapping(value = "/{wifiId}")
    public AjaxResult getInfo(@PathVariable("wifiId") Long wifiId)
    {
        return success(wifiService.selectWifiByWifiId(wifiId));
    }

    /**
     * 新增wifi
     */
    @PreAuthorize("@ss.hasPermi('system:wifi:add')")
    @Log(title = "wifi", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Wifi wifi)
    {
        return toAjax(wifiService.insertWifi(wifi));
    }

    /**
     * 修改wifi
     */
    @PreAuthorize("@ss.hasPermi('system:wifi:edit')")
    @Log(title = "wifi", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Wifi wifi)
    {
        return toAjax(wifiService.updateWifi(wifi));
    }

    /**
     * 删除wifi
     */
    @PreAuthorize("@ss.hasPermi('system:wifi:remove')")
    @Log(title = "wifi", businessType = BusinessType.DELETE)
	@DeleteMapping("/{wifiIds}")
    public AjaxResult remove(@PathVariable Long[] wifiIds)
    {
        return toAjax(wifiService.deleteWifiByWifiIds(wifiIds));
    }
}
