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, )] #[serde(rename_all = "snake_case")] #[sea_orm(rs_type = "String", db_type = "String(StringLen::N(16))")] pub enum SpaceJoinRequestStatus { #[default] #[sea_orm(string_value = "pending")] Pending, #[sea_orm(string_value = "approved")] Approved, #[sea_orm(string_value = "rejected")] Rejected, #[sea_orm(string_value = "withdrawn")] Withdrawn, } #[sea_orm::model] #[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[sea_orm(table_name = "space_join_request")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: Uuid, pub space_id: Uuid, pub user_id: i64, pub status: SpaceJoinRequestStatus, pub note: Option, pub decided_by: Option, pub decided_at: Option, pub created_at: OffsetDateTime, pub updated_at: OffsetDateTime, #[sea_orm(belongs_to, from = "space_id", to = "id")] pub space: BelongsTo, #[sea_orm(belongs_to, relation_enum = "Applicant", from = "user_id", to = "uid")] pub applicant: BelongsTo, #[sea_orm(belongs_to, relation_enum = "Decider", from = "decided_by", to = "uid")] pub decider: BelongsTo>, } impl ActiveModelBehavior for ActiveModel {}