feat: ap管理功能
This commit is contained in:
@@ -15,6 +15,9 @@ import org.wfc.common.core.domain.R;
|
|||||||
import org.wfc.common.core.web.controller.BaseController;
|
import org.wfc.common.core.web.controller.BaseController;
|
||||||
import org.wfc.common.core.web.domain.AjaxResult;
|
import org.wfc.common.core.web.domain.AjaxResult;
|
||||||
import org.wfc.common.core.web.page.TableDataInfo;
|
import org.wfc.common.core.web.page.TableDataInfo;
|
||||||
|
import org.wfc.omada.api.device.model.AdoptDeviceRequest;
|
||||||
|
import org.wfc.omada.api.device.model.ApGeneralConfig;
|
||||||
|
import org.wfc.omada.api.device.model.DeviceListAddBySnOpenApiVo;
|
||||||
import org.wfc.system.domain.SysDevice;
|
import org.wfc.system.domain.SysDevice;
|
||||||
import org.wfc.system.service.ISysDeviceService;
|
import org.wfc.system.service.ISysDeviceService;
|
||||||
|
|
||||||
@@ -86,4 +89,30 @@ public class SysDeviceController extends BaseController {
|
|||||||
public R<String> testJob() {
|
public R<String> testJob() {
|
||||||
return R.ok(sysDeviceService.testJob());
|
return R.ok(sysDeviceService.testJob());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/forget/{siteId}/{deviceMac}")
|
||||||
|
public R<Boolean> forgetDevice(@PathVariable(required = true) String siteId, @PathVariable(required = true) String deviceMac) {
|
||||||
|
return R.ok(sysDeviceService.forgetDevice(siteId, deviceMac));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/add/{siteId}")
|
||||||
|
public R<Boolean> addDevice(@PathVariable(required = true) String siteId, @RequestBody(required = false) DeviceListAddBySnOpenApiVo deviceListAddBySnOpenApiVo) {
|
||||||
|
return R.ok(sysDeviceService.addDeviceBySn(siteId, deviceListAddBySnOpenApiVo));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/startAdopt/{siteId}/{deviceMac}")
|
||||||
|
public R<Boolean> startAdoptDevice(@PathVariable(required = true) String siteId, @PathVariable(required = true) String deviceMac, @RequestBody(required = false) AdoptDeviceRequest adoptDeviceRequest) {
|
||||||
|
return R.ok(sysDeviceService.startAdoptDevice(siteId, deviceMac, adoptDeviceRequest));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/reboot/{siteId}/{deviceMac}")
|
||||||
|
public R<Boolean> rebootDevice(@PathVariable(required = true) String siteId, @PathVariable(required = true) String deviceMac) {
|
||||||
|
return R.ok(sysDeviceService.rebootDevice(siteId, deviceMac));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/updateConfig/{siteId}/{deviceMac}")
|
||||||
|
public R<Boolean> updateConfig(@PathVariable(required = true) String siteId, @PathVariable(required = true) String deviceMac, @RequestBody(required = false) ApGeneralConfig apGeneralConfig) {
|
||||||
|
return R.ok(sysDeviceService.updateConfig(siteId, deviceMac, apGeneralConfig));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package org.wfc.system.service;
|
package org.wfc.system.service;
|
||||||
|
|
||||||
|
import org.wfc.omada.api.device.model.AdoptDeviceRequest;
|
||||||
|
import org.wfc.omada.api.device.model.ApGeneralConfig;
|
||||||
|
import org.wfc.omada.api.device.model.DeviceListAddBySnOpenApiVo;
|
||||||
import org.wfc.system.domain.SysDevice;
|
import org.wfc.system.domain.SysDevice;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
@@ -18,4 +21,14 @@ public interface ISysDeviceService extends IService<SysDevice> {
|
|||||||
boolean settingJob();
|
boolean settingJob();
|
||||||
|
|
||||||
String testJob();
|
String testJob();
|
||||||
|
|
||||||
|
boolean forgetDevice(String siteId, String deviceMac);
|
||||||
|
|
||||||
|
boolean addDeviceBySn(String siteId, DeviceListAddBySnOpenApiVo deviceListAddBySnOpenApiVo);
|
||||||
|
|
||||||
|
boolean startAdoptDevice(String siteId, String deviceMac, AdoptDeviceRequest adoptDeviceRequest);
|
||||||
|
|
||||||
|
boolean rebootDevice(String siteId, String deviceMac);
|
||||||
|
|
||||||
|
boolean updateConfig(String siteId, String deviceMac, ApGeneralConfig apGeneralConfig);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,23 @@ package org.wfc.system.service.impl;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.wfc.common.core.constant.WifiConstants;
|
||||||
|
import org.wfc.common.core.exception.OmadaException;
|
||||||
import org.wfc.common.redis.service.RedisService;
|
import org.wfc.common.redis.service.RedisService;
|
||||||
|
import org.wfc.omada.api.device.OmadaApApi;
|
||||||
import org.wfc.omada.api.device.OmadaDeviceApi;
|
import org.wfc.omada.api.device.OmadaDeviceApi;
|
||||||
|
import org.wfc.omada.api.device.model.AdoptDeviceRequest;
|
||||||
|
import org.wfc.omada.api.device.model.ApGeneralConfig;
|
||||||
import org.wfc.omada.api.device.model.DeviceInfo;
|
import org.wfc.omada.api.device.model.DeviceInfo;
|
||||||
|
import org.wfc.omada.api.device.model.DeviceListAddBySnOpenApiVo;
|
||||||
|
import org.wfc.omada.api.device.model.OperationResponseDeviceAddRespOpenApiVo;
|
||||||
import org.wfc.omada.api.device.model.OperationResponseGridVoDeviceInfo;
|
import org.wfc.omada.api.device.model.OperationResponseGridVoDeviceInfo;
|
||||||
|
import org.wfc.omada.api.device.model.OperationResponseWithoutResult;
|
||||||
import org.wfc.omada.api.maintenance.OmadaHistoryDataRetentionApi;
|
import org.wfc.omada.api.maintenance.OmadaHistoryDataRetentionApi;
|
||||||
import org.wfc.omada.api.maintenance.model.HistoryRetentionOpenApiVo;
|
import org.wfc.omada.api.maintenance.model.HistoryRetentionOpenApiVo;
|
||||||
import org.wfc.omada.api.maintenance.model.ModifyHistoryRetentionOpenApiVo;
|
import org.wfc.omada.api.maintenance.model.ModifyHistoryRetentionOpenApiVo;
|
||||||
@@ -35,6 +44,7 @@ import java.util.stream.Collectors;
|
|||||||
* @author sys
|
* @author sys
|
||||||
* @since 2025-01-07
|
* @since 2025-01-07
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice> implements ISysDeviceService {
|
public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice> implements ISysDeviceService {
|
||||||
|
|
||||||
@@ -47,6 +57,9 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice
|
|||||||
@Autowired
|
@Autowired
|
||||||
private OmadaHistoryDataRetentionApi omadaHistoryDataRetentionApi;
|
private OmadaHistoryDataRetentionApi omadaHistoryDataRetentionApi;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OmadaApApi omadaApApi;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
@@ -126,4 +139,51 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice
|
|||||||
}
|
}
|
||||||
return siteList.getBody().getMsg();
|
return siteList.getBody().getMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean forgetDevice(String siteId, String deviceMac) {
|
||||||
|
ResponseEntity<OperationResponseWithoutResult> response = omadaDeviceApi.forgetDevice(siteId, deviceMac);
|
||||||
|
|
||||||
|
checkResponse(Objects.requireNonNull(response.getBody()).getErrorCode(), response.getBody().getMsg());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 boolean addDeviceBySn(String siteId, DeviceListAddBySnOpenApiVo deviceListAddBySnOpenApiVo) {
|
||||||
|
ResponseEntity<OperationResponseDeviceAddRespOpenApiVo> response = omadaDeviceApi.addDevicesBySn(siteId, deviceListAddBySnOpenApiVo);
|
||||||
|
|
||||||
|
checkResponse(Objects.requireNonNull(response.getBody()).getErrorCode(), response.getBody().getMsg());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean startAdoptDevice(String siteId, String deviceMac, AdoptDeviceRequest adoptDeviceRequest) {
|
||||||
|
ResponseEntity<OperationResponseWithoutResult> response = omadaDeviceApi.adoptDevice(siteId, deviceMac, adoptDeviceRequest);
|
||||||
|
|
||||||
|
checkResponse(Objects.requireNonNull(response.getBody()).getErrorCode(), response.getBody().getMsg());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean rebootDevice(String siteId, String deviceMac) {
|
||||||
|
ResponseEntity<OperationResponseWithoutResult> response = omadaDeviceApi.rebootDevice(siteId, deviceMac);
|
||||||
|
|
||||||
|
checkResponse(Objects.requireNonNull(response.getBody()).getErrorCode(), response.getBody().getMsg());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateConfig(String siteId, String deviceMac, ApGeneralConfig apGeneralConfig) {
|
||||||
|
ResponseEntity<OperationResponseWithoutResult> response = omadaApApi.modifyGeneralConfig2(siteId, deviceMac, apGeneralConfig);
|
||||||
|
|
||||||
|
checkResponse(Objects.requireNonNull(response.getBody()).getErrorCode(), response.getBody().getMsg());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user