zhaowenyu
2025-10-14 f905f4377db462640a4fdd53dc5daa1adfc8c542
ard-work/src/main/java/com/ard/work/component/forest/MyAddressSource.java
New file
@@ -0,0 +1,24 @@
package com.ard.work.component.forest;
import com.ard.work.domain.entity.ArdServerInfo;
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 org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Component
public class MyAddressSource implements AddressSource {
    @Resource
    private IArdServerInfoService ardServerService;
    @Override
    public ForestAddress getAddress(ForestRequest request) {
        String serverKey = request.varAsString("serverId");
        ArdServerInfo serverInfo = ardServerService.selectArdServerManagementById(serverKey);
        // 返回 Forest 地址对象
        return new ForestAddress(serverInfo.getHost(), serverInfo.getHttpPort());
    }
}