From 1a09dd79bd0b156ceb13470c312e44e522238780 Mon Sep 17 00:00:00 2001
From: liusuyi <1951119284@qq.com>
Date: Wed, 22 Oct 2025 16:52:33 +0800
Subject: [PATCH] 增加回复指令通过websocket返回给前端

---
 ard-work/src/main/java/com/ard/work/component/forest/MyAddressSource.java |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/ard-work/src/main/java/com/ard/work/component/forest/MyAddressSource.java b/ard-work/src/main/java/com/ard/work/component/forest/MyAddressSource.java
index c707967..7a49d70 100644
--- a/ard-work/src/main/java/com/ard/work/component/forest/MyAddressSource.java
+++ b/ard-work/src/main/java/com/ard/work/component/forest/MyAddressSource.java
@@ -1,23 +1,33 @@
 package com.ard.work.component.forest;
 
 import com.ard.work.domain.entity.ArdServerInfo;
-import com.ard.work.service.IArdServerService;
+import com.ard.work.service.IArdServerInfoService;
 import com.dtflys.forest.callback.AddressSource;
 import com.dtflys.forest.http.ForestAddress;
 import com.dtflys.forest.http.ForestRequest;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
 
+@Slf4j
 @Component
 public class MyAddressSource implements AddressSource {
 
     @Resource
-    private IArdServerService ardServerService;
+    private IArdServerInfoService ardServerService;
     @Override
     public ForestAddress getAddress(ForestRequest request) {
-        String serverKey = (String) request.getVariableValue("serverId");
-        ArdServerInfo serverInfo = ardServerService.selectArdServerManagementById(serverKey);
+        String serverKey = request.varAsString("serverId");
+        if(serverKey == null){
+            log.warn("请求属性serverId为空");
+            return null;
+        }
+        ArdServerInfo serverInfo = ardServerService.selectArdServerInfoById(serverKey);
+        if(serverInfo == null){
+            log.warn("边缘服务器不存在");
+            return null;
+        }
         // 返回 Forest 地址对象
         return new ForestAddress(serverInfo.getHost(), serverInfo.getHttpPort());
     }

--
Gitblit v1.9.3