package com.usky.issue.service.listener;

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

/**
 * 用户变更时写入云端下发队列
 *
 * @author fyc
 * @date 2026-06-29
 */
@Slf4j
@Component
public class CloudUserSyncPublishListener {

    @Autowired
    private CloudSyncPublishService cloudSyncPublishService;

    @EventListener
    public void onUserChanged(CloudUserChangedEvent event) {
        log.info("收到用户变更事件 userId={}, operation={}",
                event.getUser().getUserId(), event.getOperation());
        cloudSyncPublishService.enqueueUser(event.getUser(), event.getOperation());
    }
}
