feat: ssid管理功能
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
package org.wfc.system.controller;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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.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.UpdateSsidBasicConfigOpenApiVo;
|
||||
import org.wfc.omada.api.sitesetting.model.WlanGroupOpenApiVo;
|
||||
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("/getWlanGroupList/{siteId}")
|
||||
public R<List<WlanGroupOpenApiVo>> getWlanGroupList(@PathVariable(required = true) String siteId) {
|
||||
return R.ok(sysWlanService.getWlanGroupList(siteId));
|
||||
}
|
||||
|
||||
@GetMapping("/getSsidList/{siteId}/{wlanId}")
|
||||
public TableDataInfo getSsidList(@PathVariable String siteId, @PathVariable String wlanId, @RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize) {
|
||||
startPage();
|
||||
return sysWlanService.getSsidList(siteId, wlanId, pageNum, pageSize);
|
||||
}
|
||||
|
||||
@PostMapping("/createSsid/{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));
|
||||
}
|
||||
|
||||
@PostMapping("/updateSsidBasicConfig/{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));
|
||||
}
|
||||
|
||||
@PostMapping("/createSsid/{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));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package org.wfc.system.service.impl;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.wfc.common.core.constant.HttpStatus;
|
||||
import org.wfc.common.core.constant.WifiConstants;
|
||||
import org.wfc.common.core.exception.OmadaException;
|
||||
import org.wfc.common.core.web.page.TableDataInfo;
|
||||
import org.wfc.omada.api.sitesetting.OmadaWirelessNetworkApi;
|
||||
import org.wfc.omada.api.sitesetting.model.CreateSsidOpenApiVo;
|
||||
import org.wfc.omada.api.sitesetting.model.OperationResponseGridVoSsidOpenApiVo;
|
||||
import org.wfc.omada.api.sitesetting.model.OperationResponseListWlanGroupOpenApiVo;
|
||||
import org.wfc.omada.api.sitesetting.model.OperationResponseObject;
|
||||
import org.wfc.omada.api.sitesetting.model.OperationResponseWithoutResult;
|
||||
import org.wfc.omada.api.sitesetting.model.UpdateSsidBasicConfigOpenApiVo;
|
||||
import org.wfc.omada.api.sitesetting.model.WlanGroupOpenApiVo;
|
||||
import org.wfc.system.service.ISysWlanService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @description: wlan service impl
|
||||
* @author: cyc
|
||||
* @since: 2025-02-15
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SysWlanServiceImpl implements ISysWlanService {
|
||||
|
||||
@Autowired
|
||||
private OmadaWirelessNetworkApi omadaWirelessNetworkApi;
|
||||
|
||||
@Override
|
||||
public List<WlanGroupOpenApiVo> getWlanGroupList(String siteId) {
|
||||
ResponseEntity<OperationResponseListWlanGroupOpenApiVo> response = omadaWirelessNetworkApi.getWlanGroupList(siteId);
|
||||
checkResponse(Objects.requireNonNull(response.getBody()).getErrorCode(), response.getBody().getMsg());
|
||||
return response.getBody().getResult();
|
||||
}
|
||||
|
||||
private static void checkResponse(Integer errorCode, String msg) {
|
||||
if (errorCode != WifiConstants.ERROR_CODE_SUCCESS) {
|
||||
log.error("Omada error msg: {}", msg);
|
||||
throw new OmadaException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo getSsidList(String siteId, String wlanId, Integer pageNum, Integer pageSize) {
|
||||
ResponseEntity<OperationResponseGridVoSsidOpenApiVo> response = omadaWirelessNetworkApi.getSsidList(siteId, wlanId, pageNum, pageSize);
|
||||
checkResponse(Objects.requireNonNull(response.getBody()).getErrorCode(), response.getBody().getMsg());
|
||||
return getDataTable(response.getBody().getResult().getData(), response.getBody().getResult().getTotalRows());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createSsid(String siteId, String wlanId, CreateSsidOpenApiVo createSsidOpenApiVo) {
|
||||
ResponseEntity<OperationResponseObject> response = omadaWirelessNetworkApi.createSsid(siteId, wlanId, createSsidOpenApiVo);
|
||||
checkResponse(Objects.requireNonNull(response.getBody()).getErrorCode(), response.getBody().getMsg());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateSsidBasicConfig(String siteId, String wlanId, String ssidId, UpdateSsidBasicConfigOpenApiVo updateSsidBasicConfigOpenApiVo) {
|
||||
ResponseEntity<OperationResponseWithoutResult> response = omadaWirelessNetworkApi.updateSsidBasicConfig(siteId, wlanId, ssidId, updateSsidBasicConfigOpenApiVo);
|
||||
checkResponse(Objects.requireNonNull(response.getBody()).getErrorCode(), response.getBody().getMsg());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteSsid(String siteId, String wlanId, String ssidId) {
|
||||
ResponseEntity<OperationResponseWithoutResult> response = omadaWirelessNetworkApi.deleteSsid(siteId, wlanId, ssidId);
|
||||
checkResponse(Objects.requireNonNull(response.getBody()).getErrorCode(), response.getBody().getMsg());
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应请求分页数据
|
||||
*/
|
||||
protected TableDataInfo getDataTable(List<?> list, Long total) {
|
||||
TableDataInfo rspData = new TableDataInfo(list, total);
|
||||
rspData.setCode(HttpStatus.SUCCESS);
|
||||
rspData.setMsg("Query successful");
|
||||
|
||||
return rspData;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user