package cokr.xit.ens.core.eventlistner;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor
public class EnsAMSEventListener implements EnsAMSEventListenerTemplate<EnsAMSEvent> {

    @Override
    @Order(1)
    @EventListener
    public void execute(EnsAMSEvent event) {
        if(event.getAccept()!=null)
            event.getAccept().execute();
        if(event.getMake()!=null)
            event.getMake().execute();
        if(event.getSend()!=null)
            event.getSend().execute();
    }

    @Override
    @Order(2)
    @EventListener
    public void callback(EnsAMSEvent event) {
        if(event.getCallback()!=null)
            event.getCallback().execute();
    }
}
