Skip to content
Clone
main
49 lines 1.3 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,
utoipa::ToSchema,
)]
#[sea_orm(rs_type = "i16", db_type = "SmallInteger")]
pub enum ThreadNotifyLevel {
#[sea_orm(num_value = 0)]
None,
#[default]
#[sea_orm(num_value = 1)]
All,
}
#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "chat_thread_member")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub thread_id: Uuid,
#[sea_orm(primary_key, auto_increment = false)]
pub user_id: i64,
#[sea_orm(default_value = 1)]
pub notify_level: ThreadNotifyLevel,
pub last_read_message_id: Option<Uuid>,
#[sea_orm(default_value = 0)]
pub last_read_seq: i64,
pub created_at: OffsetDateTime,
pub updated_at: OffsetDateTime,
#[sea_orm(belongs_to, from = "thread_id", to = "id")]
pub thread: BelongsTo<super::threads::Entity>,
#[sea_orm(belongs_to, from = "user_id", to = "uid")]
pub user: BelongsTo<super::super::users::user::Entity>,
}
impl ActiveModelBehavior for ActiveModel {}