package com.xhkjedu.slive.task;

import com.xhkjedu.slive.service.agora.AgoralicenseService;
import com.xhkjedu.slive.service.liveplay.CourseSectionService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author ywx
 * @classname LivePlayTask
 * @description
 * @date 2021/1/16 13:30
 **/
@Component
public class LivePlayTask {

    @Resource
    private CourseSectionService courseSectionService;
    @Resource
    private AgoralicenseService agoralicenseService;

    /**
     * 定时任务修改课节状态
     * @Param []
     * @Author ywx
     * @Date 2021/1/16 13:34
     * @return void
     **/
    @Scheduled(cron = "${cron.updateSectionState}")
    public void updateSectionState(){
        try {
            courseSectionService.updateSectionState2();
        } catch (Exception e) {
            System.out.println("定时任务修改课节状态异常："+e.getCause().getMessage());
        }
    }

    /**
     * 定时任务修改license状态
     * @Param []
     * @Author ywx
     * @Date 2021/4/7 10:10
     * @return void
     **/
    @Scheduled(cron = "${cron.updateLicenseState}")
    public void updateLicenseState() {
        agoralicenseService.updateLicenseState();
    }

    //处理未释放的授权
    @Scheduled(cron = "${cron.updateLicense}")
    public void updateLicense() {
        agoralicenseService.updateLicense();
    }
}
