WeEventPublisherService.java
1.15 KB
package com.linkwechat.wecom.service.event;
import com.linkwechat.wecom.domain.query.WeCustomerWelcomeQuery;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Service;
/**
* @author danmo
* @description 注册事件发布
* @date 2021/11/13 19:01
**/
@Service
@Slf4j
public class WeEventPublisherService implements ApplicationEventPublisherAware {
private ApplicationEventPublisher applicationEventPublisher;
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.applicationEventPublisher = applicationEventPublisher;
}
/**
* 发布欢迎语事件
*/
public void register(String externalUserId, String userId, String welcomeCode, String state) {
log.info("发布发送欢迎语事件:externalUserId:{},userId:{},welcomeCode:{},state:{}",externalUserId,userId,welcomeCode,state);
applicationEventPublisher.publishEvent(new WeCustomerWelcomeQuery(this, externalUserId,userId,welcomeCode,state));
}
}