夏文涛 2 лет назад
Родитель
Сommit
d8f5776fe9
1 измененных файлов с 11 добавлено и 6 удалено
  1. 11 6
      mhotel/src/com/happy/action/articleTweetAction.java

+ 11 - 6
mhotel/src/com/happy/action/articleTweetAction.java

@@ -1,5 +1,6 @@
 package com.happy.action;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baidubce.model.User;
 import com.google.gson.Gson;
@@ -92,6 +93,9 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
             return null;
         }
 
+        //推文发布参数
+        System.out.println("推文发布参数:"+ JSON.toJSON(articleTweetDto));
+
         //查询当前用户
         Users user = userService.queryByUserId(String.valueOf(articleTweetDto.getCreateId()));
         if (user == null) {
@@ -129,7 +133,7 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
 
             //添加附件
             List<String> fileStr = new ArrayList<>();
-            if (articleTweetDto.getImages() != null) {
+            if (articleTweetDto.getImages() != null && articleTweetDto.getImages().size() > 0) {
                 fileStr = articleTweetDto.getImages();
             } else {
                 fileStr.add(articleTweetDto.getVideo());
@@ -150,7 +154,7 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
             int length = articleTweetService.insertArticleFileBatch(afis);
             if (length <= 0) {
                 ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
-                    put("message", "推文发布失败");
+                    put("message", "推文附件新增失败");
                     put("code", 500);
                 }}.toString());
                 return null;
@@ -166,18 +170,19 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
             workflow.setId(id);
             workflow.setStatus(1);//1是正在审批
             workflow.setType(3);//3是推文
-            workflow.setCoverImg(articleTweetDto.getImages() != null ? articleTweetDto.getImages().get(0) : articleTweetDto.getVideo());
+            workflow.setCoverImg(articleTweetDto.getImages() != null && articleTweetDto.getImages().size() > 0 ? articleTweetDto.getImages().get(0) : articleTweetDto.getVideo());
             int i = workflowService.insert(workflow);
             if (i <= 0) {
                 ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
-                    put("message", "推文发布失败");
+                    put("message", "推文流程发布失败");
                     put("code", 500);
                 }}.toString());
                 return null;
             }
         } catch (Exception e) {
+            System.out.println("推文发布异常:"+e.getMessage());
             ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
-                put("message", "推文发布失败");
+                put("message", "推文发布异常");
                 put("code", 500);
             }}.toString());
             return null;
@@ -659,7 +664,7 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
             List<FileInfo> fileInfos = articleTweetService.queryList("and link_id in (" + articleIds + ")");
 
             for (OwnerArticleVo data : result.getPageList()) {
-                List<FileInfo> fileInfoList = fileInfos.stream().filter(e -> e.getLinkId().equals(data.getId().toString())).collect(Collectors.toList());
+                List<FileInfo> fileInfoList = fileInfos == null ? null : fileInfos.stream().filter(e -> e.getLinkId().equals(data.getId().toString())).collect(Collectors.toList());
                 if (fileInfoList != null) {
                     if (fileInfoList.size() > 1) {
                         data.setImages(fileInfoList.stream().map(FileInfo::getUrl).collect(Collectors.toList()));