xiangpei
2025-05-29 817c7de04cb6b74164a42ed0e6050ae5b91b0ef1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package cn.lili.job;
 
import cn.lili.modules.lmk.domain.vo.CollectTypeNumVO;
import cn.lili.modules.lmk.enums.general.CollectTypeEnum;
import cn.lili.modules.lmk.service.MyCollectService;
import cn.lili.modules.lmk.service.VideoCommentService;
import cn.lili.modules.lmk.service.VideoService;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Component;
 
import java.util.List;
 
/**
 * 视频相关的定时任务
 *
 * @author:xp
 * @date:2025/5/23 9:13
 */
@Component
@RequiredArgsConstructor
public class VideoJob {
 
    private final VideoService videoService;
    private final MyCollectService myCollectService;
    private final VideoCommentService videoCommentService;
 
    /**
     * 视频收藏数统计
     *
     * @throws Exception
     */
    @XxlJob("videoCollectNumJob")
    public void videoCollectNumJob() throws Exception {
        XxlJobHelper.log("开始执行:视频收藏数统计");
        List<CollectTypeNumVO> numList = myCollectService.countNumGroupByType(CollectTypeEnum.VIDEO.getValue());
        if (CollectionUtils.isNotEmpty(numList)) {
            videoService.updateCollectNumBatch(numList);
        }
    }
 
    /**
     * 视频评论数统计
     *
     * @throws Exception
     */
    @XxlJob("videoCommentNumJob")
    public void videoCommentNumJob() throws Exception {
        XxlJobHelper.log("开始执行:视频评论数统计");
        List<CollectTypeNumVO> numList = videoCommentService.countNumGroupByVideo();
        if (CollectionUtils.isNotEmpty(numList)) {
            videoService.updateCommentNumBatch(numList);
        }
    }
 
}