package com.ruoyi.rongcloud.service; import com.dtflys.forest.callback.AddressSource; import com.dtflys.forest.http.ForestAddress; import com.dtflys.forest.http.ForestRequest; import com.ruoyi.common.core.redis.RedisCache; import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.net.MalformedURLException; import java.net.URL; /** * @Description: * @ClassName: MyAddressSource * @Author: 刘苏义 * @Date: 2023年07月17日13:40:46 * @Version: 1.0 **/ @Component public class MyAddressSource implements AddressSource { @Resource RedisCache redisCache; @Override public ForestAddress getAddress(ForestRequest forestRequest) { String apiUrl = redisCache.getCacheObject("sys_config:rongyun"); URL url = null; try { url = new URL(apiUrl); } catch (MalformedURLException e) { e.printStackTrace(); } String host = url.getHost(); int port = url.getPort(); return new ForestAddress(host,port); } }