Skip to content
Clone
a06673b
36 lines 1.1 KB Rust
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<Uuid>,
pub role_id: Option<Uuid>,
pub channel_id: Option<Uuid>,
pub is_everyone: bool,
pub is_here: bool,
pub created_at: OffsetDateTime,
#[sea_orm(belongs_to, from = "user_id", to = "uid")]
pub user: BelongsTo<Option<super::super::user::users::Entity>>,
#[sea_orm(belongs_to, from = "channel_id", to = "id")]
pub channel: BelongsTo<Option<super::super::channel::channels::Entity>>,
}
impl ActiveModelBehavior for ActiveModel {}