package com.muyu.event;

import com.muyu.event.common.VehicleEvent;
import com.muyu.event.service.EventService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

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

/**
 * 事件启动 EventRunner
 *
 * @author Yangle
 * Date 2024/6/20 16:47
 */

@Component
public class EventRunner implements Runnable {
        @Autowired
        private EventService eventService;
    @PostConstruct
    public void run() {
        List<VehicleEvent> vehicleEvents = eventService.selectVehicleEvent();
        vehicleEvents.forEach(
                vehicleEvent -> {
                    eventService.selectEvent(vehicleEvent);
                }
        );
    }
}
