From 6378b1e03b15e66ce58ebdb0f748f1330e2324d9 Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期二, 05 八月 2025 09:14:15 +0800
Subject: [PATCH] 修改首页视频显示问题

---
 framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoTagRefServiceImpl.java    |    5 +
 framework/src/main/resources/mapper/lmk/VideoMapper.xml                                 |  104 ++++++++++++++++++++++++++++++++--
 framework/src/main/java/cn/lili/modules/lmk/service/impl/ThumbsUpRecordServiceImpl.java |    4 +
 framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java          |   26 +++++++-
 framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java                     |    2 
 framework/src/main/java/cn/lili/modules/lmk/service/impl/MyCollectServiceImpl.java      |    8 +-
 6 files changed, 133 insertions(+), 16 deletions(-)

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 d6fad30..e4b4bf8 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
@@ -85,6 +85,8 @@
      */
     VideoAccountVO getAuthorInfo(@Param("authorId") String authorId, @Param("currentUserId") String currentUserId);
 
+    VideoAccountVO getAuthorInfoAdmin(@Param("authorId") String authorId, @Param("currentUserId") String currentUserId);
+
     /**
      * 鑾峰彇浣滆�呯殑鎵�鏈夎棰慽d
      *
diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/MyCollectServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/MyCollectServiceImpl.java
index c2ae06e..abc3a70 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/service/impl/MyCollectServiceImpl.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/MyCollectServiceImpl.java
@@ -34,10 +34,7 @@
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -169,6 +166,9 @@
 
     @Override
     public List<SimpleMyCollectVO> getCollectsByVideoIds(List<String> videoIds) {
+        if (videoIds == null || videoIds.isEmpty()) {
+            return new ArrayList<>();
+        }
         return baseMapper.getCollectsByVideoIds(videoIds, UserContext.getCurrentUserId());
     }
 
diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/ThumbsUpRecordServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/ThumbsUpRecordServiceImpl.java
index e3ec3f0..2bee8c4 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/service/impl/ThumbsUpRecordServiceImpl.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/ThumbsUpRecordServiceImpl.java
@@ -18,6 +18,7 @@
 import org.springframework.beans.BeanUtils;
 import org.springframework.util.Assert;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -104,6 +105,9 @@
 
     @Override
     public List<SimpleMyThumbsUpVO> getThumbssByVideoIds(List<String> videoIds) {
+        if (videoIds == null || videoIds.isEmpty()) {
+            return new ArrayList<>();
+        }
         return baseMapper.getThumbssByVideoIds(videoIds, UserContext.getCurrentUserId());
     }
 }
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 9cc98f7..0679ce2 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
@@ -19,6 +19,8 @@
 import cn.lili.modules.member.entity.dos.Member;
 import cn.lili.modules.member.service.FootprintService;
 import cn.lili.modules.member.service.MemberService;
+import cn.lili.modules.permission.entity.dos.AdminUser;
+import cn.lili.modules.permission.service.AdminUserService;
 import cn.lili.modules.search.entity.dos.EsGoodsIndex;
 import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
 import cn.lili.rocketmq.tags.CommentTagsEnum;
@@ -85,7 +87,7 @@
     private final VideoGoodsService videoGoodsService;
     private final KitchenTypeService kitchenTypeService;
     private final Cache cache;
-
+    private final AdminUserService adminUserService;
     private final RocketmqCustomProperties rocketmqCustomProperties;
     private final RocketMQTemplate rocketMQTemplate;
     private final ThumbsUpRecordService thumbsUpRecordService;
@@ -251,7 +253,9 @@
         String destination = rocketmqCustomProperties.getVideoTopic() + ":" + VideoTagsEnum.ES_DOC_ADD_OR_UPDATE.name();
         rocketMQTemplate.asyncSend(destination, JSON.toJSONString(videoIndex), RocketmqSendCallbackBuilder.commonCallback());
         return Result.ok("鍙戝竷鎴愬姛锛岃棰戝鏍镐腑~");
-    }    @Override
+    }
+
+    @Override
     @Transactional(rollbackFor = Exception.class)
     public Result systemPublish(WxVideoForm form) {
         // 1.淇濆瓨瑙嗛
@@ -426,7 +430,10 @@
             // 3. 鑾峰彇瑙嗛涓存椂璁块棶鍦板潃銆佽缃棰戞爣绛�
             page.getRecords().forEach(v -> {
                 v.setTagList(tagMap.get(v.getId()));
-                v.setCoverUrl(cosUtil.getPreviewUrl(v.getCoverUrl()));
+                String coverUrl = v.getCoverUrl();
+                if (StringUtils.isNotBlank(coverUrl)&&!coverUrl.contains("http")) {
+                    v.setCoverUrl(cosUtil.getPreviewUrl(v.getCoverUrl()));
+                }
                 v.getGoodsList().forEach(goods ->{
                     if (StringUtils.isNotBlank(goods.getThumbnail())&&!goods.getThumbnail().contains("http")) {
                         goods.setThumbnail(cosUtil.getPreviewUrl(goods.getThumbnail()));
@@ -626,7 +633,10 @@
                 v.setCommentNum(this.getCommentNum(v.getId(), v.getCommentNum()));
                 v.setCollectNum(this.getCollectNum(v.getId(), v.getCollectNum()));
                 v.setThumbsUpNum(this.getThumbsUpNum(v.getId(), v.getThumbsUpNum()));
-                v.setAuthorAvatar(cosUtil.getPreviewUrl(v.getAuthorAvatar()));
+                String authorAvatar = v.getAuthorAvatar();
+                if (StringUtils.isNotBlank(authorAvatar)&&!authorAvatar.contains("http")) {
+                    v.setAuthorAvatar(cosUtil.getPreviewUrl(v.getAuthorAvatar()));
+                }
                 if (VideoContentTypeEnum.VIDEO.getValue().equals(v.getVideoContentType())) {
                     v.setVideoUrl(cosUtil.getPreviewUrl(v.getVideoFileKey()));
                     v.setCoverUrl(cosUtil.getPreviewUrl(v.getCoverFileKey()));
@@ -799,7 +809,13 @@
 
     @Override
     public Result getAuthorInfo(String authorId) {
-        VideoAccountVO vo = baseMapper.getAuthorInfo(authorId, UserContext.getCurrentUserId());
+        AdminUser adminUser = adminUserService.getById(authorId);
+        VideoAccountVO vo;
+        if (Objects.isNull(adminUser)) {
+            vo  = baseMapper.getAuthorInfo(authorId, UserContext.getCurrentUserId());
+        }else {
+            vo = baseMapper.getAuthorInfoAdmin(authorId, UserContext.getCurrentUserId());
+        }
         vo.setSelf(authorId.equals(UserContext.getCurrentUserId()));
         // 鏌ヨ鑾疯禐鏁�
         List<String> videoIds = baseMapper.getVideoIdsByAuthor(authorId);
diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoTagRefServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoTagRefServiceImpl.java
index 9ea83e2..7732a88 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoTagRefServiceImpl.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoTagRefServiceImpl.java
@@ -1,5 +1,6 @@
 package cn.lili.modules.lmk.service.impl;
 
+import cn.hutool.core.util.ArrayUtil;
 import cn.lili.modules.lmk.domain.entity.VideoTagRef;
 import cn.lili.modules.lmk.domain.vo.SimpleVideoTagVO;
 import cn.lili.modules.lmk.mapper.VideoTagRefMapper;
@@ -8,6 +9,7 @@
 import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -26,6 +28,9 @@
 
     @Override
     public List<SimpleVideoTagVO> getTagsByVideoIds(List<String> videoIds) {
+        if (videoIds == null || videoIds.isEmpty()) {
+            return new ArrayList<>();
+        }
         return baseMapper.getTagsByVideoIds(videoIds);
     }
 }
diff --git a/framework/src/main/resources/mapper/lmk/VideoMapper.xml b/framework/src/main/resources/mapper/lmk/VideoMapper.xml
index 1da37db..6f83f46 100644
--- a/framework/src/main/resources/mapper/lmk/VideoMapper.xml
+++ b/framework/src/main/resources/mapper/lmk/VideoMapper.xml
@@ -232,7 +232,41 @@
             <if test="query.status != null and query.status != ''">AND LV.status = #{query.status}</if>
     </select>
 
-
+<!-- todo 澶囦唤鍘熸湁鐨勫け鍘讳簡鏂囦欢-->
+<!--    <select id="recommendVideo" 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.create_time,-->
+<!--            LV.video_content_type,-->
+<!--            LV.video_type,-->
+<!--            LV.video_imgs,-->
+<!--            LV.id,-->
+<!--            LM.nick_name as authorName,-->
+<!--            LM.face as authorAvatar-->
+<!--        FROM-->
+<!--            lmk_video LV-->
+<!--            LEFT JOIN li_member LM ON LV.author_id = LM.id-->
+<!--        WHERE-->
+<!--            LV.delete_flag = 0 AND LV.status = '1' AND LV.video_type = #{query.videoType}-->
+<!--        ORDER BY-->
+<!--            LV.create_time DESC-->
+<!--    </select> -->
     <select id="recommendVideo" resultMap="WxResultMap">
         SELECT
             LV.author_id,
@@ -244,7 +278,7 @@
             LV.goods_view_num,
             LV.goods_order_num,
             LV.recommend,
-            LV.status,
+            LV.STATUS,
             LV.play_num,
             LV.comment_num,
             LV.collect_num,
@@ -257,15 +291,52 @@
             LV.video_type,
             LV.video_imgs,
             LV.id,
-            LM.nick_name as authorName,
-            LM.face as authorAvatar
+            LM.nick_name AS authorName,
+            LM.face AS authorAvatar
         FROM
             lmk_video LV
-            LEFT JOIN li_member LM ON LV.author_id = LM.id
+                LEFT JOIN li_member LM ON LV.author_id = LM.id
         WHERE
-            LV.delete_flag = 0 AND LV.status = '1' AND LV.video_type = #{query.videoType}
+            LV.delete_flag = 0
+          AND LV.STATUS = '1'
+          AND LV.video_type = #{query.videoType}
+          AND lm.id IS NOT NULL
+        UNION ALL
+        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.create_time,
+            LV.video_content_type,
+            LV.video_type,
+            LV.video_imgs,
+            LV.id,
+            LM.nick_name AS authorName,
+            LM.avatar AS authorAvatar
+        FROM
+            lmk_video LV
+                LEFT JOIN li_admin_user LM ON LV.author_id = LM.id
+        WHERE
+            LV.delete_flag = 0
+          AND LV.STATUS = '1'
+          AND LV.video_type = #{query.videoType}
+          AND lm.id IS NOT NULL
         ORDER BY
-            LV.create_time DESC
+            create_time DESC
     </select>
     <select id="recommendVideoByVideoId" resultMap="WxResultMap">
         SELECT
@@ -560,6 +631,25 @@
         WHERE
               LM.id = #{authorId} AND LM.delete_flag = 0
     </select>
+    <select id="getAuthorInfoAdmin" resultType="cn.lili.modules.lmk.domain.vo.VideoAccountVO">
+        SELECT
+               LM.id as userId,
+               LM.nick_name as nickName,
+               LM.avatar as avatar,
+               LVA.motto,
+               (SELECT COUNT(*) FROM lmk_my_subscribe WHERE subscribe_user_id = #{authorId} AND delete_flag = 0) as fansNum,
+               (SELECT COUNT(*) FROM lmk_my_subscribe WHERE user_id = #{authorId} AND delete_flag = 0) as subNum,
+               (SELECT CASE
+                           WHEN id IS NOT NULL THEN 1
+                           ELSE 0
+                           END
+               FROM lmk_my_subscribe WHERE user_id = #{currentUserId} AND subscribe_user_id = #{authorId} AND delete_flag = 0) as hasSub
+        FROM
+            li_admin_user LM
+                 LEFT JOIN lmk_video_account LVA ON LM.id = LVA.user_id
+        WHERE
+              LM.id = #{authorId} AND LM.delete_flag = 0
+    </select>
 
     <select id="getVideoIdsByAuthor" parameterType="string" resultType="string">
         SELECT id FROM lmk_video WHERE author_id = #{authorId} AND delete_flag = 0 AND status = '1'

--
Gitblit v1.8.0