lyhzzz 2 лет назад
Родитель
Сommit
eff9ab885f

+ 21 - 0
src/main/java/com/fdkankan/tk/httpClient/address/SocketAddressSource.java

@@ -0,0 +1,21 @@
+package com.fdkankan.tk.httpClient.address;
+
+import com.dtflys.forest.callback.AddressSource;
+import com.dtflys.forest.http.ForestAddress;
+import com.dtflys.forest.http.ForestRequest;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+@Component
+public class SocketAddressSource implements AddressSource {
+
+    @Value("${4dkk.SocketService.basePath}")
+    private String basePath;
+    @Value("${4dkk.SocketService.host}")
+    private String host;
+
+    @Override
+    public ForestAddress getAddress(ForestRequest forestRequest) {
+        return new ForestAddress("",host,null,basePath);
+    }
+}

+ 2 - 1
src/main/java/com/fdkankan/tk/httpClient/client/LiveClient.java

@@ -3,6 +3,7 @@ package com.fdkankan.tk.httpClient.client;
 import com.alibaba.fastjson.JSONObject;
 import com.dtflys.forest.annotation.*;
 import com.fdkankan.tk.httpClient.address.FdkkAddressSource;
+import com.fdkankan.tk.httpClient.address.SocketAddressSource;
 import com.fdkankan.tk.httpClient.request.WxGetPhoneParam;
 import com.fdkankan.tk.httpClient.request.WxGetQrCodeParam;
 import com.fdkankan.tk.httpClient.response.WxOpenIdVo;
@@ -10,7 +11,7 @@ import com.fdkankan.tk.httpClient.response.WxOpenIdVo;
 /**
  * 获取,调用4dkk服务
  */
-@Address(source = FdkkAddressSource.class)
+@Address(source = SocketAddressSource.class)
 public interface LiveClient {
 
     /**

+ 1 - 0
src/main/java/com/fdkankan/tk/httpClient/client/RestTemplateLive.java

@@ -1,6 +1,7 @@
 package com.fdkankan.tk.httpClient.client;
 
 import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.tk.common.util.RoomUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;

+ 4 - 2
src/main/java/com/fdkankan/tk/service/impl/RoomDanmakuServiceImpl.java

@@ -36,12 +36,14 @@ public class RoomDanmakuServiceImpl extends ServiceImpl<IRoomDanmakuMapper, Room
 
     @Autowired
     RestTemplateLive restTemplateLive;
+    @Autowired
+    LiveClient liveClient;
 
     @Override
     public void saveDanMaku(String roomId,Integer roomUserId) {
         String wxRoomId = RoomUtil.getLiveRoomId( roomId , roomUserId);
         List<RoomDanmaku> saveList = new ArrayList<>();
-        JSONObject jsonObject = restTemplateLive.getDanmaku(wxRoomId);
+        JSONObject jsonObject = liveClient.getDanmaku(wxRoomId);
         if(jsonObject != null && jsonObject.getInteger("code") ==0){
             JSONArray data = jsonObject.getJSONArray("data");
             if(data.size() >0){
@@ -63,7 +65,7 @@ public class RoomDanmakuServiceImpl extends ServiceImpl<IRoomDanmakuMapper, Room
             }
         }
         if(saveList.size() >0){
-            restTemplateLive.deleteDanmaku(wxRoomId);
+            liveClient.deleteDanmaku(wxRoomId);
             this.saveBatch(saveList);
         }
     }