package com.bcxin.tenant.domain.events.handlers;

import com.bcxin.Infrastructures.components.JsonProvider;
import com.bcxin.Infrastructures.events.handlers.DomainEventHandlerAbstract;
import com.bcxin.tenant.domain.enums.EventAction;
import com.bcxin.tenant.domain.events.OrganizationUpdatedEvent;
import com.bcxin.tenant.domain.services.TenantEventService;
import com.bcxin.tenant.domain.services.commands.CreateTenantEventCommand;
import org.springframework.stereotype.Component;

@Component
public class OrganizationUpdatedEvent_Handler extends DomainEventHandlerAbstract<OrganizationUpdatedEvent> {
    private final TenantEventService eventService;
    private final JsonProvider jsonProvider;

    public OrganizationUpdatedEvent_Handler(TenantEventService eventService, JsonProvider jsonProvider) {
        this.eventService = eventService;
        this.jsonProvider = jsonProvider;
    }

    @Override
    protected void execute(OrganizationUpdatedEvent event) {
        this.eventService.create(CreateTenantEventCommand.create(EventAction.OrganizationEdited, event.getData().getId(), event.getData().getName()));
    }
}
