namespace LingAdmin.Shared.Events;
///
/// Dapr 事件主题常量
///
public static class EventTopics
{
public const string PubSubName = "pubsub";
// 用户相关事件
public const string UserCreated = "user-created";
public const string UserUpdated = "user-updated";
public const string UserDeleted = "user-deleted";
public const string UserLoggedIn = "user-logged-in";
public const string UserLoggedOut = "user-logged-out";
public const string UserPasswordChanged = "user-password-changed";
// 角色相关事件
public const string RoleCreated = "role-created";
public const string RoleUpdated = "role-updated";
public const string RoleDeleted = "role-deleted";
public const string UserRoleAssigned = "user-role-assigned";
public const string UserRoleRevoked = "user-role-revoked";
// 权限相关事件
public const string PermissionCreated = "permission-created";
public const string PermissionUpdated = "permission-updated";
public const string RolePermissionChanged = "role-permission-changed";
}
///
/// 用户创建事件
///
public class UserCreatedEvent
{
public int UserId { get; set; }
public required string Email { get; set; }
public required string Name { get; set; }
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
public string? Source { get; set; }
}
///
/// 用户更新事件
///
public class UserUpdatedEvent
{
public int UserId { get; set; }
public Dictionary ChangedFields { get; set; } = new();
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
public int? UpdatedBy { get; set; }
}
///
/// 用户登录事件
///
public class UserLoggedInEvent
{
public int UserId { get; set; }
public required string Email { get; set; }
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
public string? IpAddress { get; set; }
public string? UserAgent { get; set; }
}
///
/// 用户登出事件
///
public class UserLoggedOutEvent
{
public int UserId { get; set; }
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
}
///
/// 用户角色分配事件
///
public class UserRoleAssignedEvent
{
public int UserId { get; set; }
public List RoleIds { get; set; } = new();
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
public int? AssignedBy { get; set; }
}
///
/// 角色权限变更事件
///
public class RolePermissionChangedEvent
{
public int RoleId { get; set; }
public List AddedPermissions { get; set; } = new();
public List RemovedPermissions { get; set; } = new();
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
public int? ChangedBy { get; set; }
}