package com.muyu.carData.event;

import com.alibaba.fastjson.JSONObject;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Component;

/** 策略发送事件
 * @Author：张腾
 * @Package：com.muyu.carData.event
 * @Project：cloud-server-8
 * @name：EventPublisher
 * @Date：2024/10/4 10:40
 */
@Component
public class EventPublisher implements ApplicationEventPublisherAware {

    private ApplicationEventPublisher publisher;
    @Override
    public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
        this.publisher = applicationEventPublisher;
    }

    public void publishEvent(JSONObject message){
        EsSaveEvent esSaveEvent = new EsSaveEvent(this, message);
        publisher.publishEvent(esSaveEvent);
    }
}
