package com.sonic.shark.event.inner.handler;

import com.sonic.shark.event.inner.EventType;
import com.sonic.shark.event.inner.payload.DemoCreatedPayload;
import com.sonic.common.event.Event;
import com.sonic.common.event.EventConsumer;
import com.sonic.common.event.EventHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author code
 */
@Slf4j
@Component
public class DemoCreatedThenHandler implements EventHandler, InitializingBean {

    @Autowired
    private EventConsumer eventConsumer;

    @Override
    public void onEvent(Event event) {
        DemoCreatedPayload payload = event.normalizedData(DemoCreatedPayload.class);
        // TODO:
    }

    @Override
    public void afterPropertiesSet() {
        eventConsumer.registerHandler(EventType.DEMO_CREATED.getEventCode(), this);
    }
}
