package com.ym.mec.biz.event.source;

import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
import com.ym.mec.biz.dal.enums.StudentMusicGroupStatusEnum;
import com.ym.mec.biz.event.MusicGroupStatusChangeEvent;
import com.ym.mec.biz.event.MusicGroupStudentChangeEvent;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author Joburgess
 * @Date 2021/2/24 0024
 */
@Service
public class GroupEventSource {

    @Resource
    private ApplicationContext applicationContext;

    public void musicGroupStatusChange(String musicGroupId, MusicGroupStatusEnum oldStatus, MusicGroupStatusEnum currentStatus) {
        applicationContext.publishEvent(new MusicGroupStatusChangeEvent(this, musicGroupId, oldStatus, currentStatus));
    }

    public void musicGroupStudentChangeEvent(String musicGroupId, StudentMusicGroupStatusEnum studentMusicGroupStatus, List<Integer> studentIds) {
        applicationContext.publishEvent(new MusicGroupStudentChangeEvent(this, musicGroupId, studentMusicGroupStatus, studentIds));
    }
}
