package org.wfc.system.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.wfc.common.core.domain.R;
import org.wfc.common.core.web.controller.BaseController;
import org.wfc.common.core.web.page.TableDataInfo;
import org.wfc.omada.api.sitesetting.model.CreateSsidOpenApiVo;
import org.wfc.omada.api.sitesetting.model.SsidDetailOpenApiVo;
import org.wfc.omada.api.sitesetting.model.UpdateSsidBasicConfigOpenApiVo;
import org.wfc.omada.api.sitesetting.model.WlanGroupOpenApiVo;
import org.wfc.omada.api.sitesetting.model.WlanSimpleOpenApiVo;
import org.wfc.system.service.ISysWlanService;

import java.util.List;

/**
 * @description: wlan controller
 * @author: cyc
 * @since: 2025-02-15
 */
@RestController
@RequestMapping("/wlan")
public class SysWlanController extends BaseController {

    @Autowired
    private ISysWlanService sysWlanService;

    @GetMapping("/group/{siteId}")
    public R<List<WlanGroupOpenApiVo>> getWlanGroupList(@PathVariable(required = true) String siteId) {
        return R.ok(sysWlanService.getWlanGroupList(siteId));
    }

    @GetMapping("/ssid/{siteId}/{wlanId}")
    public TableDataInfo getSsidList(@PathVariable String siteId, @PathVariable String wlanId, @RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize) {
        return sysWlanService.getSsidList(siteId, wlanId, pageNum, pageSize);
    }

    @PostMapping("/ssid/{siteId}/{wlanId}")
    public R<Boolean> createSsid(@PathVariable(required = true) String siteId, @PathVariable String wlanId, @RequestBody(required = false) CreateSsidOpenApiVo createSsidOpenApiVo) {
        return R.ok(sysWlanService.createSsid(siteId, wlanId, createSsidOpenApiVo));
    }

    @PutMapping("/ssid/{siteId}/{wlanId}/{ssidId}")
    public R<Boolean> updateSsidBasicConfig(@PathVariable(required = true) String siteId, @PathVariable String wlanId, @PathVariable String ssidId, @RequestBody(required = false) UpdateSsidBasicConfigOpenApiVo updateSsidBasicConfigOpenApiVo) {
        return R.ok(sysWlanService.updateSsidBasicConfig(siteId, wlanId, ssidId, updateSsidBasicConfigOpenApiVo));
    }

    @DeleteMapping("/ssid/{siteId}/{wlanId}/{ssidId}")
    public R<Boolean> deleteSsid(@PathVariable(required = true) String siteId, @PathVariable String wlanId, @PathVariable String ssidId) {
        return R.ok(sysWlanService.deleteSsid(siteId, wlanId, ssidId));
    }

    @GetMapping("/ssid/{siteId}/{wlanId}/{ssidId}")
    public R<SsidDetailOpenApiVo> getSsidDetail(@PathVariable(required = true) String siteId, @PathVariable String wlanId, @PathVariable String ssidId) {
        return R.ok(sysWlanService.getSsidDetail(siteId, wlanId, ssidId));
    }

    @GetMapping("/ssids/{siteId}")
    public R<List<WlanSimpleOpenApiVo>> getMacAuthSsids(@PathVariable(required = true) String siteId) {
        return R.ok(sysWlanService.getMacAuthSsids(siteId));
    }
}
