From de026326a9df6f4a2192e99cf0e53e7e7b6d445d Mon Sep 17 00:00:00 2001
From: Xiajijian <1176061145@qq.com>
Date: Fri, 24 Oct 2025 17:29:33 +0800
Subject: [PATCH] 1.整理文件管理文件路径。 2.新增航线信息接口业务。 3.优化KMZ文件接口业务逻辑。 4.pom文件修改。 5.增加业务工具类。 6.增加部分业务注解。 7.增加修改无人机状态方法。
---
ard-work/src/main/java/com/ard/work/component/forest/TokenInterceptor.java | 24 ++++++++++++++++--------
1 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/ard-work/src/main/java/com/ard/work/component/forest/TokenInterceptor.java b/ard-work/src/main/java/com/ard/work/component/forest/TokenInterceptor.java
index 207fbce..2145b5e 100644
--- a/ard-work/src/main/java/com/ard/work/component/forest/TokenInterceptor.java
+++ b/ard-work/src/main/java/com/ard/work/component/forest/TokenInterceptor.java
@@ -3,14 +3,14 @@
import com.ard.work.domain.receiver.AccessTokenReceiver;
import com.ard.work.service.IArdServerInfoService;
import com.dtflys.forest.http.ForestRequest;
-import com.dtflys.forest.interceptor.Interceptor;
+import com.dtflys.forest.interceptor.ForestInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Component
@Slf4j
-public class TokenInterceptor<T> implements Interceptor<T> {
+public class TokenInterceptor implements ForestInterceptor {
@Resource
private IArdServerInfoService ardServerService;
@@ -21,11 +21,19 @@
*/
@Override
public boolean beforeExecute(ForestRequest req) {
- log.debug("invoke Simple beforeExecute");
- String serverId = (String) req.getVariableValue("serverId");
- AccessTokenReceiver accessToken = ardServerService.getAccessToken(serverId);
- req.addHeader("x-cid", accessToken.getCompanyId());
- req.addHeader("x-token", accessToken.getAccessToken());
- return true; // 继续执行请求返回true
+ try {
+ String serverId = (String) req.getVariableValue("serverId");
+ AccessTokenReceiver accessToken = ardServerService.getAccessToken(serverId);
+ if (accessToken == null) {
+ log.warn("AccessToken 为 null, serverId={}", serverId);
+ return false; // 阻止请求继续
+ }
+ req.addHeader("x-cid", accessToken.getCompanyId());
+ req.addHeader("x-token", accessToken.getAccessToken());
+ } catch (Exception e) {
+ log.error("TokenInterceptor 处理异常:{}", e.getMessage());
+ return false;
+ }
+ return true;
}
}
\ No newline at end of file
--
Gitblit v1.9.3