From 54c9594e75f551702a6734c47c3d190e195564cd Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期二, 01 七月 2025 16:54:31 +0800
Subject: [PATCH] 视频主页-点赞视频

---
 framework/src/main/resources/mapper/lmk/VideoMapper.xml                        |   35 +++++++++++
 buyer-api/src/main/java/cn/lili/controller/lmk/VideoController.java            |    6 ++
 framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java          |    9 +++
 framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java |  117 +++++++++++++++++++++++++++++++++-----
 framework/src/main/java/cn/lili/modules/lmk/domain/query/VideoQuery.java       |    2 
 framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java            |    8 ++
 6 files changed, 160 insertions(+), 17 deletions(-)

diff --git a/buyer-api/src/main/java/cn/lili/controller/lmk/VideoController.java b/buyer-api/src/main/java/cn/lili/controller/lmk/VideoController.java
index c0dce59..a8f665f 100644
--- a/buyer-api/src/main/java/cn/lili/controller/lmk/VideoController.java
+++ b/buyer-api/src/main/java/cn/lili/controller/lmk/VideoController.java
@@ -119,6 +119,12 @@
         return videoService.getAuthorCollectVideoPage(query);
     }
 
+    @GetMapping("/author-like-video-page")
+    @ApiOperation(value = "鑾峰彇瑙嗛涓婚〉浣滆�呯偣璧炵殑瑙嗛鍒嗛〉", notes = "鑾峰彇瑙嗛涓婚〉浣滆�呯偣璧炵殑瑙嗛鍒嗛〉")
+    public Result getAuthorLikeVideoPage(AuthorVideoQuery query) {
+        return videoService.getAuthorLikeVideoPage(query);
+    }
+
     @PostMapping("/home-page-info-edit")
     @ApiOperation(value = "淇濆瓨瑙嗛涓婚〉鐨勪釜浜轰俊鎭慨鏀�", notes = "淇濆瓨瑙嗛涓婚〉鐨勪釜浜轰俊鎭慨鏀�")
     public Result homePageInfoEdit(@RequestBody @Validated VideoHomePageInfoForm form) {
diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/query/VideoQuery.java b/framework/src/main/java/cn/lili/modules/lmk/domain/query/VideoQuery.java
index 8aa7959..832bf33 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/domain/query/VideoQuery.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/domain/query/VideoQuery.java
@@ -24,7 +24,7 @@
     @ApiModelProperty("浣滆�卛d")
     private String authorId;
 
-    @ApiModelProperty("瑙嗛鏉ユ簮锛歳ecommend鎺ㄨ崘銆乤uthor鏌愪綔鑰呯殑瑙嗛銆乧ollect鏌愪綔鑰呮敹钘忕殑瑙嗛")
+    @ApiModelProperty("瑙嗛鏉ユ簮锛歳ecommend鎺ㄨ崘銆乤uthor鏌愪綔鑰呯殑瑙嗛銆乧ollect鏌愪綔鑰呮敹钘忕殑瑙嗛銆乴ike鏌愪綔鑰呯偣璧炵殑瑙嗛")
     private String videoFrom;
 
     /**
diff --git a/framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java b/framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java
index 31c2ba2..252babb 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java
@@ -114,6 +114,14 @@
     IPage getAuthorCollectVideoPage(IPage page, @Param("query") AuthorVideoQuery query);
 
     /**
+     * 鑾峰彇瑙嗛涓婚〉浣滆�呯偣璧炵殑瑙嗛鍒嗛〉
+     *
+     * @param page
+     * @param query
+     */
+    IPage getAuthorLikeVideoPage(IPage page, @Param("query") AuthorVideoQuery query);
+
+    /**
      * 灏忕▼搴�-瑙嗛璇︽儏
      *
      * @param id
diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java b/framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java
index 054521f..96614ec 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java
@@ -165,6 +165,14 @@
     Result getAuthorCollectVideoPage(AuthorVideoQuery query);
 
     /**
+     * 鑾峰彇瑙嗛涓婚〉浣滆�呯偣璧炶棰戝垎椤�
+     *
+     * @param query
+     * @return
+     */
+    Result getAuthorLikeVideoPage(AuthorVideoQuery query);
+
+    /**
      * 淇濆瓨瑙嗛涓婚〉鐨勪釜浜轰俊鎭慨鏀�
      *
      * @param form
@@ -281,4 +289,5 @@
      * @param numList
      */
     void updateThumbsUpNumBatch(List<CollectTypeNumVO> numList);
+
 }
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());
     }
diff --git a/framework/src/main/resources/mapper/lmk/VideoMapper.xml b/framework/src/main/resources/mapper/lmk/VideoMapper.xml
index 03e49db..230ad1a 100644
--- a/framework/src/main/resources/mapper/lmk/VideoMapper.xml
+++ b/framework/src/main/resources/mapper/lmk/VideoMapper.xml
@@ -460,6 +460,41 @@
             LMC.create_time DESC
     </select>
 
+    <select id="getAuthorLikeVideoPage" resultMap="WxResultMap">
+        SELECT
+            LV.author_id,
+            LV.cover_url,
+            LV.video_fit,
+            LV.video_duration,
+            LV.video_file_key,
+            LV.title,
+            LV.goods_view_num,
+            LV.goods_order_num,
+            LV.recommend,
+            LV.status,
+            LV.play_num,
+            LV.comment_num,
+            LV.collect_num,
+            LV.thumbs_up_num,
+            LV.weight,
+            LV.audit_pass_time,
+            LV.update_time,
+            LV.video_content_type,
+            LV.video_type,
+            LV.video_imgs,
+            LV.id,
+            LM.nick_name as authorName,
+            LM.face as authorAvatar
+        FROM
+            lmk_thumbs_up_record LMC
+                INNER JOIN lmk_video LV ON LMC.ref_id = LV.id AND LV.delete_flag = 0 AND LV.status = '1'
+                LEFT JOIN li_member LM ON LV.author_id = LM.id
+        WHERE
+            LMC.delete_flag = 0 AND LMC.user_id = #{query.authorId} AND LMC.thumbs_up_type = 'video' AND LV.video_type = #{query.videoType}
+        ORDER BY
+            LMC.create_time DESC
+    </select>
+
 
     <!-- 寰俊瑙嗛缂栬緫璇︽儏 -->
     <resultMap id="WxEditResultMap" type="cn.lili.modules.lmk.domain.vo.WxEditVideoVO">

--
Gitblit v1.8.0