package com.usky.issue.service.listener;

import com.usky.issue.service.CloudSyncService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * 组织/用户变更事件监听（应用内事件，可替换为 MQ/CDC）
 *
 * @author fyc
 * @date 2026-05-21
 */
@Slf4j
@Component
public class CloudDataChangeListener {

    @Autowired
    private CloudSyncService cloudSyncService;

    @EventListener
    public void onOrgDataChanged(CloudOrgChangedEvent event) {
        log.info("收到组织变更事件 source={}", event.getSource());
        cloudSyncService.onOrgChanged();
    }

    @EventListener
    public void onUserDataChanged(CloudUserChangedEvent event) {
        log.info("收到用户变更事件 source={}", event.getSource());
        cloudSyncService.onUserChanged();
    }
}
