From 6fb006c40ff90a615fa3c3a55a65c99b55acc03d Mon Sep 17 00:00:00 2001 From: zxl <763096477@qq.com> Date: 星期二, 29 七月 2025 14:43:35 +0800 Subject: [PATCH] 提取videoServiceImpl方法 --- framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java | 26 +++++++++++++++++++++++--- 1 files changed, 23 insertions(+), 3 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 da35abc..9cc98f7 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 @@ -4,6 +4,7 @@ import cn.lili.cache.CachePrefix; import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.common.security.context.UserContext; +import cn.lili.common.utils.CommonUtil; import cn.lili.elasticsearch.EsSuffix; import cn.lili.modules.lmk.constant.RedisKeyExpireConstant; import cn.lili.modules.lmk.domain.dto.VideoEsUpdateDTO; @@ -46,6 +47,7 @@ import org.springframework.data.elasticsearch.core.SearchHits; import org.springframework.data.elasticsearch.core.query.NativeSearchQuery; import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import lombok.RequiredArgsConstructor; import cn.lili.utils.PageUtil; @@ -54,6 +56,8 @@ import org.springframework.util.Assert; import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -423,6 +427,12 @@ page.getRecords().forEach(v -> { v.setTagList(tagMap.get(v.getId())); 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())); + } + + }); }); } return Result.ok().data(page.getRecords()).total(page.getTotal()); @@ -547,6 +557,16 @@ switch (query.getVideoFrom()) { case "recommend":// 鍔犺浇鎺ㄨ崘瑙嗛 baseMapper.recommendVideo(page, query); + //鎺ㄨ崘瑙嗛閲嶆柊鎺掑簭 + WxVideoVO wxVideoVO = null; + if (StringUtils.isNotBlank(query.getVideoId())) { + wxVideoVO = baseMapper.recommendVideoByVideoId(query); + } + List<WxVideoVO> records = page.getRecords(); + Collections.shuffle(records); + if (wxVideoVO!=null) { + records.set(0, wxVideoVO); + } break; case "author": // 鍔犺浇瑙嗛涓婚〉鎴戝彂甯冪殑瑙嗛 AuthorVideoQuery query1 = new AuthorVideoQuery(); @@ -631,7 +651,7 @@ * @param mysqlNum * @return */ - private Integer getCommentNum(String videoId, Integer mysqlNum) { + public Integer getCommentNum(String videoId, Integer mysqlNum) { Object redisNum = cache.get(CachePrefix.VIDEO_COMMENT_NUM.getPrefixWithId(videoId)); if (Objects.isNull(redisNum)) { // redis涓病鏈夊氨鎶婃暟鎹簱鐨勫啓鍒皉edis涓� @@ -648,7 +668,7 @@ * @param mysqlNum * @return */ - private Integer getCollectNum(String videoId, Integer mysqlNum) { + public Integer getCollectNum(String videoId, Integer mysqlNum) { Object redisNum = cache.get(CachePrefix.VIDEO_COLLECT_NUM.getPrefixWithId(videoId)); if (Objects.isNull(redisNum)) { // redis涓病鏈夊氨鎶婃暟鎹簱鐨勫啓鍒皉edis涓� @@ -665,7 +685,7 @@ * @param mysqlNum * @return */ - private Integer getThumbsUpNum(String videoId, Integer mysqlNum) { + public Integer getThumbsUpNum(String videoId, Integer mysqlNum) { Object redisNum = cache.get(CachePrefix.VIDEO_THUMBS_UP_NUM.getPrefixWithId(videoId)); if (Objects.isNull(redisNum)) { // redis涓病鏈夊氨鎶婃暟鎹簱鐨勫啓鍒皉edis涓� -- Gitblit v1.8.0