Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/master'

yangzian 3 rokov pred
rodič
commit
61b9d3bde1

+ 18 - 15
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/FileInfoServiceImpl.java

@@ -68,29 +68,32 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
 
     @Override
     public void uploadVideoToBytedance(String accountId, String videoUrl, String userId, String materialName) {
+        UserAllocation userAllocation = userAllocationService.getByAccountId(Long.parseLong(accountId));
+        Project project = projectService.getById(userAllocation.getProjectId());
         try {
             CtopOauthToken token = ctopOauthTokenService.getOauthTokenByAccountId(accountId);
             JSONObject jsonObject = videoUpload(token, videoUrl,materialName);
-            if (!Check.isNull(jsonObject)) {
-                Integer code = jsonObject.getInteger("code");
-                if (code == 0) {
-                    log.info("头条上传素材成功,返回信息:{},accountId:{}", jsonObject, accountId);
-                    //TODO 信息返回之后同步入库
-                } else {
-                    log.error("头条上传素材失败,返回信息:{},accountId:{}", jsonObject, accountId);
-                    UserAllocation allocation = userAllocationService.getByAccountId(Long.valueOf(accountId));
-                    Project project = projectService.getById(allocation.getProjectId());
-                    String message = messageTemplate.getMaterialSyncTemplate(project.getProjectName(), accountId, allocation.getAuthName(), materialName, jsonObject.getString("message"));
-                    sendMessageService.sendMessage(userId, message);
-                }
-
-            } else {
+            if (Check.isNull(jsonObject)) {
                 log.info("头条上传素材返回结果为空,返回信息:{},accountId:{}", jsonObject, accountId);
+                String message = messageTemplate.getMaterialSyncTemplate(project.getProjectName(), accountId, userAllocation.getAuthName(), materialName, "头条上传素材返回结果为空");
+                sendMessageService.sendMessage(userId, message);
+                return ;
             }
-
+            Integer code = jsonObject.getInteger("code");
+            if (code == 0) {
+                log.info("头条上传素材成功,返回信息:{},accountId:{}", jsonObject, accountId);
+                String message = messageTemplate.getMaterialSyncSucessTemplate(project.getProjectName(), accountId, userAllocation.getAuthName(), materialName, jsonObject.getString("message"));
+                sendMessageService.sendMessage(userId, message);
+                return ;
+            }
+            log.error("头条上传素材失败,返回信息:{},accountId:{}", jsonObject, accountId);
+            String message = messageTemplate.getMaterialSyncTemplate(project.getProjectName(), accountId, userAllocation.getAuthName(), materialName, jsonObject.getString("message"));
+            sendMessageService.sendMessage(userId, message);
         } catch (Exception e) {
             log.error("头条上传视频文件失败,accountId:{}", accountId);
             e.printStackTrace();
+            String message = messageTemplate.getMaterialSyncTemplate(project.getProjectName(), accountId, userAllocation.getAuthName(), materialName, "头条api上传素材返回结果异常:系统异常,联系研发人员");
+            sendMessageService.sendMessage(userId, message);
         }
     }