use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; use time::OffsetDateTime; use uuid::Uuid; #[derive( Debug, Clone, Copy, PartialEq, Eq, Default, EnumIter, DeriveActiveEnum, Serialize, Deserialize, )] #[sea_orm(rs_type = "i32", db_type = "SmallInteger")] pub enum MentionTarget { #[default] Post = 0, Reply = 1, } #[sea_orm::model] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] #[sea_orm(table_name = "post_mention")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: Uuid, pub target_id: Uuid, pub target: MentionTarget, pub user_id: Option, pub role_id: Option, pub channel_id: Option, pub is_everyone: bool, pub is_here: bool, pub created_at: OffsetDateTime, #[sea_orm(belongs_to, from = "user_id", to = "uid")] pub user: BelongsTo>, #[sea_orm(belongs_to, from = "channel_id", to = "id")] pub channel: BelongsTo>, } impl ActiveModelBehavior for ActiveModel {}