package com.ruoyi.web.controller.app;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.ValidGroup;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
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.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

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

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

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

    /**
     * 新增wifi
     */
    @Log(title = "wifi", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class)Wifi wifi)
    {
        return toAjax(wifiService.insertWifi(wifi));
    }

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

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