Pārlūkot izejas kodu

Merge branch '20250925-wyp-uploadVideo' into test

wangyunpeng 3 nedēļas atpakaļ
vecāks
revīzija
c7f9c742e1

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

@@ -55,7 +55,8 @@ public enum ExceptionEnum {
     // 用户上传内容管理
     PQ_LOGIN_FAIL(6001, "票圈登录失败"),
     VIDEO_PUBLISH_FAILED(6002, "视频发布失败"),
-    PQ_ACCOUNT_NOT_BINDING(6003, "票圈账号未绑定"),
+    VIDEO_UPDATE_FAILED(6003, "视频更新失败"),
+    PQ_ACCOUNT_NOT_BINDING(6004, "票圈账号未绑定"),
 
     // 自动回复
     CGI_REPLY_BUCKET_DATA_NOT_FOUND(10000, "自动回复数据不存在"),

+ 33 - 1
api-module/src/main/java/com/tzld/piaoquan/api/component/VideoApiService.java

@@ -96,23 +96,55 @@ public class VideoApiService {
         return null;
     }
 
-    public void updateVideo(Long uid, Long videoId, String coverUrl, String title) {
+    public String updateVideo(Long uid, Long videoId, String coverUrl, String title) {
         String url = videoApiHost + "/longvideoapi/openapi/video/update";
+        String result = null;
         try {
+            JSONObject videoDetail = getVideoInfo(videoId);
+            JSONObject chargeDetail = videoDetail.getJSONObject("chargeDetail");
             JSONObject param = new JSONObject();
             param.put("loginUid", uid);
+            param.put("id", videoId);
             param.put("videoId", videoId);
+            param.put("appType", 8);
             param.put("coverImgPath", coverUrl);
             param.put("title", title);
+            param.put("viewStatus", 1);
+            param.put("videoCollectionId", videoDetail.getLong("videoCollectionId"));
+            param.put("barrageSwitch", videoDetail.getLong("barrageSwitch"));
+            param.put("charge", chargeDetail.getInteger("charge"));
+            param.put("price", chargeDetail.getLong("price"));
+            param.put("allowIosPlay", chargeDetail.getLong("allowIosPlay"));
+            param.put("allowDownload", 0);
             String post = httpPoolClient.post(url, param.toJSONString());
             JSONObject res = JSONObject.parseObject(post);
             if (res.getInteger("code") != 0) {
                 log.error("updateVideo error, uid:{} videoId={} coverUrl={} title={} res={}", uid, videoId, coverUrl, title, res);
+                result = res.getString("msg");
                 throw new CommonException(ExceptionEnum.VIDEO_PUBLISH_FAILED.getCode(), res.getString("msg"));
             }
         } catch (Exception e) {
             log.error("updateVideo error", e);
         }
+        return result;
+    }
+
+    public JSONObject getVideoInfo(Long videoId) {
+        String url = videoApiHost + "/longvideoapi/openapi/video/getVideoInfo";
+        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");
+        } catch (Exception e) {
+            log.error("getVideoInfo error", e);
+        }
+        return null;
     }
 
     public void deleteVideo(Long uid, Long videoId) {

+ 5 - 1
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformUploadContentServiceImpl.java

@@ -79,7 +79,11 @@ public class ContentPlatformUploadContentServiceImpl implements ContentPlatformU
         uploadVideoMapper.updateByPrimaryKeySelective(uploadVideo);
         // 调用修改视频接口
         ContentPlatformPqAccountRel pqAccountRel = settingService.getPqAccountRel(user.getId());
-        videoApiService.updateVideo(pqAccountRel.getPqUid(), uploadVideo.getVideoId(), param.getCoverUrl(), param.getTitle());
+        String result = videoApiService.updateVideo(pqAccountRel.getPqUid(), uploadVideo.getVideoId(), param.getCoverUrl(), param.getTitle());
+        if (StringUtils.isNotBlank(result)) {
+            throw new CommonException(ExceptionEnum.VIDEO_UPDATE_FAILED.getCode(),
+                    ExceptionEnum.VIDEO_UPDATE_FAILED.getMsg() + "," + result);
+        }
         return UploadVideoItemVO.convert(uploadVideo);
     }