main
use sea_orm::entity::prelude::*;
use time::OffsetDateTime;
use uuid::Uuid;
#[derive(
Debug,
Clone,
Copy,
PartialEq,
Eq,
EnumIter,
DeriveActiveEnum,
serde::Serialize,
serde::Deserialize,
utoipa::ToSchema,
)]
#[serde(rename_all = "snake_case")]
#[sea_orm(rs_type = "String", db_type = "String(StringLen::N(16))")]
pub enum SuspensionType {
#[sea_orm(string_value = "temporary")]
Temporary,
#[sea_orm(string_value = "permanent")]
Permanent,
}
#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "user_suspensions")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub user_id: i64,
#[sea_orm(
belongs_to,
from = "user_id",
to = "uid",
relation_enum = "SuspendedUser"
)]
pub user: BelongsTo<super::user::Entity>,
pub suspension_type: SuspensionType,
pub reason: Option<String>,
pub suspended_by: Option<i64>,
#[sea_orm(
belongs_to,
from = "suspended_by",
to = "uid",
relation_enum = "SuspendedBy"
)]
pub suspender: BelongsTo<Option<super::user::Entity>>,
pub starts_at: OffsetDateTime,
pub ends_at: Option<OffsetDateTime>,
pub revoked_at: Option<OffsetDateTime>,
pub revoked_by: Option<i64>,
#[sea_orm(
belongs_to,
from = "revoked_by",
to = "uid",
relation_enum = "RevokedBy"
)]
pub revoker: BelongsTo<Option<super::user::Entity>>,
pub created_at: OffsetDateTime,
pub updated_at: OffsetDateTime,
}
impl ActiveModelBehavior for ActiveModel {}