|
@@ -3,10 +3,13 @@ package com.fdkankan.tk.httpClient.client;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
public class RestTemplateLive {
|
|
@@ -19,19 +22,26 @@ public class RestTemplateLive {
|
|
|
public JSONObject getDanmaku(String wxRoomId){
|
|
|
String url = basePath + "/service/room-manager/danmaku/{wxRoomId}";
|
|
|
url = url.replace("{wxRoomId}",wxRoomId);
|
|
|
- ResponseEntity<JSONObject> responseEntity = restTemplate.getForEntity(url, JSONObject.class);
|
|
|
+ ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class);
|
|
|
log.info("getDanmaku:roomId:{},resp:{}",wxRoomId,responseEntity);
|
|
|
- return responseEntity.getBody();
|
|
|
+ if(responseEntity.getStatusCode() == HttpStatus.OK){
|
|
|
+ String body = responseEntity.getBody();
|
|
|
+ return JSONObject.parseObject(body);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
///service/room-manager/danmaku/delete/{wxRoomId}
|
|
|
|
|
|
public JSONObject deleteDanmaku(String wxRoomId){
|
|
|
String url = basePath + "/service/room-manager/danmaku/delete/{wxRoomId}";
|
|
|
url = url.replace("{wxRoomId}",wxRoomId);
|
|
|
- ResponseEntity<JSONObject> responseEntity = restTemplate.getForEntity(url, JSONObject.class);
|
|
|
+ ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class);
|
|
|
log.info("getDanmaku:roomId:{},resp:{}",wxRoomId,responseEntity);
|
|
|
- return responseEntity.getBody();
|
|
|
+ if(responseEntity.getStatusCode() == HttpStatus.OK){
|
|
|
+ String body = responseEntity.getBody();
|
|
|
+ return JSONObject.parseObject(body);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
}
|
|
|
}
|