Skip to content
Clone
b4afb4b
53 lines 1.5 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,
)]
#[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<String>,
pub decided_by: Option<i64>,
pub decided_at: Option<OffsetDateTime>,
pub created_at: OffsetDateTime,
pub updated_at: OffsetDateTime,
#[sea_orm(belongs_to, relation_enum = "Applicant", from = "user_id", to = "uid")]
pub applicant: BelongsTo<super::super::users::user::Entity>,
#[sea_orm(belongs_to, relation_enum = "Decider", from = "decided_by", to = "uid")]
pub decider: BelongsTo<Option<super::super::users::user::Entity>>,
}
impl ActiveModelBehavior for ActiveModel {}