Browse Source

更新文件 articleTweetAction.java

陈士柏 2 years ago
parent
commit
8fa221f041
1 changed files with 43 additions and 0 deletions
  1. 43 0
      mhotel/src/com/happy/action/articleTweetAction.java

+ 43 - 0
mhotel/src/com/happy/action/articleTweetAction.java

@@ -501,6 +501,49 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
 
                 return null;
             }
+            articleTweetService.delArticleFile(articleTweetDto.getId());
+            //添加附件
+            List<String> fileStr = new ArrayList<>();
+            if (articleTweetDto.getImages() != null && articleTweetDto.getImages().size() > 0) {
+                fileStr = articleTweetDto.getImages();
+            }
+            List<String> fileStrVideo = new ArrayList<>();
+            if (articleTweetDto.getVideo() != null && articleTweetDto.getVideo().length() > 0) {
+                fileStrVideo.add(articleTweetDto.getVideo());
+            }
+            List<ArticleFileInfo> afis = new ArrayList<>();
+            for (String f : fileStr) {
+                String[] split = f.split("/");
+                String fileName = split[split.length - 1];
+                ArticleFileInfo afi = new ArticleFileInfo();
+                afi.setLinkId(aId);
+                afi.setName(fileName);
+                afi.setType(1);
+                afi.setUrl(f);
+                afi.setCreateDate(now);
+                afi.setFileType(1);
+                afis.add(afi);
+            }
+            for (String f : fileStrVideo) {
+                String[] split = f.split("/");
+                String fileName = split[split.length - 1];
+                ArticleFileInfo afi = new ArticleFileInfo();
+                afi.setLinkId(aId);
+                afi.setName(fileName);
+                afi.setType(1);
+                afi.setUrl(f);
+                afi.setCreateDate(now);
+                afi.setFileType(2);
+                afis.add(afi);
+            }
+            int length = articleTweetService.insertArticleFileBatch(afis);
+            if (length <= 0) {
+                ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
+                    put("message", "推文附件新增失败");
+                    put("code", 500);
+                }}.toString());
+                return null;
+            }
         } catch (Exception e) {
             System.out.println("推文发布异常:" + e.getMessage());
             ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{