From e0beab0edb7049fdf46aca17f32f9dc5f4a8a755 Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期四, 29 五月 2025 17:33:15 +0800 Subject: [PATCH] 视频评论数定时任务、视频评论查询 --- framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java | 36 +++++++++++++++++++++++++++++++----- 1 files changed, 31 insertions(+), 5 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 053fbfc..bf978a9 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 @@ -5,14 +5,15 @@ import cn.lili.modules.lmk.domain.entity.VideoAuditRecord; import cn.lili.modules.lmk.domain.entity.VideoTag; import cn.lili.modules.lmk.domain.entity.VideoTagRef; -import cn.lili.modules.lmk.domain.form.VideoAuditingForm; -import cn.lili.modules.lmk.domain.form.VideoDownForm; -import cn.lili.modules.lmk.domain.form.VideoRecommendForm; +import cn.lili.modules.lmk.domain.form.*; import cn.lili.modules.lmk.domain.query.ManagerVideoQuery; import cn.lili.modules.lmk.domain.vo.*; import cn.lili.modules.lmk.enums.general.TagCreateTypeEnum; import cn.lili.modules.lmk.enums.general.VideoStatusEnum; +import cn.lili.modules.lmk.enums.general.ViewTypeEnum; import cn.lili.modules.lmk.service.*; +import cn.lili.modules.member.entity.dos.FootPrint; +import cn.lili.modules.member.service.FootprintService; import cn.lili.utils.COSUtil; import com.baomidou.mybatisplus.core.metadata.IPage; import cn.lili.modules.lmk.domain.entity.Video; @@ -21,7 +22,6 @@ import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import cn.lili.modules.lmk.domain.form.VideoForm; import cn.lili.modules.lmk.domain.query.VideoQuery; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.ListUtils; @@ -53,6 +53,8 @@ private final VideoAuditRecordService videoAuditRecordService; private final MyCollectService myCollectService; private final COSUtil cosUtil; + private final FootprintService footprintService; + private final MySubscribeService mySubscribeService; /** * 娣诲姞 @@ -269,12 +271,14 @@ Map<String, List<SimpleMyCollectVO>> collectMap =myCollectService.getCollectsByVideoIds(videoIds) .stream() .collect(Collectors.groupingBy(SimpleMyCollectVO::getRefId)); - // 3. 鑾峰彇瑙嗛涓存椂璁块棶鍦板潃銆佽缃棰戞爣绛俱�佹垜鏄惁鏀惰棌 + List<String> subscribes = mySubscribeService.getSubscribesByUserId(UserContext.getCurrentUserId()); + // 3. 鑾峰彇瑙嗛涓存椂璁块棶鍦板潃銆佽缃棰戞爣绛俱�佹垜鏄惁鏀惰棌銆佷綔鑰呮槸鍚﹀叧娉� page.getRecords().forEach(v -> { v.setGoods(new VideoGoodsVO()); v.setTagList(tagMap.get(v.getId())); v.setCollected(CollectionUtils.isNotEmpty(collectMap.get(v.getId()))); v.setVideoUrl(cosUtil.getPreviewUrl(v.getVideoFileKey())); + v.setSubscribeThisAuthor(subscribes.contains(v.getAuthorId())); }); } return Result.ok().data(page.getRecords()); @@ -289,4 +293,26 @@ baseMapper.updateCollectNumBatch(chunk); } } + + @Override + @Transactional(rollbackFor = Exception.class) + public void updateCommentNumBatch(List<CollectTypeNumVO> numList) { + // 鎸�500鏉℃暟鎹繘琛屾媶鍒� + List<List<CollectTypeNumVO>> chunks = ListUtils.partition(numList, 500); + for (List<CollectTypeNumVO> chunk : chunks) { + baseMapper.updateCommentNumBatch(chunk); + } + } + + @Override + public Result saveViewRecord(VideoFootPrintForm form) { + FootPrint footPrint = new FootPrint(); + footPrint.setViewType(ViewTypeEnum.VIDEO.getValue()); + footPrint.setRefId(form.getVideoId()); + footPrint.setMemberId(UserContext.getCurrentUserId()); + footPrint.setViewDuration(form.getViewDuration()); + footPrint.setPlayAt(form.getPlayAt()); + footprintService.saveFootprint(footPrint); + return Result.ok(); + } } -- Gitblit v1.8.0