package com.muyu.processing.basic;

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

/**
 * 策略发送事件
 * @Author：杨鹏
 * @Package：com.muyu.processing.basic
 * @Project：car-cloud-server
 * @name：EventPublisher
 * @Date：2024/9/29 22:31
 */
@Component
public class EventPublisher implements ApplicationEventPublisherAware {

    private ApplicationEventPublisher publisher;

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

    /**
     * 发送事件
     * @param jsonObject 数据
     */
    public void eventPublish(JSONObject jsonObject){
        EventCustom eventCustom = new EventCustom(this, jsonObject);
        publisher.publishEvent(eventCustom);
    }

}
