use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; use time::OffsetDateTime; use uuid::Uuid; #[derive( Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default, EnumIter, DeriveActiveEnum, Serialize, Deserialize, utoipa::ToSchema, )] #[serde(rename_all = "snake_case")] #[sea_orm(rs_type = "i16", db_type = "SmallInteger")] pub enum RoomMemberRole { #[default] #[sea_orm(num_value = 0)] Member, #[sea_orm(num_value = 1)] Moderator, #[sea_orm(num_value = 2)] Admin, #[sea_orm(num_value = 3)] Owner, } #[sea_orm::model] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] #[sea_orm(table_name = "room_members")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub room_id: Uuid, #[sea_orm(primary_key, auto_increment = false)] pub user_id: i64, #[sea_orm(default_value = 0)] pub role: RoomMemberRole, pub nick: Option, pub joined_at: OffsetDateTime, pub left_at: Option, pub created_at: OffsetDateTime, pub updated_at: Option, #[sea_orm(belongs_to, from = "room_id", to = "id")] pub room: BelongsTo, #[sea_orm(belongs_to, from = "user_id", to = "uid")] pub user: BelongsTo, } impl ActiveModelBehavior for ActiveModel {}