2
0

fix: 修复omada上云问题

This commit is contained in:
caiyuchao
2025-01-20 11:39:58 +08:00
parent 6c10050fe7
commit d17153ed50
10 changed files with 40 additions and 17 deletions

View File

@@ -11,6 +11,7 @@ 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.RestController;
import org.wfc.common.core.domain.R;
import org.wfc.common.core.web.controller.BaseController;
import org.wfc.common.core.web.domain.AjaxResult;
import org.wfc.common.core.web.page.TableDataInfo;
@@ -80,4 +81,9 @@ public class SysDeviceController extends BaseController {
public AjaxResult settingJob() {
return toAjax(sysDeviceService.settingJob());
}
@PostMapping("/testJob")
public R<String> testJob() {
return R.ok(sysDeviceService.testJob());
}
}

View File

@@ -16,4 +16,6 @@ public interface ISysDeviceService extends IService<SysDevice> {
boolean deviceJob();
boolean settingJob();
String testJob();
}

View File

@@ -53,8 +53,10 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice
private static final String REDIS_ACCESS_TOKEN = "wfc-api-omada:access-token";
private static final String REDIS_REFRESH_TOKEN = "wfc-api-omada:refresh-token";
private static final int OMADA_ERROR_CODE = -44112;
private static final int OMADA_SUCCESS_CODE = 0;
@Transactional(rollbackFor = Exception.class)
@Override
public boolean deviceJob() {
ResponseEntity<OperationResponseGridVoSiteSummaryInfo> siteList = omadaSiteApi.getSiteList(1, 1000);
if (siteList.getBody() == null) {
@@ -92,6 +94,7 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice
return true;
}
@Override
public boolean settingJob() {
// 启用Omada历史记录保留
ResponseEntity<OperationResponseHistoryRetentionOpenApiVo> dataRetentionRes = omadaHistoryDataRetentionApi.getDataRetention();
@@ -115,4 +118,12 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice
return true;
}
@Override
public String testJob() {
ResponseEntity<OperationResponseGridVoSiteSummaryInfo> siteList = omadaSiteApi.getSiteList(1, 1000);
if (siteList.getBody() != null && siteList.getBody().getErrorCode() == OMADA_SUCCESS_CODE) {
return "success";
}
return siteList.getBody().getMsg();
}
}