Skip to content
Clone
eeff292
81 lines 2.0 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 RoomKind {
#[default]
#[sea_orm(num_value = 0)]
GuildRoom,
#[sea_orm(num_value = 1)]
GroupDm,
#[sea_orm(num_value = 2)]
Dm,
#[sea_orm(num_value = 3)]
Category,
#[sea_orm(num_value = 10)]
Text,
#[sea_orm(num_value = 11)]
Voice,
#[sea_orm(num_value = 12)]
Stage,
#[sea_orm(num_value = 13)]
News,
#[sea_orm(num_value = 14)]
Thread,
#[sea_orm(num_value = 15)]
DirectMessage,
}
#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "rooms")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
#[sea_orm(unique_key = "space_lower_name")]
pub space_id: Option<Uuid>,
#[sea_orm(default_value = 0)]
pub kind: RoomKind,
#[sea_orm(unique_key = "space_lower_name")]
pub lower_name: String,
pub name: String,
pub topic: Option<String>,
pub icon: Option<String>,
pub color: Option<String>,
#[sea_orm(default_value = 0)]
pub position: i64,
pub owner_id: i64,
#[sea_orm(default_value = "false")]
pub is_private: bool,
#[sea_orm(default_value = "false")]
pub nsfw: bool,
pub user_limit: Option<i32>,
pub rate_limit_per_user: Option<i32>,
pub bitrate: Option<i32>,
pub last_message_id: Option<Uuid>,
#[sea_orm(default_value = "true")]
pub is_active: bool,
pub created_at: OffsetDateTime,
pub updated_at: OffsetDateTime,
#[sea_orm(belongs_to, from = "owner_id", to = "uid")]
pub owner: BelongsTo<super::super::users::user::Entity>,
#[sea_orm(has_many)]
pub members: HasMany<super::room_members::Entity>,
}
impl ActiveModelBehavior for ActiveModel {}