diff --git a/wfc-api/wfc-api-omada/pom.xml b/wfc-api/wfc-api-omada/pom.xml index adabae8..fd85ba3 100644 --- a/wfc-api/wfc-api-omada/pom.xml +++ b/wfc-api/wfc-api-omada/pom.xml @@ -32,11 +32,5 @@ swagger-annotations - - org.projectlombok - lombok - - - diff --git a/wfc-api/wfc-api-omada/src/main/java/org/wfc/omada/config/FeignConfig.java b/wfc-api/wfc-api-omada/src/main/java/org/wfc/omada/config/FeignConfig.java index 374b4d0..5ca6ce0 100644 --- a/wfc-api/wfc-api-omada/src/main/java/org/wfc/omada/config/FeignConfig.java +++ b/wfc-api/wfc-api-omada/src/main/java/org/wfc/omada/config/FeignConfig.java @@ -4,7 +4,6 @@ import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson2.JSON; import feign.RequestInterceptor; import feign.RequestTemplate; -import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.core.ParameterizedTypeReference; @@ -27,7 +26,6 @@ import java.util.concurrent.TimeUnit; * @author: caiyuchao * @date: 2024-11-21 */ -@Slf4j @Configuration public class FeignConfig implements RequestInterceptor { @@ -85,9 +83,6 @@ public class FeignConfig implements RequestInterceptor { requestTemplate.uri("/openapi/v1/" + omadaProperties.getOmadacId() + lastUri); } - log.info("requestTemplate path:{}", requestTemplate.path()); - log.info("omadacId:{}", omadaProperties.getOmadacId()); - log.info("authorization:{}", authorization); // 添加授权请求头 requestTemplate.header(AUTHORIZATION, authorization); } diff --git a/wfc-api/wfc-api-system/src/main/java/org/wfc/system/api/RemoteUserService.java b/wfc-api/wfc-api-system/src/main/java/org/wfc/system/api/RemoteUserService.java index 9636e6f..eb4463b 100644 --- a/wfc-api/wfc-api-system/src/main/java/org/wfc/system/api/RemoteUserService.java +++ b/wfc-api/wfc-api-system/src/main/java/org/wfc/system/api/RemoteUserService.java @@ -57,4 +57,7 @@ public interface RemoteUserService @PostMapping("/device/settingJob") public R settingJob(); + + @PostMapping("/device/testJob") + public R testJob(); } diff --git a/wfc-api/wfc-api-system/src/main/java/org/wfc/system/api/factory/RemoteUserFallbackFactory.java b/wfc-api/wfc-api-system/src/main/java/org/wfc/system/api/factory/RemoteUserFallbackFactory.java index 4009a87..2d153b7 100644 --- a/wfc-api/wfc-api-system/src/main/java/org/wfc/system/api/factory/RemoteUserFallbackFactory.java +++ b/wfc-api/wfc-api-system/src/main/java/org/wfc/system/api/factory/RemoteUserFallbackFactory.java @@ -52,6 +52,11 @@ public class RemoteUserFallbackFactory implements FallbackFactory settingJob() { return R.fail("oamda setting job error:" + throwable.getMessage()); } + + @Override + public R testJob() { + return R.fail("oamda test job error:" + throwable.getMessage()); + } }; } } diff --git a/wfc-gateway/src/main/java/org/wfc/gateway/filter/AuthFilter.java b/wfc-gateway/src/main/java/org/wfc/gateway/filter/AuthFilter.java index c832500..b3a3f7c 100644 --- a/wfc-gateway/src/main/java/org/wfc/gateway/filter/AuthFilter.java +++ b/wfc-gateway/src/main/java/org/wfc/gateway/filter/AuthFilter.java @@ -21,6 +21,8 @@ import org.wfc.gateway.config.properties.IgnoreWhiteProperties; import io.jsonwebtoken.Claims; import reactor.core.publisher.Mono; +import java.util.Arrays; + /** * 网关鉴权 * @@ -38,6 +40,8 @@ public class AuthFilter implements GlobalFilter, Ordered @Autowired private RedisService redisService; + private static final String[] feignOmadaUrls = {"system/dashboard/overview", "system/dashboard/page", "schedule/job/run", "system/client/list"}; + @Override public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) @@ -83,6 +87,10 @@ public class AuthFilter implements GlobalFilter, Ordered addHeader(mutate, SecurityConstants.DETAILS_USER_ID, userid); addHeader(mutate, SecurityConstants.DETAILS_USERNAME, username); addHeader(mutate, SecurityConstants.DETAILS_PLATFORM, platform); + // feign omada api 调用处理 + if (Arrays.stream(feignOmadaUrls).anyMatch(url::contains)) { + removeHeader(mutate, SecurityConstants.AUTHORIZATION_HEADER); + } // 内部请求来源参数清除 removeHeader(mutate, SecurityConstants.FROM_SOURCE); return chain.filter(exchange.mutate().request(mutate.build()).build()); diff --git a/wfc-modules/wfc-job/src/main/java/org/wfc/job/controller/SysJobController.java b/wfc-modules/wfc-job/src/main/java/org/wfc/job/controller/SysJobController.java index 7d82c1e..48d3726 100644 --- a/wfc-modules/wfc-job/src/main/java/org/wfc/job/controller/SysJobController.java +++ b/wfc-modules/wfc-job/src/main/java/org/wfc/job/controller/SysJobController.java @@ -20,7 +20,6 @@ import org.wfc.common.core.web.domain.AjaxResult; import org.wfc.common.core.web.page.TableDataInfo; import org.wfc.common.log.annotation.Log; import org.wfc.common.log.enums.BusinessType; -//import org.wfc.common.security.annotation.RequiresPermissions; import org.wfc.common.security.utils.SecurityUtils; import org.wfc.job.domain.SysJob; import org.wfc.job.service.ISysJobService; @@ -176,9 +175,9 @@ public class SysJobController extends BaseController { SysJob sysJob = jobService.selectJobById(job.getJobId()); if (sysJob != null && sysJob.getInvokeTarget().contains("omadaTask")) { - R omadaResult = omadaTask.testOmadaApi(); - if (omadaResult.getCode() != 200) { - return error(omadaResult.getMsg()); + R omadaResult = omadaTask.testOmadaApi(); + if (!"success".equals(omadaResult.getData())) { + return error(omadaResult.getData()); } } diff --git a/wfc-modules/wfc-job/src/main/java/org/wfc/job/task/OmadaTask.java b/wfc-modules/wfc-job/src/main/java/org/wfc/job/task/OmadaTask.java index 1af1ec0..bd778d9 100644 --- a/wfc-modules/wfc-job/src/main/java/org/wfc/job/task/OmadaTask.java +++ b/wfc-modules/wfc-job/src/main/java/org/wfc/job/task/OmadaTask.java @@ -30,8 +30,8 @@ public class OmadaTask { log.info("wifi定时任务执行成功, 耗时:{} 毫秒", endTime - startTime); } - public R testOmadaApi() { - return remoteUserService.deviceJob(); + public R testOmadaApi() { + return remoteUserService.testJob(); } public R initJob() { diff --git a/wfc-modules/wfc-system/src/main/java/org/wfc/system/controller/SysDeviceController.java b/wfc-modules/wfc-system/src/main/java/org/wfc/system/controller/SysDeviceController.java index 7b7f2b6..a5ad48e 100644 --- a/wfc-modules/wfc-system/src/main/java/org/wfc/system/controller/SysDeviceController.java +++ b/wfc-modules/wfc-system/src/main/java/org/wfc/system/controller/SysDeviceController.java @@ -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 testJob() { + return R.ok(sysDeviceService.testJob()); + } } diff --git a/wfc-modules/wfc-system/src/main/java/org/wfc/system/service/ISysDeviceService.java b/wfc-modules/wfc-system/src/main/java/org/wfc/system/service/ISysDeviceService.java index 6fe4a3e..6c9afbb 100644 --- a/wfc-modules/wfc-system/src/main/java/org/wfc/system/service/ISysDeviceService.java +++ b/wfc-modules/wfc-system/src/main/java/org/wfc/system/service/ISysDeviceService.java @@ -16,4 +16,6 @@ public interface ISysDeviceService extends IService { boolean deviceJob(); boolean settingJob(); + + String testJob(); } diff --git a/wfc-modules/wfc-system/src/main/java/org/wfc/system/service/impl/SysDeviceServiceImpl.java b/wfc-modules/wfc-system/src/main/java/org/wfc/system/service/impl/SysDeviceServiceImpl.java index b3a153a..c602a37 100644 --- a/wfc-modules/wfc-system/src/main/java/org/wfc/system/service/impl/SysDeviceServiceImpl.java +++ b/wfc-modules/wfc-system/src/main/java/org/wfc/system/service/impl/SysDeviceServiceImpl.java @@ -53,8 +53,10 @@ public class SysDeviceServiceImpl extends ServiceImpl siteList = omadaSiteApi.getSiteList(1, 1000); if (siteList.getBody() == null) { @@ -92,6 +94,7 @@ public class SysDeviceServiceImpl extends ServiceImpl dataRetentionRes = omadaHistoryDataRetentionApi.getDataRetention(); @@ -115,4 +118,12 @@ public class SysDeviceServiceImpl extends ServiceImpl siteList = omadaSiteApi.getSiteList(1, 1000); + if (siteList.getBody() != null && siteList.getBody().getErrorCode() == OMADA_SUCCESS_CODE) { + return "success"; + } + return siteList.getBody().getMsg(); + } }