package com.seer.teach.teacher.stateMachine.action;

import com.seer.teach.common.enums.teacher.LessonStateEnum;
import com.seer.teach.common.enums.teacher.LessonStateEvent;
import com.seer.teach.teacher.common.utils.CountdownExecutorUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.statemachine.StateContext;
import org.springframework.statemachine.action.Action;
import org.springframework.stereotype.Component;

/**
 * 取消当前倒计时动作
 */
@Slf4j
@Component
public class CancelAudioCountdownAction implements Action<LessonStateEnum, LessonStateEvent> {

    @Override
    public void execute(StateContext<LessonStateEnum, LessonStateEvent> context) {
        Integer userId = Integer.parseInt(context.getStateMachine().getId());
        CountdownExecutorUtil.cancel(userId);
        log.info("用户[{}] 用户回答，倒计时已取消", userId);
    }
}
