package com.fs.app.task;

import com.fs.store.service.IFsUserCourseCountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class UserCourseWatchCountTask {
    @Autowired
    private IFsUserCourseCountService userCourseCountService;


    /**
     * 每15分钟执行一次
     */
    @Scheduled(cron = "0 */10 * * * ?")  // 每10分钟执行一次
    public void userCourseCountTask() {
        try {
            log.info("==============会员看课统计任务执行===============开始");
            long startTime = System.currentTimeMillis();

            userCourseCountService.insertFsUserCourseCountTask();

            log.info("会员看课统计任务执行==============结束");
            long endTime = System.currentTimeMillis();
            log.info("会员看课统计任务执行----------执行时长：{}", (endTime - startTime));
        } catch (Exception e) {
            log.error("会员看课统计任务执行----------定时任务执行失败", e);
        }

    }


}
