瀏覽代碼

获取视频文件代码优化

fangzhen 6 月之前
父節點
當前提交
6ccfb16db9

+ 5 - 3
ruoyi-generator/src/main/java/com/ruoyi/generator/service/CommunityArticleServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ruoyi.generator.service;
 
+import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.common.core.domain.entity.SysUser;
@@ -132,14 +133,15 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
             articleVo.setClassIds(classIds);
             List<CommunityArticleImages> videoList = new ArrayList<>();
             CommunityArticleImages videos = null;
-            for (Map<String, Object> image : imageList) {
-                videos = new CommunityArticleImages();
+            List<Map<String, Object>> imageList_copy = new ArrayList<>(imageList);
+            for (Map<String, Object> image : imageList_copy) {
                 String imageUrl = image.get("imageUrl").toString();
                 //判断是否是视频
                 boolean isVideo = isVideoFile(imageUrl);
                 if (isVideo) {
                     imageList.remove(image);
-                    BeanUtils.copyProperties(image, videos);
+                    videos = JSONObject.parseObject(JSONObject.toJSONString(image), CommunityArticleImages.class);
+                    //BeanUtils.copyProperties(image, videos);
                     videoList.add(videos);
                 }
             }