Kaynağa Gözat

Merge remote-tracking branch 'origin/sit' into sit

liudongzhi 2 ay önce
ebeveyn
işleme
8c314041f7

+ 28 - 0
alien-store/src/main/java/shop/alien/store/service/impl/LifeUserViolationServiceImpl.java

@@ -786,6 +786,17 @@ public class LifeUserViolationServiceImpl extends ServiceImpl<LifeUserViolationM
                         .map(String::trim)
                         .filter(StringUtils::isNotEmpty)
                         .collect(Collectors.toList());
+                // 如果包含视频,则过滤掉图片(视频封面/第一帧),只保留用户实际上传的视频
+                boolean hasVideo = imagePathList.stream().anyMatch(url -> {
+                    String ext = url.substring(url.lastIndexOf(".") + 1).toLowerCase();
+                    return videoFileType.contains(ext);
+                });
+                if (hasVideo) {
+                    imagePathList = imagePathList.stream().filter(url -> {
+                        String ext = url.substring(url.lastIndexOf(".") + 1).toLowerCase();
+                        return videoFileType.contains(ext);
+                    }).collect(Collectors.toList());
+                }
                 item.setDynamicsImg(imagePathList);
             }
         }
@@ -811,6 +822,17 @@ public class LifeUserViolationServiceImpl extends ServiceImpl<LifeUserViolationM
                         .map(String::trim)
                         .filter(StringUtils::isNotEmpty)
                         .collect(Collectors.toList());
+                // 如果包含视频,则过滤掉图片(视频封面/第一帧),只保留用户实际上传的视频
+                boolean hasVideo = imagePathList.stream().anyMatch(url -> {
+                    String ext = url.substring(url.lastIndexOf(".") + 1).toLowerCase();
+                    return videoFileType.contains(ext);
+                });
+                if (hasVideo) {
+                    imagePathList = imagePathList.stream().filter(url -> {
+                        String ext = url.substring(url.lastIndexOf(".") + 1).toLowerCase();
+                        return videoFileType.contains(ext);
+                    }).collect(Collectors.toList());
+                }
                 item.setDynamicsImg(imagePathList);
             }
         }
@@ -835,6 +857,12 @@ public class LifeUserViolationServiceImpl extends ServiceImpl<LifeUserViolationM
                 list.add(map);
             }
 
+            // 如果包含视频,则过滤掉图片(视频封面),只保留用户实际上传的视频
+            boolean hasVideo = list.stream().anyMatch(map -> "video".equals(map.get("type")));
+            if (hasVideo) {
+                list = list.stream().filter(map -> "video".equals(map.get("type"))).collect(Collectors.toList());
+            }
+
             item.setImgList(list);
         }