49 lines
1.1 KiB
Rust
49 lines
1.1 KiB
Rust
use sea_orm::entity::prelude::*;
|
|
use serde::{Deserialize, Serialize};
|
|
use utoipa::ToSchema;
|
|
|
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize, ToSchema)]
|
|
#[sea_orm(table_name = "invite_link")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key)]
|
|
pub id: i32,
|
|
pub family_id: i32,
|
|
#[sea_orm(unique)]
|
|
pub token: String,
|
|
pub created_at: DateTime,
|
|
pub expires_at: Option<DateTime>,
|
|
pub max_uses: Option<i32>,
|
|
pub uses_count: i32,
|
|
pub created_by: i32,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {
|
|
#[sea_orm(
|
|
belongs_to = "super::family::Entity",
|
|
from = "Column::FamilyId",
|
|
to = "super::family::Column::Id"
|
|
)]
|
|
Family,
|
|
#[sea_orm(
|
|
belongs_to = "super::user::Entity",
|
|
from = "Column::CreatedBy",
|
|
to = "super::user::Column::Id"
|
|
)]
|
|
User,
|
|
}
|
|
|
|
impl Related<super::family::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::Family.def()
|
|
}
|
|
}
|
|
|
|
impl Related<super::user::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::User.def()
|
|
}
|
|
}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|