package com.sonic.frog.event.outer.handler;

import com.sonic.frog.event.outer.EventType;
import com.sonic.frog.event.outer.payload.UserCratedPayload;
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 UserCreatedThenHandler implements EventHandler, InitializingBean {

    @Autowired
    private EventConsumer eventConsumer;

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

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