Bläddra i källkod

Merge branch '20250925-wyp-uploadVideo' into test

wangyunpeng 3 veckor sedan
förälder
incheckning
325b5b8c90

+ 3 - 1
api-module/src/main/java/com/tzld/piaoquan/api/common/enums/ExceptionEnum.java

@@ -56,7 +56,9 @@ public enum ExceptionEnum {
     PQ_LOGIN_FAIL(6001, "票圈登录失败"),
     VIDEO_PUBLISH_FAILED(6002, "视频发布失败"),
     VIDEO_UPDATE_FAILED(6003, "视频更新失败"),
-    PQ_ACCOUNT_NOT_BINDING(6004, "票圈账号未绑定"),
+    VIDEO_DELETE_FAILED(6004, "视频删除失败"),
+    VIDEO_INFO_FAILED(6005, "视频信息获取失败"),
+    PQ_ACCOUNT_NOT_BINDING(6006, "票圈账号未绑定"),
 
     // 自动回复
     CGI_REPLY_BUCKET_DATA_NOT_FOUND(10000, "自动回复数据不存在"),

+ 23 - 9
api-module/src/main/java/com/tzld/piaoquan/api/component/VideoApiService.java

@@ -92,7 +92,8 @@ public class VideoApiService {
         }
         if (res.getInteger("code") != 0) {
             log.error("publishVideo error, uid:{} videoUrl={} coverUrl={} title={} res={}", uid, videoUrl, coverUrl, title, res);
-            throw new CommonException(ExceptionEnum.VIDEO_PUBLISH_FAILED.getCode(), res.getString("msg"));
+            throw new CommonException(ExceptionEnum.VIDEO_PUBLISH_FAILED.getCode(),
+                    ExceptionEnum.VIDEO_PUBLISH_FAILED.getMsg() + "," + res.getString("msg"));
         }
         JSONObject data = res.getJSONObject("data");
         Long videoId = data.getLong("id");
@@ -136,33 +137,46 @@ public class VideoApiService {
 
     public JSONObject getVideoInfo(Long videoId) {
         String url = videoApiHost + "/longvideoapi/openapi/video/getVideoInfo";
+        JSONObject res = null;
         try {
             JSONObject param = new JSONObject();
             param.put("videoId", videoId);
             String post = httpPoolClient.post(url, param.toJSONString());
-            JSONObject res = JSONObject.parseObject(post);
-            if (res.getInteger("code") != 0) {
-                log.error("getVideoInfo error, videoId={} res={}", videoId, res);
-                throw new CommonException(ExceptionEnum.VIDEO_PUBLISH_FAILED.getCode(), res.getString("msg"));
-            }
-            return res.getJSONObject("data");
+            res = JSONObject.parseObject(post);
         } catch (Exception e) {
             log.error("getVideoInfo error", e);
         }
-        return null;
+        if (Objects.isNull(res)) {
+            throw new CommonException(ExceptionEnum.VIDEO_INFO_FAILED);
+        }
+        if (res.getInteger("code") != 0) {
+            log.error("getVideoInfo error, videoId={} res={}", videoId, res);
+            throw new CommonException(ExceptionEnum.VIDEO_INFO_FAILED.getCode(),
+                    ExceptionEnum.VIDEO_INFO_FAILED.getMsg() + "," + res.getString("msg"));
+        }
+        return res.getJSONObject("data");
     }
 
     public void deleteVideo(Long uid, Long videoId) {
         String url = videoApiHost + "/longvideoapi/openapi/video/delete";
+        JSONObject res = null;
         try {
             JSONObject param = new JSONObject();
             param.put("loginUid", uid);
             param.put("videoId", videoId);
             String post = httpPoolClient.post(url, param.toJSONString());
-            JSONObject res = JSONObject.parseObject(post);
+            res = JSONObject.parseObject(post);
         } catch (Exception e) {
             log.error("deleteVideo error", e);
         }
+        if (Objects.isNull(res)) {
+            throw new CommonException(ExceptionEnum.VIDEO_DELETE_FAILED);
+        }
+        if (res.getInteger("code") != 0) {
+            log.error("getVideoInfo error, videoId={} res={}", videoId, res);
+            throw new CommonException(ExceptionEnum.VIDEO_DELETE_FAILED.getCode(),
+                    ExceptionEnum.VIDEO_DELETE_FAILED.getMsg() + "," + res.getString("msg"));
+        }
     }
 
 }