role.rs 33 lignes · 1038 octets
use chrono::{DateTime, Utc};
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
use uuid::Uuid;

/// Role entity model
///
/// Represents a role in the RBAC system.
/// Roles can be assigned to multiple users through the many-to-many relationship.
#[derive(Clone, Debug, Serialize, Deserialize, DeriveEntityModel)]
#[sea_orm(table_name = "roles")]
pub struct Model {
    /// Unique identifier for the role
    #[sea_orm(primary_key)]
    pub id: Uuid,
    /// Role name (unique, max 64 characters)
    /// Predefined values: "admin", "user"
    #[sea_orm(unique)]
    pub name: String,
    /// Optional description of the role (max 255 characters)
    #[sea_orm(nullable)]
    pub description: Option<String>,
    /// Creation timestamp
    pub created_at: DateTime<Utc>,
    /// Last update timestamp
    pub updated_at: DateTime<Utc>,
}

/// SeaORM relations for the Role entity (none defined).
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}

impl ActiveModelBehavior for ActiveModel {}