package com.xhkjedu.sexam.task;

import com.xhkjedu.sexam.mapper.exam.ESubjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author ywx
 * @classname PaperTask
 * @description 试卷状态定时任务
 * @date 2022/9/13 11:28
 **/
@Slf4j
@Component
public class PaperTask {

    @Autowired
    private ESubjectMapper eSubjectMapper;

    /**
     * 试卷开始考试
     * @Param []
     * @Author ywx
     * @Date 2022/9/13 11:29
     * @return void
     **/
    @Async("threadPoolTaskScheduler")
    @Scheduled(cron = "${cron.updatePaperState}")
    public void startPaper() {
        eSubjectMapper.startPaper();
    }

    /**
     * 试卷结束考试
     * @Param []
     * @Author ywx
     * @Date 2022/9/13 11:30
     * @return void
     **/
    @Async("threadPoolTaskScheduler")
    @Scheduled(cron = "${cron.updatePaperState}")
    public void endPaper() {
        eSubjectMapper.endPaper();
    }

}
