package com.usky.issue.service.support;

import com.usky.issue.domain.SysUser;
import com.usky.issue.service.listener.CloudUserChangedEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

/**
 * 云平台同步事件发布（供用户/组织模块在数据变更后调用）
 *
 * @author fyc
 * @date 2026-06-29
 */
@Component
public class CloudSyncEventPublisher {

    @Autowired
    private ApplicationEventPublisher eventPublisher;

    public void notifyUserCreated(SysUser user) {
        eventPublisher.publishEvent(new CloudUserChangedEvent(user, "INSERT"));
    }

    public void notifyUserUpdated(SysUser user) {
        eventPublisher.publishEvent(new CloudUserChangedEvent(user, "UPDATE"));
    }

    public void notifyUserDeleted(SysUser user) {
        eventPublisher.publishEvent(new CloudUserChangedEvent(user, "DELETE"));
    }
}
