From 1cdb060a8aa59b0979f7609db1781805528e76e7 Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期三, 25 六月 2025 18:25:42 +0800 Subject: [PATCH] 视频评论数、收藏数通过mq、redis实现 --- framework/src/main/java/cn/lili/modules/lmk/service/VideoCommentService.java | 4 framework/src/main/resources/mapper/lmk/ThumbsUpRecordMapper.xml | 10 framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoVO.java | 6 consumer/src/main/java/cn/lili/listener/CommentMessageListener.java | 14 - framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoCommentServiceImpl.java | 44 ++-- framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java | 93 ++++++++++ framework/src/main/java/cn/lili/modules/lmk/service/MyCollectService.java | 6 framework/src/main/java/cn/lili/cache/CachePrefix.java | 11 + framework/src/main/java/cn/lili/modules/lmk/constant/RedisKeyExpireConstant.java | 12 + framework/src/main/java/cn/lili/modules/lmk/domain/vo/WxVideoVO.java | 4 framework/src/main/java/cn/lili/modules/lmk/mapper/MyCollectMapper.java | 5 framework/src/main/java/cn/lili/common/properties/RocketmqCustomProperties.java | 7 framework/src/main/java/cn/lili/modules/lmk/domain/entity/Video.java | 14 + framework/src/main/java/cn/lili/modules/lmk/event/eventListener/LmkEventListener.java | 63 +++++++ framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java | 8 framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoCommentVO.java | 2 lmk-job/src/main/java/cn/lili/job/VideoJob.java | 2 framework/src/main/resources/mapper/lmk/VideoCommentMapper.xml | 11 framework/src/main/java/cn/lili/modules/lmk/domain/entity/VideoComment.java | 2 framework/src/main/java/cn/lili/modules/lmk/domain/vo/KitchenVideoVO.java | 4 config/application.yml | 2 framework/src/main/resources/mapper/lmk/MyCollectMapper.xml | 13 consumer/src/main/java/cn/lili/listener/VideoMessageListener.java | 69 +++++++ framework/src/main/java/cn/lili/modules/lmk/service/impl/MyCollectServiceImpl.java | 51 +++- framework/src/main/java/cn/lili/rocketmq/tags/VideoTagsEnum.java | 29 +++ framework/src/main/java/cn/lili/modules/lmk/event/event/VideoCommentNumCacheEvent.java | 43 ++++ 26 files changed, 442 insertions(+), 87 deletions(-) diff --git a/config/application.yml b/config/application.yml index a44c47e..5bc02c2 100644 --- a/config/application.yml +++ b/config/application.yml @@ -284,6 +284,8 @@ promotion-group: shop_lili_promotion_group comment-topic: lmk_comment_topic # 璇勮 comment-group: lmk_comment_group + video-topic: lmk_video_topic # 瑙嗛 + video-group: lmk_video_group msg-ext-topic: shop_lili_msg_topic msg-ext-group: shop_lili_msg_group goods-topic: shop_lili_goods_topic diff --git a/consumer/src/main/java/cn/lili/listener/CommentMessageListener.java b/consumer/src/main/java/cn/lili/listener/CommentMessageListener.java index 5d87495..f5204ac 100644 --- a/consumer/src/main/java/cn/lili/listener/CommentMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/CommentMessageListener.java @@ -1,18 +1,11 @@ package cn.lili.listener; -import cn.lili.base.Result; import cn.lili.cache.Cache; -import cn.lili.cache.CachePrefix; -import cn.lili.common.security.context.UserContext; -import cn.lili.modules.lmk.constant.RedisKeyExpireConstant; import cn.lili.modules.lmk.domain.entity.ThumbsUpRecord; -import cn.lili.modules.lmk.domain.entity.VideoComment; -import cn.lili.modules.lmk.domain.form.ThumbsUpRecordForm; import cn.lili.modules.lmk.service.ThumbsUpRecordService; import cn.lili.modules.lmk.service.VideoCommentService; import cn.lili.rocketmq.tags.CommentTagsEnum; import com.alibaba.fastjson.JSON; -import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.rocketmq.common.message.MessageExt; @@ -20,9 +13,6 @@ import org.apache.rocketmq.spring.core.RocketMQListener; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; - -import java.util.Objects; -import java.util.concurrent.TimeUnit; /** * 璇勮娑堟伅娑堣垂鑰� @@ -87,7 +77,7 @@ * @param msg */ public void cancelThumbsUp(String msg) { - ThumbsUpRecordForm form = JSON.parseObject(msg, ThumbsUpRecordForm.class); - videoCommentService.mqCancelThumbsUp(form); + ThumbsUpRecord record = JSON.parseObject(msg, ThumbsUpRecord.class); + videoCommentService.mqCancelThumbsUp(record); } } diff --git a/consumer/src/main/java/cn/lili/listener/VideoMessageListener.java b/consumer/src/main/java/cn/lili/listener/VideoMessageListener.java new file mode 100644 index 0000000..613f9af --- /dev/null +++ b/consumer/src/main/java/cn/lili/listener/VideoMessageListener.java @@ -0,0 +1,69 @@ +package cn.lili.listener; + +import cn.lili.cache.Cache; +import cn.lili.modules.lmk.domain.entity.MyCollect; +import cn.lili.modules.lmk.domain.entity.ThumbsUpRecord; +import cn.lili.modules.lmk.domain.form.ThumbsUpRecordForm; +import cn.lili.modules.lmk.service.ThumbsUpRecordService; +import cn.lili.modules.lmk.service.VideoCommentService; +import cn.lili.modules.lmk.service.VideoService; +import cn.lili.rocketmq.tags.CommentTagsEnum; +import cn.lili.rocketmq.tags.VideoTagsEnum; +import com.alibaba.fastjson.JSON; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.rocketmq.common.message.MessageExt; +import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; +import org.apache.rocketmq.spring.core.RocketMQListener; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 璇勮娑堟伅娑堣垂鑰� + * + * @author paulG + * @since 2020/12/9 + **/ +@Component +@Slf4j +@RocketMQMessageListener(topic = "${lili.data.rocketmq.video-topic}", consumerGroup = "${lili.data.rocketmq.video-group}") +public class VideoMessageListener implements RocketMQListener<MessageExt> { + + @Autowired + private VideoService videoService; + + @Autowired + private Cache<Object> cache; + + @Override + public void onMessage(MessageExt messageExt) { + try { + String msg = new String(messageExt.getBody()); + if (StringUtils.isBlank(msg)) { + log.error("video msg is null, cant not consumer"); + return; + } + switch (VideoTagsEnum.valueOf(messageExt.getTags())) { + case COLLECT: + this.collect(msg); + break; + default: + log.error("video msg not match correct tag, consumer err"); + break; + } + } catch (Exception e) { + log.error("video msg consumer err", e); + } + } + + /** + * 瑙嗛鏀惰棌/鍙栨秷鏀惰棌 + * + * @param msg + */ + public void collect(String msg) { + MyCollect collect = JSON.parseObject(msg, MyCollect.class); + videoService.mqCollectChange(collect); + } + +} diff --git a/framework/src/main/java/cn/lili/cache/CachePrefix.java b/framework/src/main/java/cn/lili/cache/CachePrefix.java index 63f20dd..e3cb80b 100644 --- a/framework/src/main/java/cn/lili/cache/CachePrefix.java +++ b/framework/src/main/java/cn/lili/cache/CachePrefix.java @@ -519,6 +519,17 @@ VIDEO_COMMENT_LIKE_NUM, /** + * 瑙嗛璇勮鏁伴噺 + */ + VIDEO_COMMENT_NUM, + + /** + * 瑙嗛鏀惰棌鏁伴噺 + */ + VIDEO_COLLECT_NUM, + + + /** * 鎵爜鐧诲綍 * * @param str diff --git a/framework/src/main/java/cn/lili/common/properties/RocketmqCustomProperties.java b/framework/src/main/java/cn/lili/common/properties/RocketmqCustomProperties.java index 2a6e0dc..965c1ce 100644 --- a/framework/src/main/java/cn/lili/common/properties/RocketmqCustomProperties.java +++ b/framework/src/main/java/cn/lili/common/properties/RocketmqCustomProperties.java @@ -26,6 +26,13 @@ private String commentGroup; + /** + * 瑙嗛 + */ + private String videoTopic; + + private String videoGroup; + private String promotionTopic; private String promotionGroup; diff --git a/framework/src/main/java/cn/lili/modules/lmk/constant/RedisKeyExpireConstant.java b/framework/src/main/java/cn/lili/modules/lmk/constant/RedisKeyExpireConstant.java index 73873eb..2c4a4ba 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/constant/RedisKeyExpireConstant.java +++ b/framework/src/main/java/cn/lili/modules/lmk/constant/RedisKeyExpireConstant.java @@ -11,10 +11,20 @@ public class RedisKeyExpireConstant { /** - * 璇勮鏁� + * 璇勮鏁拌繃鏈熸椂闂� */ public static final Long COMMENT_NUM_EXPIRE = 15l; + /** + * 璇勮鐐硅禐鏁拌繃鏈熸椂闂� + */ + public static final Long COMMENT_LIKE_NUM_EXPIRE = 15l; + + /** + * 瑙嗛鏀惰棌鏁拌繃鏈熸椂闂� + */ + public static final Long COLLECT_NUM_EXPIRE = 15l; + /** * 杩囨湡鏃堕棿鍗曚綅 diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/entity/Video.java b/framework/src/main/java/cn/lili/modules/lmk/domain/entity/Video.java index dd5cc3a..35ca6a7 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/domain/entity/Video.java +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/entity/Video.java @@ -75,15 +75,23 @@ @TableField("play_num") /** 鎾斁閲� */ - private Long playNum; + private Integer playNum; @TableField("collect_num") /** 鏀惰棌鏁� */ - private Long collectNum; + private Integer collectNum; @TableField("comment_num") /** 璇勮鏁� */ - private Long commentNum; + private Integer commentNum; + + @TableField("collect_num_job") + /** 鏄惁闇�瑕佸畾鏃朵换鍔$粺璁℃敹钘忔暟 */ + private Boolean collectNumJob; + + @TableField("comment_num_job") + /** 鏄惁闇�瑕佸畾鏃朵换鍔$粺璁¤瘎璁烘暟 */ + private Boolean commentNumJob; @TableField("weight") /** 鏉冮噸 */ diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/entity/VideoComment.java b/framework/src/main/java/cn/lili/modules/lmk/domain/entity/VideoComment.java index 3cb1a3b..5e2bd38 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/domain/entity/VideoComment.java +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/entity/VideoComment.java @@ -52,7 +52,7 @@ @TableField("thumbs_up_num") /** 鐐硅禐鏁伴噺 */ - private Long thumbsUpNum; + private Integer thumbsUpNum; @TableField("thumbs_up_job") /** 鏄惁闇�瑕佸畾鏃朵换鍔℃洿鏂扮偣璧炴暟 */ diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/KitchenVideoVO.java b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/KitchenVideoVO.java index 2c436fc..7511b4d 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/KitchenVideoVO.java +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/KitchenVideoVO.java @@ -91,11 +91,11 @@ /** 鏀惰棌鏁� */ @ApiModelProperty("鏀惰棌鏁�") - private Long collectNum; + private Integer collectNum; /** 璇勮鏁� */ @ApiModelProperty("璇勮鏁�") - private Long commentNum; + private Integer commentNum; /** 鏉冮噸 */ @ApiModelProperty("鏉冮噸") diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoCommentVO.java b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoCommentVO.java index 27f1273..4d436fe 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoCommentVO.java +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoCommentVO.java @@ -56,7 +56,7 @@ private String userAvatar; @ApiModelProperty("璇勮鐐硅禐鏁�") - private Long thumbsUpNum; + private Integer thumbsUpNum; @ApiModelProperty("涓昏瘎璁轰笅闈㈡�诲叡鏈夊灏戞潯鍥炲") private Long replyTotalCount; diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoVO.java b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoVO.java index 0fc6690..6f80172 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoVO.java +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoVO.java @@ -79,15 +79,15 @@ /** 鎾斁閲� */ @ApiModelProperty("鎾斁閲�") - private Long playNum; + private Integer playNum; /** 鏀惰棌鏁� */ @ApiModelProperty("鏀惰棌鏁�") - private Long collectNum; + private Integer collectNum; /** 璇勮鏁� */ @ApiModelProperty("璇勮鏁�") - private Long commentNum; + private Integer commentNum; /** 鏉冮噸 */ @ApiModelProperty("鏉冮噸") diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/WxVideoVO.java b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/WxVideoVO.java index 827efa3..9041166 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/WxVideoVO.java +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/WxVideoVO.java @@ -83,11 +83,11 @@ /** 鏀惰棌鏁� */ @ApiModelProperty("鏀惰棌鏁�") - private Long collectNum; + private Integer collectNum; /** 璇勮鏁� */ @ApiModelProperty("璇勮鏁�") - private Long commentNum; + private Integer commentNum; /** 瑙嗛鎷ユ湁鐨勬搷浣� */ @ApiModelProperty("瑙嗛鏀寔鐨勬搷浣�") diff --git a/framework/src/main/java/cn/lili/modules/lmk/event/event/VideoCommentNumCacheEvent.java b/framework/src/main/java/cn/lili/modules/lmk/event/event/VideoCommentNumCacheEvent.java new file mode 100644 index 0000000..4786997 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/event/event/VideoCommentNumCacheEvent.java @@ -0,0 +1,43 @@ +package cn.lili.modules.lmk.event.event; + +import org.springframework.context.ApplicationEvent; + +import java.time.Clock; + +/** + * 缂撳瓨瑙嗛璇勮鏁伴噺浜嬩欢 + * + * @author锛歺p + * @date锛�2025/6/25 14:52 + */ +public class VideoCommentNumCacheEvent extends ApplicationEvent { + + /** + * 瑙嗛id + */ + private String videoId; + + + + + public VideoCommentNumCacheEvent(Object source) { + super(source); + } + + public VideoCommentNumCacheEvent(Object source, Clock clock) { + super(source, clock); + } + + public String getVideoId() { + return videoId; + } + + public void setVideoId(String videoId) { + this.videoId = videoId; + } + + public VideoCommentNumCacheEvent(Object source, String videoId) { + super(source); + this.videoId = videoId; + } +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/event/eventListener/LmkEventListener.java b/framework/src/main/java/cn/lili/modules/lmk/event/eventListener/LmkEventListener.java new file mode 100644 index 0000000..5da6148 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/event/eventListener/LmkEventListener.java @@ -0,0 +1,63 @@ +package cn.lili.modules.lmk.event.eventListener; + +import cn.lili.cache.Cache; +import cn.lili.cache.CachePrefix; +import cn.lili.modules.lmk.constant.RedisKeyExpireConstant; +import cn.lili.modules.lmk.domain.entity.Video; +import cn.lili.modules.lmk.event.event.VideoCommentNumCacheEvent; +import cn.lili.modules.lmk.service.VideoService; +import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; +import lombok.RequiredArgsConstructor; +import org.springframework.context.event.EventListener; +import org.springframework.stereotype.Component; +import org.springframework.transaction.event.TransactionPhase; +import org.springframework.transaction.event.TransactionalEventListener; + +import java.util.Objects; + +/** + * 浜嬩欢鐩戝惉鍣� + * + * @author锛歺p + * @date锛�2025/6/25 14:54 + */ +@Component +@RequiredArgsConstructor +public class LmkEventListener { + + private final Cache cache; + private final VideoService videoService; + + /** + * 鏂板瑙嗛璇勮鏃讹紝鏇存柊瑙嗛璇勮鏁扮紦瀛� + * + * TransactionalEventListener TransactionPhase.BEFORE_COMMIT 琛ㄧず浜嬩欢鍙戣捣澶勭殑浜嬪姟鎻愪氦涔嬪墠鎵ц璇ヤ簨浠讹紝鑳戒繚璇佷簨鍔� + * + * @param event + */ + @TransactionalEventListener(classes = {VideoCommentNumCacheEvent.class}, phase = TransactionPhase.BEFORE_COMMIT) + public void videoCommentNumCache(VideoCommentNumCacheEvent event) { + // 鍒濆鍖杛edis涓瘎璁虹殑鐐硅禐鏁伴噺 + cache.put(CachePrefix.VIDEO_COMMENT_LIKE_NUM.getPrefixWithId(event.getVideoId()), 0, RedisKeyExpireConstant.COMMENT_NUM_EXPIRE, RedisKeyExpireConstant.EXPIRE_DAY); + // 澶勭悊瑙嗛璇勮鏁� + Video video = videoService.getById(event.getVideoId()); + if (cache.exist(CachePrefix.VIDEO_COMMENT_NUM.getPrefixWithId(event.getVideoId()))) { + cache.incr(CachePrefix.VIDEO_COMMENT_NUM.getPrefixWithId(event.getVideoId())); + } else { + if (Objects.nonNull(video)) { + cache.put(CachePrefix.VIDEO_COMMENT_NUM.getPrefixWithId(event.getVideoId()), + video.getCommentNum() + 1, + RedisKeyExpireConstant.COMMENT_NUM_EXPIRE, + RedisKeyExpireConstant.EXPIRE_DAY); + } + } + // 鏍囪瘑闇�瑕佸畾鏃朵换鍔$粺璁¤瘎璁烘暟閲� + if (Objects.nonNull(video) && ! video.getCommentNumJob()) { + new LambdaUpdateChainWrapper<>(videoService.getBaseMapper()) + .eq(Video::getId, event.getVideoId()) + .set(Video::getCommentNumJob, Boolean.TRUE) + .update(); + } + } + +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/mapper/MyCollectMapper.java b/framework/src/main/java/cn/lili/modules/lmk/mapper/MyCollectMapper.java index 4583073..acfe0a0 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/mapper/MyCollectMapper.java +++ b/framework/src/main/java/cn/lili/modules/lmk/mapper/MyCollectMapper.java @@ -40,12 +40,11 @@ List<SimpleMyCollectVO> getCollectsByVideoIds(@Param("videoIds") List<String> videoIds, @Param("userId") String currentUserId); /** - * 鏍规嵁鏌愭敹钘忕被鍨媔d鍒嗙粍缁熻鏁伴噺锛屾瘮濡傦細缁熻姣忎釜瑙嗛鐨勬敹钘忔暟 + * 鏍规嵁瑙嗛钘忕被鍨媔d鍒嗙粍缁熻鏁伴噺锛屾瘮濡傦細缁熻姣忎釜瑙嗛鐨勬敹钘忔暟 * - * @param type * @return */ - List<CollectTypeNumVO> countNumGroupByType(@Param("type") String type); + List<CollectTypeNumVO> countNumGroupByVideo(); /** diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/MyCollectService.java b/framework/src/main/java/cn/lili/modules/lmk/service/MyCollectService.java index 29010ac..8563b83 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/service/MyCollectService.java +++ b/framework/src/main/java/cn/lili/modules/lmk/service/MyCollectService.java @@ -75,11 +75,11 @@ List<SimpleMyCollectVO> getCollectsByVideoIds(List<String> videoIds); /** - * 鏍规嵁鏌愭敹钘忕被鍨媔d鍒嗙粍缁熻鏁伴噺锛屾瘮濡傦細缁熻姣忎釜瑙嗛鐨勬敹钘忔暟 - * @param type + * 鏍规嵁瑙嗛钘忕被鍨媔d鍒嗙粍缁熻鏁伴噺锛屾瘮濡傦細缁熻姣忎釜瑙嗛鐨勬敹钘忔暟 + * * @return */ - List<CollectTypeNumVO> countNumGroupByType(String type); + List<CollectTypeNumVO> countNumGroupByVideo(); Result getMyCollectList(MyCollectQuery query); } diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/VideoCommentService.java b/framework/src/main/java/cn/lili/modules/lmk/service/VideoCommentService.java index 0825f82..b6bc798 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/service/VideoCommentService.java +++ b/framework/src/main/java/cn/lili/modules/lmk/service/VideoCommentService.java @@ -100,9 +100,9 @@ /** * mq鐨勫彇娑堢偣璧為�昏緫 * - * @param form + * @param record */ - void mqCancelThumbsUp(ThumbsUpRecordForm form); + void mqCancelThumbsUp(ThumbsUpRecord record); /** * 鎵归噺鏇存柊璇勮鐐硅禐鏁� 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 f81ad39..0671480 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 @@ -1,6 +1,7 @@ package cn.lili.modules.lmk.service; import cn.lili.group.Add; +import cn.lili.modules.lmk.domain.entity.MyCollect; import cn.lili.modules.lmk.domain.entity.Video; import cn.lili.modules.lmk.domain.form.*; import cn.lili.modules.lmk.domain.query.*; @@ -257,4 +258,11 @@ * @return */ Result updatePublish(WxVideoForm form); + + /** + * mq鎵ц瑙嗛鏀惰棌/鍙栨秷鏀惰棌 + * + * @param collect + */ + void mqCollectChange(MyCollect collect); } 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 28eb4e8..f4b64ea 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 @@ -1,9 +1,14 @@ package cn.lili.modules.lmk.service.impl; import cn.lili.common.enums.CollectTypeEnum; +import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.common.security.context.UserContext; import cn.lili.modules.goods.entity.vos.GoodsVO; import cn.lili.modules.lmk.domain.vo.*; +import cn.lili.rocketmq.RocketmqSendCallbackBuilder; +import cn.lili.rocketmq.tags.CommentTagsEnum; +import cn.lili.rocketmq.tags.VideoTagsEnum; +import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.metadata.IPage; import cn.lili.modules.lmk.domain.entity.MyCollect; import cn.lili.modules.lmk.mapper.MyCollectMapper; @@ -13,6 +18,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import cn.lili.modules.lmk.domain.form.MyCollectForm; import cn.lili.modules.lmk.domain.query.MyCollectQuery; +import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.stereotype.Service; import lombok.RequiredArgsConstructor; import cn.lili.utils.PageUtil; @@ -34,28 +40,41 @@ public class MyCollectServiceImpl extends ServiceImpl<MyCollectMapper, MyCollect> implements MyCollectService { private final MyCollectMapper myCollectMapper; - + private final RocketmqCustomProperties rocketmqCustomProperties; private final LmkFileServiceImpl fileService; + private final RocketMQTemplate rocketMQTemplate; + + /** - * 娣诲姞 + * 鏀惰棌/鍙栨秷鏀惰棌 * @param form * @return */ @Override public Result change(MyCollectForm form) { - MyCollect myCollect = new LambdaQueryChainWrapper<>(baseMapper) - .eq(MyCollect::getCollectType, form.getCollectType()) - .eq(MyCollect::getRefId, form.getRefId()) - .eq(MyCollect::getUserId, UserContext.getCurrentUserId()) - .one(); - if (Objects.nonNull(myCollect)) { - baseMapper.deleteById(myCollect.getId()); + // 瑙嗛鏀惰棌璧癿q + if (CollectTypeEnum.video.getType().equals(form.getCollectType())) { + MyCollect collect = new MyCollect(); + collect.setRefId(form.getRefId()); + collect.setCollectType(form.getCollectType()); + collect.setUserId(UserContext.getCurrentUserId()); + String destination = rocketmqCustomProperties.getVideoTopic() + ":" + VideoTagsEnum.COLLECT.name(); + rocketMQTemplate.asyncSend(destination, JSON.toJSONString(collect), RocketmqSendCallbackBuilder.commonCallback()); } else { - myCollect = new MyCollect(); - myCollect.setRefId(form.getRefId()); - myCollect.setCollectType(form.getCollectType()); - myCollect.setUserId(UserContext.getCurrentUserId()); - baseMapper.insert(myCollect); + MyCollect myCollect = new LambdaQueryChainWrapper<>(baseMapper) + .eq(MyCollect::getCollectType, form.getCollectType()) + .eq(MyCollect::getRefId, form.getRefId()) + .eq(MyCollect::getUserId, UserContext.getCurrentUserId()) + .one(); + if (Objects.nonNull(myCollect)) { + baseMapper.deleteById(myCollect.getId()); + } else { + myCollect = new MyCollect(); + myCollect.setRefId(form.getRefId()); + myCollect.setCollectType(form.getCollectType()); + myCollect.setUserId(UserContext.getCurrentUserId()); + baseMapper.insert(myCollect); + } } return Result.ok("鎿嶄綔鎴愬姛"); } @@ -141,8 +160,8 @@ } @Override - public List<CollectTypeNumVO> countNumGroupByType(String type) { - return baseMapper.countNumGroupByType(type); + public List<CollectTypeNumVO> countNumGroupByVideo() { + return baseMapper.countNumGroupByVideo(); } diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoCommentServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoCommentServiceImpl.java index 6d4047b..ca4e7af 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoCommentServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoCommentServiceImpl.java @@ -11,6 +11,7 @@ import cn.lili.modules.lmk.domain.form.ThumbsUpRecordForm; import cn.lili.modules.lmk.domain.vo.CollectTypeNumVO; import cn.lili.modules.lmk.enums.general.VideoCommentStatusEnum; +import cn.lili.modules.lmk.event.event.VideoCommentNumCacheEvent; import cn.lili.modules.lmk.service.ThumbsUpRecordService; import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.tags.CommentTagsEnum; @@ -32,6 +33,7 @@ import org.apache.rocketmq.client.producer.DefaultMQProducer; import org.apache.rocketmq.common.MixAll; import org.apache.rocketmq.spring.core.RocketMQTemplate; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Service; import lombok.RequiredArgsConstructor; import cn.lili.utils.PageUtil; @@ -59,11 +61,7 @@ private final ThumbsUpRecordService thumbsUpRecordService; private final RocketMQTemplate rocketMQTemplate; private final RocketmqCustomProperties rocketmqCustomProperties; - - /** - * 璇勮鐐硅禐鏁扮殑杩囨湡鏃堕棿 - */ - public final static long EXPIRE_TIME = 15l; + private final ApplicationEventPublisher eventPublisher; /** * 娣诲姞 @@ -92,7 +90,9 @@ entity.setUserAvatar(currentUser.getFace()); baseMapper.insert(entity); // 鍒濆鍖杛edis涓瘎璁虹殑鐐硅禐鏁伴噺 - cache.put(CachePrefix.VIDEO_COMMENT_LIKE_NUM.getPrefixWithId(entity.getId()), 0, EXPIRE_TIME, TimeUnit.DAYS); + cache.put(CachePrefix.VIDEO_COMMENT_LIKE_NUM.getPrefixWithId(entity.getId()), 0, RedisKeyExpireConstant.COMMENT_LIKE_NUM_EXPIRE, RedisKeyExpireConstant.EXPIRE_DAY); + // 澶勭悊瑙嗛璇勮鏁� + eventPublisher.publishEvent(new VideoCommentNumCacheEvent(this, entity.getVideoId())); return Result.ok("娣诲姞鎴愬姛").data(this.detail(entity.getId()).get("data")); } @@ -198,7 +198,7 @@ public void mqThumbsUp(ThumbsUpRecord record) { boolean exists = new LambdaQueryChainWrapper<>(thumbsUpRecordService.getBaseMapper()) .eq(ThumbsUpRecord::getRefId, record.getRefId()) - .eq(ThumbsUpRecord::getUserId, UserContext.getCurrentUserId()) + .eq(ThumbsUpRecord::getUserId, record.getUserId()) .exists(); if (exists) { return; @@ -209,7 +209,7 @@ cache.incr(CachePrefix.VIDEO_COMMENT_LIKE_NUM.getPrefixWithId(record.getRefId())); } else { if (Objects.nonNull(comment)) { - cache.put(CachePrefix.VIDEO_COMMENT_LIKE_NUM.getPrefixWithId(comment.getId()), comment.getThumbsUpNum() + 1, RedisKeyExpireConstant.COMMENT_NUM_EXPIRE, RedisKeyExpireConstant.EXPIRE_DAY); + cache.put(CachePrefix.VIDEO_COMMENT_LIKE_NUM.getPrefixWithId(comment.getId()), comment.getThumbsUpNum() + 1, RedisKeyExpireConstant.COMMENT_LIKE_NUM_EXPIRE, RedisKeyExpireConstant.EXPIRE_DAY); } } // 鏍囪瘑璇ヨ瘎璁洪渶瑕侀�氳繃瀹氭椂浠诲姟缁熻鐐硅禐鏁� @@ -223,27 +223,29 @@ @Override public Result cancelThumbsUp(ThumbsUpRecordForm form) { + ThumbsUpRecord record = ThumbsUpRecordForm.getEntityByForm(form, null); + record.setUserId(UserContext.getCurrentUserId()); // 璧癿q寮傛澶勭悊 String destination = rocketmqCustomProperties.getCommentTopic() + ":" + CommentTagsEnum.CANCEL_THUMBS_UP.name(); - rocketMQTemplate.asyncSend(destination, JSON.toJSONString(form), RocketmqSendCallbackBuilder.commonCallback()); + rocketMQTemplate.asyncSend(destination, JSON.toJSONString(record), RocketmqSendCallbackBuilder.commonCallback()); return Result.ok(); } @Override @Transactional(rollbackFor = Exception.class) - public void mqCancelThumbsUp(ThumbsUpRecordForm form) { + public void mqCancelThumbsUp(ThumbsUpRecord record) { new LambdaUpdateChainWrapper<>(thumbsUpRecordService.getBaseMapper()) - .eq(ThumbsUpRecord::getRefId, form.getRefId()) - .eq(ThumbsUpRecord::getThumbsUpType, form.getThumbsUpType()) - .eq(ThumbsUpRecord::getUserId, UserContext.getCurrentUserId()) + .eq(ThumbsUpRecord::getRefId, record.getRefId()) + .eq(ThumbsUpRecord::getThumbsUpType, record.getThumbsUpType()) + .eq(ThumbsUpRecord::getUserId, record.getUserId()) .remove(); // redis鏁伴噺鍑忎竴 - VideoComment comment = this.getById(form.getRefId()); - if (cache.exist(CachePrefix.VIDEO_COMMENT_LIKE_NUM.getPrefixWithId(form.getRefId()))) { - cache.decr(CachePrefix.VIDEO_COMMENT_LIKE_NUM.getPrefixWithId(form.getRefId())); + VideoComment comment = this.getById(record.getRefId()); + if (cache.exist(CachePrefix.VIDEO_COMMENT_LIKE_NUM.getPrefixWithId(record.getRefId()))) { + cache.decr(CachePrefix.VIDEO_COMMENT_LIKE_NUM.getPrefixWithId(record.getRefId())); } else { if (Objects.nonNull(comment)) { - cache.put(CachePrefix.VIDEO_COMMENT_LIKE_NUM.getPrefixWithId(comment.getId()), comment.getThumbsUpNum() - 1, RedisKeyExpireConstant.COMMENT_NUM_EXPIRE, RedisKeyExpireConstant.EXPIRE_DAY); + cache.put(CachePrefix.VIDEO_COMMENT_LIKE_NUM.getPrefixWithId(comment.getId()), comment.getThumbsUpNum() - 1, RedisKeyExpireConstant.COMMENT_LIKE_NUM_EXPIRE, RedisKeyExpireConstant.EXPIRE_DAY); } } // 鏍囪瘑璇ヨ瘎璁洪渶瑕侀�氳繃瀹氭椂浠诲姟缁熻鐐硅禐鏁� @@ -256,20 +258,20 @@ } /** - * 浠巖edis涓幏鍙栬瘎璁烘暟閲忥紝濡傛灉redis涓病鏈夊垯灏唌ysql涓殑鏁伴噺鍐欏叆鍒皉edis + * 浠巖edis涓幏鍙栬瘎璁虹偣璧炴暟閲忥紝濡傛灉redis涓病鏈夊垯灏唌ysql涓殑鏁伴噺鍐欏叆鍒皉edis * * @param commentId * @param mysqlNum * @return */ - private long getCommentThumbsUpNum(String commentId, long mysqlNum) { + private Integer getCommentThumbsUpNum(String commentId, Integer mysqlNum) { Object redisNum = cache.get(CachePrefix.VIDEO_COMMENT_LIKE_NUM.getPrefixWithId(commentId)); if (Objects.isNull(redisNum)) { // redis涓病鏈夊氨鎶婃暟鎹簱鐨勫啓鍒皉edis涓� - cache.put(CachePrefix.VIDEO_COMMENT_LIKE_NUM.getPrefixWithId(commentId), mysqlNum, EXPIRE_TIME, TimeUnit.DAYS); + cache.put(CachePrefix.VIDEO_COMMENT_LIKE_NUM.getPrefixWithId(commentId), mysqlNum, RedisKeyExpireConstant.COMMENT_LIKE_NUM_EXPIRE, RedisKeyExpireConstant.EXPIRE_DAY); return mysqlNum; } - return Long.valueOf((Integer) redisNum); + return (Integer) redisNum; } @Override 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 ca75179..57909e0 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 @@ -1,6 +1,9 @@ package cn.lili.modules.lmk.service.impl; +import cn.lili.cache.Cache; +import cn.lili.cache.CachePrefix; import cn.lili.common.security.context.UserContext; +import cn.lili.modules.lmk.constant.RedisKeyExpireConstant; import cn.lili.modules.lmk.domain.entity.*; import cn.lili.modules.lmk.domain.form.*; import cn.lili.modules.lmk.domain.query.*; @@ -57,6 +60,7 @@ private final KitchenVideoTypeRefService kitchenVideoTypeRefService; private final VideoGoodsService videoGoodsService; private final KitchenTypeService kitchenTypeService; + private final Cache cache; /** * 娣诲姞 @@ -389,6 +393,8 @@ page.getRecords().forEach(v -> { v.setTagList(tagMap.get(v.getId())); v.setCollected(CollectionUtils.isNotEmpty(collectMap.get(v.getId()))); + v.setCommentNum(this.getCommentNum(v.getId(), v.getCommentNum())); + v.setCollectNum(this.getCollectNum(v.getId(), v.getCollectNum())); if (VideoContentTypeEnum.VIDEO.getValue().equals(v.getVideoContentType())) { v.setVideoUrl(cosUtil.getPreviewUrl(v.getVideoFileKey())); v.setCoverUrl(cosUtil.getPreviewUrl(v.getCoverFileKey())); @@ -400,6 +406,40 @@ }); } return Result.ok().data(page.getRecords()); + } + + /** + * 浠巖edis涓幏鍙栬瘎璁烘暟閲忥紝濡傛灉redis涓病鏈夊垯灏唌ysql涓殑鏁伴噺鍐欏叆鍒皉edis + * + * @param videoId + * @param mysqlNum + * @return + */ + private Integer getCommentNum(String videoId, Integer mysqlNum) { + Object redisNum = cache.get(CachePrefix.VIDEO_COMMENT_NUM.getPrefixWithId(videoId)); + if (Objects.isNull(redisNum)) { + // redis涓病鏈夊氨鎶婃暟鎹簱鐨勫啓鍒皉edis涓� + cache.put(CachePrefix.VIDEO_COMMENT_NUM.getPrefixWithId(videoId), mysqlNum, RedisKeyExpireConstant.COMMENT_NUM_EXPIRE, RedisKeyExpireConstant.EXPIRE_DAY); + return mysqlNum; + } + return (Integer) redisNum; + } + + /** + * 浠巖edis涓幏鍙栨敹钘忔暟閲忥紝濡傛灉redis涓病鏈夊垯灏唌ysql涓殑鏁伴噺鍐欏叆鍒皉edis + * + * @param videoId + * @param mysqlNum + * @return + */ + private Integer getCollectNum(String videoId, Integer mysqlNum) { + Object redisNum = cache.get(CachePrefix.VIDEO_COLLECT_NUM.getPrefixWithId(videoId)); + if (Objects.isNull(redisNum)) { + // redis涓病鏈夊氨鎶婃暟鎹簱鐨勫啓鍒皉edis涓� + cache.put(CachePrefix.VIDEO_COLLECT_NUM.getPrefixWithId(videoId), mysqlNum, RedisKeyExpireConstant.COLLECT_NUM_EXPIRE, RedisKeyExpireConstant.EXPIRE_DAY); + return mysqlNum; + } + return (Integer) redisNum; } @Override @@ -446,6 +486,10 @@ List<List<CollectTypeNumVO>> chunks = ListUtils.partition(numList, 500); for (List<CollectTypeNumVO> chunk : chunks) { baseMapper.updateCollectNumBatch(chunk); + new LambdaUpdateChainWrapper<>(baseMapper) + .in(Video::getId, chunk.stream().map(CollectTypeNumVO::getId).collect(Collectors.toList())) + .set(Video::getCollectNumJob, Boolean.FALSE) + .update(); } } @@ -456,6 +500,10 @@ List<List<CollectTypeNumVO>> chunks = ListUtils.partition(numList, 500); for (List<CollectTypeNumVO> chunk : chunks) { baseMapper.updateCommentNumBatch(chunk); + new LambdaUpdateChainWrapper<>(baseMapper) + .in(Video::getId, chunk.stream().map(CollectTypeNumVO::getId).collect(Collectors.toList())) + .set(Video::getCommentNumJob, Boolean.FALSE) + .update(); } } @@ -709,4 +757,49 @@ .eq(KitchenVideoTypeRef::getVideoId, id)); return Result.ok("鍒犻櫎鎴愬姛"); } + + /** + * mq鎵ц瑙嗛鐨勬敹钘�/鍙栨秷鏀惰棌 + * + * @param collect + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void mqCollectChange(MyCollect collect) { + MyCollect myCollect = new LambdaQueryChainWrapper<>(myCollectService.getBaseMapper()) + .eq(MyCollect::getCollectType, collect.getCollectType()) + .eq(MyCollect::getRefId, collect.getRefId()) + .eq(MyCollect::getUserId, collect.getUserId()) + .one(); + boolean add = false; + if (Objects.nonNull(myCollect)) { + myCollectService.removeById(myCollect.getId()); + } else { + myCollectService.save(collect); + add = true; + } + // 澶勭悊缂撳瓨 + Video video = baseMapper.selectById(collect.getRefId()); + if (cache.exist(CachePrefix.VIDEO_COLLECT_NUM.getPrefixWithId(collect.getRefId()))) { + if (add) { + cache.incr(CachePrefix.VIDEO_COLLECT_NUM.getPrefixWithId(collect.getRefId())); + } else { + cache.decr(CachePrefix.VIDEO_COLLECT_NUM.getPrefixWithId(collect.getRefId())); + } + } else { + if (Objects.nonNull(video)) { + cache.put(CachePrefix.VIDEO_COLLECT_NUM.getPrefixWithId(video.getId()), + video.getCollectNum() + (add ? 1 : -1), + RedisKeyExpireConstant.COLLECT_NUM_EXPIRE, + RedisKeyExpireConstant.EXPIRE_DAY); + } + } + // 鏍囪瘑璇ヨ棰戦渶瑕侀�氳繃瀹氭椂浠诲姟缁熻鏀惰棌鏁� + if (Objects.nonNull(video) && ! video.getCollectNumJob()) { + new LambdaUpdateChainWrapper<>(baseMapper) + .eq(Video::getId, video.getId()) + .set(Video::getCollectNumJob, Boolean.TRUE) + .update(); + } + } } diff --git a/framework/src/main/java/cn/lili/rocketmq/tags/VideoTagsEnum.java b/framework/src/main/java/cn/lili/rocketmq/tags/VideoTagsEnum.java new file mode 100644 index 0000000..03b5ea1 --- /dev/null +++ b/framework/src/main/java/cn/lili/rocketmq/tags/VideoTagsEnum.java @@ -0,0 +1,29 @@ +package cn.lili.rocketmq.tags; + +/** + * mq瑙嗛tag + * + * @author paulG + * @since 2020/12/9 + **/ +public enum VideoTagsEnum { + + /** + * 鏀惰棌 + */ + COLLECT("鏀惰棌"), + ; + + + private final String description; + + VideoTagsEnum(String description) { + this.description = description; + } + + public String description() { + return description; + } + + +} diff --git a/framework/src/main/resources/mapper/lmk/MyCollectMapper.xml b/framework/src/main/resources/mapper/lmk/MyCollectMapper.xml index 573467c..f1ff446 100644 --- a/framework/src/main/resources/mapper/lmk/MyCollectMapper.xml +++ b/framework/src/main/resources/mapper/lmk/MyCollectMapper.xml @@ -54,16 +54,17 @@ AND ref_id IN <foreach collection="videoIds" open="(" item="videoId" close=")" separator=",">#{videoId}</foreach> </select> - <select id="countNumGroupByType" parameterType="string" resultType="cn.lili.modules.lmk.domain.vo.CollectTypeNumVO"> + <select id="countNumGroupByVideo" parameterType="string" resultType="cn.lili.modules.lmk.domain.vo.CollectTypeNumVO"> SELECT - ref_id as id, - count(id) as countNum + LV.id as id, + count(LMC.ref_id) as countNum FROM - lmk_my_collect + lmk_video LV + LEFT JOIN lmk_my_collect LMC ON LV.id = LMC.ref_id AND LMC.collect_type = 'video' AND LMC.delete_flag = 0 WHERE - collect_type = #{type} AND delete_flag = 0 + LV.collect_num_job = 1 AND LV.delete_flag = 0 AND LV.status = '1' GROUP BY - ref_id + LMC.ref_id </select> diff --git a/framework/src/main/resources/mapper/lmk/ThumbsUpRecordMapper.xml b/framework/src/main/resources/mapper/lmk/ThumbsUpRecordMapper.xml index 1e1c362..a0a28e7 100644 --- a/framework/src/main/resources/mapper/lmk/ThumbsUpRecordMapper.xml +++ b/framework/src/main/resources/mapper/lmk/ThumbsUpRecordMapper.xml @@ -44,14 +44,14 @@ <select id="countNumGroupByComment" resultType="cn.lili.modules.lmk.domain.vo.CollectTypeNumVO"> SELECT - LTUR.ref_id as id, + LVC.id as id, count(LTUR.ref_id) as countNum FROM - lmk_thumbs_up_record LTUR - INNER JOIN lmk_video_comment LVC ON LTUR.ref_id = LVC.id AND LVC.thumbs_up_job = 1 AND LVC.delete_flag = 0 + lmk_video_comment LVC + LEFT JOIN lmk_thumbs_up_record LTUR ON LTUR.ref_id = LVC.id AND LTUR.thumbs_up_type = 'video_comment' AND LTUR.delete_flag = 0 WHERE - LTUR.thumbs_up_type = 'video_comment' - AND LTUR.delete_flag = 0 + LVC.thumbs_up_job = 1 + AND LVC.delete_flag = 0 GROUP BY LTUR.ref_id </select> diff --git a/framework/src/main/resources/mapper/lmk/VideoCommentMapper.xml b/framework/src/main/resources/mapper/lmk/VideoCommentMapper.xml index 2c1c43a..59e68f2 100644 --- a/framework/src/main/resources/mapper/lmk/VideoCommentMapper.xml +++ b/framework/src/main/resources/mapper/lmk/VideoCommentMapper.xml @@ -145,14 +145,15 @@ <select id="countNumGroupByVideo" resultType="cn.lili.modules.lmk.domain.vo.CollectTypeNumVO"> SELECT - video_id as id, - COUNT(*) as countNum + LV.id as id, + COUNT(LVC.video_id) as countNum FROM - lmk_video_comment + lmk_video LV + LEFT JOIN lmk_video_comment LVC ON LVC.video_id = LV.id AND LVC.delete_flag = 0 AND LVC.status = 'normal' WHERE - delete_flag = 0 AND status = 'normal' + LV.comment_num_job = 1 AND LV.delete_flag = 0 AND LV.status = '1' GROUP BY - video_id + LVC.video_id </select> diff --git a/lmk-job/src/main/java/cn/lili/job/VideoJob.java b/lmk-job/src/main/java/cn/lili/job/VideoJob.java index 9ff9d00..15035f1 100644 --- a/lmk-job/src/main/java/cn/lili/job/VideoJob.java +++ b/lmk-job/src/main/java/cn/lili/job/VideoJob.java @@ -37,7 +37,7 @@ @XxlJob("videoCollectNumJob") public void videoCollectNumJob() throws Exception { XxlJobHelper.log("寮�濮嬫墽琛岋細瑙嗛鏀惰棌鏁扮粺璁�"); - List<CollectTypeNumVO> numList = myCollectService.countNumGroupByType(CollectTypeEnum.VIDEO.getValue()); + List<CollectTypeNumVO> numList = myCollectService.countNumGroupByVideo(); if (CollectionUtils.isNotEmpty(numList)) { videoService.updateCollectNumBatch(numList); } -- Gitblit v1.8.0