From aac2321d1cf5536f7ea03f30d55a4aba30fbf710 Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期三, 02 七月 2025 10:39:39 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev

---
 framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java |  117 ++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 101 insertions(+), 16 deletions(-)

diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java
index e26fe9e..cdfff28 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java
@@ -464,6 +464,10 @@
                 query2.setAuthorId(query.getAuthorId());
                 baseMapper.getAuthorCollectVideoPage(page, query2);
                 break;
+            case "like":
+                AuthorVideoQuery query3 = new AuthorVideoQuery();
+                query3.setAuthorId(query.getAuthorId());
+                baseMapper.getAuthorLikeVideoPage(page, query3);
             default:
                 break;
         }
@@ -651,16 +655,39 @@
         IPage<WxVideoVO> page = PageUtil.getPage(query, WxVideoVO.class);
         query.setAuthorSelf(UserContext.getCurrentUserId().equals(query.getAuthorId()));
         baseMapper.getAuthorVideoPage(page, query);
-        for (WxVideoVO vo : page.getRecords()) {
-            if (VideoContentTypeEnum.VIDEO.getValue().equals(vo.getVideoContentType())) {
-                vo.setVideoUrl(cosUtil.getPreviewUrl(vo.getVideoFileKey()));
-                vo.setCoverUrl(cosUtil.getPreviewUrl(vo.getCoverFileKey()));
-            } else if (VideoContentTypeEnum.IMG.getValue().equals(vo.getVideoContentType()) && StringUtils.isNotBlank(vo.getVideoImgs())) {
-                vo.setImgs(JSON.parseArray(vo.getVideoImgs(), String.class).stream().map(fileKey -> cosUtil.getPreviewUrl(fileKey)).collect(Collectors.toList()));
+        List<String> videoIds = page.getRecords().stream().map(WxVideoVO::getId).collect(Collectors.toList());
+        Map<String, List<SimpleVideoTagVO>> tagMap = videoTagRefService.getTagsByVideoIds(videoIds)
+                .stream()
+                .collect(Collectors.groupingBy(SimpleVideoTagVO::getVideoId));
+        Map<String, List<SimpleMyCollectVO>> collectMap = myCollectService.getCollectsByVideoIds(videoIds)
+                .stream()
+                .collect(Collectors.groupingBy(SimpleMyCollectVO::getRefId));
+        Map<String, List<SimpleMyThumbsUpVO>> thumbsUpMap = thumbsUpRecordService.getThumbssByVideoIds(videoIds)
+                .stream()
+                .collect(Collectors.groupingBy(SimpleMyThumbsUpVO::getRefId));
+        List<String> subscribes = mySubscribeService.getSubscribesByUserId(UserContext.getCurrentUserId());
+        if (CollectionUtils.isNotEmpty(page.getRecords())) {
+            for (WxVideoVO v : page.getRecords()) {
+                v.setTagList(tagMap.get(v.getId()));
+                v.setCollected(CollectionUtils.isNotEmpty(collectMap.get(v.getId())));
+                v.setThumbsUp(CollectionUtils.isNotEmpty(thumbsUpMap.get(v.getId())));
+                v.setCommentNum(this.getCommentNum(v.getId(), v.getCommentNum()));
+                v.setCollectNum(this.getCollectNum(v.getId(), v.getCollectNum()));
+                v.setThumbsUpNum(this.getThumbsUpNum(v.getId(), v.getThumbsUpNum()));
+                if (VideoContentTypeEnum.VIDEO.getValue().equals(v.getVideoContentType())) {
+                    v.setVideoUrl(cosUtil.getPreviewUrl(v.getVideoFileKey()));
+                    v.setCoverUrl(cosUtil.getPreviewUrl(v.getCoverFileKey()));
+                } else if (VideoContentTypeEnum.IMG.getValue().equals(v.getVideoContentType()) && StringUtils.isNotBlank(v.getVideoImgs())) {
+                    v.setImgs(JSON.parseArray(v.getVideoImgs(), String.class).stream().map(fileKey -> cosUtil.getPreviewUrl(fileKey)).collect(Collectors.toList()));
+                }
+                v.setOptions(VideoSupportOpEnum.getVideoOpByStatus(v.getStatus()));
+                if (CollectionUtils.isNotEmpty(v.getGoodsList())) {
+                    v.getGoodsList().stream().forEach(goods -> {
+                        goods.setThumbnail(cosUtil.getPreviewUrl(goods.getThumbnail()));
+                    });
+                }
+                v.setSubscribeThisAuthor(subscribes.contains(v.getAuthorId()));
             }
-
-
-            vo.setOptions(VideoSupportOpEnum.getVideoOpByStatus(vo.getStatus()));
         }
         return Result.ok().data(page.getRecords()).total(page.getTotal());
     }
@@ -669,14 +696,72 @@
     public Result getAuthorCollectVideoPage(AuthorVideoQuery query) {
         IPage<WxVideoVO> page = PageUtil.getPage(query, WxVideoVO.class);
         baseMapper.getAuthorCollectVideoPage(page, query);
-        for (WxVideoVO vo : page.getRecords()) {
-            if (VideoContentTypeEnum.VIDEO.getValue().equals(vo.getVideoContentType())) {
-                vo.setVideoUrl(cosUtil.getPreviewUrl(vo.getVideoFileKey()));
-                vo.setCoverUrl(cosUtil.getPreviewUrl(vo.getCoverFileKey()));
-            } else if (VideoContentTypeEnum.IMG.getValue().equals(vo.getVideoContentType()) && StringUtils.isNotBlank(vo.getVideoImgs())) {
-                vo.setImgs(JSON.parseArray(vo.getVideoImgs(), String.class).stream().map(fileKey -> cosUtil.getPreviewUrl(fileKey)).collect(Collectors.toList()));
+        if (CollectionUtils.isNotEmpty(page.getRecords())) {
+            List<String> videoIds = page.getRecords().stream().map(WxVideoVO::getId).collect(Collectors.toList());
+            Map<String, List<SimpleVideoTagVO>> tagMap = videoTagRefService.getTagsByVideoIds(videoIds)
+                    .stream()
+                    .collect(Collectors.groupingBy(SimpleVideoTagVO::getVideoId));
+            Map<String, List<SimpleMyThumbsUpVO>> thumbsUpMap = thumbsUpRecordService.getThumbssByVideoIds(videoIds)
+                    .stream()
+                    .collect(Collectors.groupingBy(SimpleMyThumbsUpVO::getRefId));
+            List<String> subscribes = mySubscribeService.getSubscribesByUserId(UserContext.getCurrentUserId());
+            for (WxVideoVO v : page.getRecords()) {
+                v.setTagList(tagMap.get(v.getId()));
+                v.setCollected(Boolean.TRUE);
+                v.setThumbsUp(CollectionUtils.isNotEmpty(thumbsUpMap.get(v.getId())));
+                v.setCommentNum(this.getCommentNum(v.getId(), v.getCommentNum()));
+                v.setCollectNum(this.getCollectNum(v.getId(), v.getCollectNum()));
+                v.setThumbsUpNum(this.getThumbsUpNum(v.getId(), v.getThumbsUpNum()));
+                if (VideoContentTypeEnum.VIDEO.getValue().equals(v.getVideoContentType())) {
+                    v.setVideoUrl(cosUtil.getPreviewUrl(v.getVideoFileKey()));
+                    v.setCoverUrl(cosUtil.getPreviewUrl(v.getCoverFileKey()));
+                } else if (VideoContentTypeEnum.IMG.getValue().equals(v.getVideoContentType()) && StringUtils.isNotBlank(v.getVideoImgs())) {
+                    v.setImgs(JSON.parseArray(v.getVideoImgs(), String.class).stream().map(fileKey -> cosUtil.getPreviewUrl(fileKey)).collect(Collectors.toList()));
+                }
+                if (CollectionUtils.isNotEmpty(v.getGoodsList())) {
+                    v.getGoodsList().stream().forEach(goods -> {
+                        goods.setThumbnail(cosUtil.getPreviewUrl(goods.getThumbnail()));
+                    });
+                }
+                v.setSubscribeThisAuthor(subscribes.contains(v.getAuthorId()));
             }
-            vo.setCollected(Boolean.TRUE);
+        }
+        return Result.ok().data(page.getRecords()).total(page.getTotal());
+    }
+
+    @Override
+    public Result getAuthorLikeVideoPage(AuthorVideoQuery query) {
+        IPage<WxVideoVO> page = PageUtil.getPage(query, WxVideoVO.class);
+        baseMapper.getAuthorLikeVideoPage(page, query);
+        if (CollectionUtils.isNotEmpty(page.getRecords())) {
+            List<String> videoIds = page.getRecords().stream().map(WxVideoVO::getId).collect(Collectors.toList());
+            Map<String, List<SimpleVideoTagVO>> tagMap = videoTagRefService.getTagsByVideoIds(videoIds)
+                    .stream()
+                    .collect(Collectors.groupingBy(SimpleVideoTagVO::getVideoId));
+            Map<String, List<SimpleMyCollectVO>> collectMap = myCollectService.getCollectsByVideoIds(videoIds)
+                    .stream()
+                    .collect(Collectors.groupingBy(SimpleMyCollectVO::getRefId));
+            List<String> subscribes = mySubscribeService.getSubscribesByUserId(UserContext.getCurrentUserId());
+            for (WxVideoVO v : page.getRecords()) {
+                v.setTagList(tagMap.get(v.getId()));
+                v.setCollected(CollectionUtils.isNotEmpty(collectMap.get(v.getId())));
+                v.setThumbsUp(Boolean.TRUE);
+                v.setCommentNum(this.getCommentNum(v.getId(), v.getCommentNum()));
+                v.setCollectNum(this.getCollectNum(v.getId(), v.getCollectNum()));
+                v.setThumbsUpNum(this.getThumbsUpNum(v.getId(), v.getThumbsUpNum()));
+                if (VideoContentTypeEnum.VIDEO.getValue().equals(v.getVideoContentType())) {
+                    v.setVideoUrl(cosUtil.getPreviewUrl(v.getVideoFileKey()));
+                    v.setCoverUrl(cosUtil.getPreviewUrl(v.getCoverFileKey()));
+                } else if (VideoContentTypeEnum.IMG.getValue().equals(v.getVideoContentType()) && StringUtils.isNotBlank(v.getVideoImgs())) {
+                    v.setImgs(JSON.parseArray(v.getVideoImgs(), String.class).stream().map(fileKey -> cosUtil.getPreviewUrl(fileKey)).collect(Collectors.toList()));
+                }
+                if (CollectionUtils.isNotEmpty(v.getGoodsList())) {
+                    v.getGoodsList().stream().forEach(goods -> {
+                        goods.setThumbnail(cosUtil.getPreviewUrl(goods.getThumbnail()));
+                    });
+                }
+                v.setSubscribeThisAuthor(subscribes.contains(v.getAuthorId()));
+            }
         }
         return Result.ok().data(page.getRecords()).total(page.getTotal());
     }

--
Gitblit v1.8.0