package cn.newfeifan.mall.module.system.mq.producer.login;

import cn.newfeifan.mall.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO;
import cn.newfeifan.mall.module.system.mq.message.login.LoginSendMessage;
import cn.newfeifan.mall.module.system.mq.message.mail.MailSendMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Slf4j
@Component
public class LoginProducer {
    @Resource
    private ApplicationContext applicationContext;

    /**
     * 发送 {@link MailSendMessage} 消息
     *
     * @param oAuth2AccessTokenDO 当前登录信息
     */
    public void sendLoginMessage(OAuth2AccessTokenDO oAuth2AccessTokenDO) {
        LoginSendMessage message = new LoginSendMessage()
                .setOAuth2AccessTokenDO(oAuth2AccessTokenDO);
        applicationContext.publishEvent(message);
    }
}
