Просмотр исходного кода

Merge branch 'dev-xym-update-match-video' of Server/long-article-manage into master

xueyiming 4 дней назад
Родитель
Сommit
911922d6db

+ 14 - 12
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/utils/VideoUtils.java

@@ -16,19 +16,21 @@ public class VideoUtils {
 
 
     public static JSONObject getVideoDetail(Long videoId) {
-        JSONObject params = new JSONObject();
-        Map<String, Object> data = new HashMap<>();
-        data.put("videoIdList", new String[]{String.valueOf(videoId)});
-        HttpResponse response = HttpRequest.post(VIDEO_DETAIL_URL)
-                .header("Content-Type", "application/json")
-                .body(JSONUtil.toJsonStr(data)) // 将数据转换为 JSON 字符串
-                .execute();
-        JSONObject jsonObject = JSONObject.parseObject(response.body());
-        if (jsonObject.getJSONArray("data") != null) {
-            return jsonObject.getJSONArray("data").getJSONObject(0);
-        } else {
-            return null;
+        try {
+            Map<String, Object> data = new HashMap<>();
+            data.put("videoIdList", new String[]{String.valueOf(videoId)});
+            HttpResponse response = HttpRequest.post(VIDEO_DETAIL_URL)
+                    .header("Content-Type", "application/json")
+                    .body(JSONUtil.toJsonStr(data)) // 将数据转换为 JSON 字符串
+                    .execute();
+            JSONObject jsonObject = JSONObject.parseObject(response.body());
+            if (jsonObject.getJSONArray("data") != null) {
+                return jsonObject.getJSONArray("data").getJSONObject(0);
+            }
+        } catch (Exception e) {
+            log.error("VideoUtils getVideoDetail error", e);
         }
+        return null;
     }
 
     public static void main(String[] args) {