package com.qqchen.deploy.backend.system.event;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.event.TransactionPhase;
import org.springframework.transaction.event.TransactionalEventListener;

@Slf4j
@Component
public class UserEventListener {

    @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
    public void handleUserRoleChanged(UserRoleChangedEvent event) {
        log.info("User role changed - userId: {}, roleId: {}, action: {}", 
            event.getUserId(), 
            event.getRoleId(), 
            event.getAction());

        // 这里可以添加后续处理逻辑
        // 例如：发送通知、更新缓存等
    }
} 