44 lines
1.1 KiB
Rust
44 lines
1.1 KiB
Rust
use sea_orm::entity::prelude::*;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(
|
|
Clone, Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum, DeriveDisplay, Serialize, Deserialize,
|
|
)]
|
|
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "auth_type")]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum AuthType {
|
|
#[sea_orm(string_value = "basic")]
|
|
Basic,
|
|
#[sea_orm(string_value = "oidc")]
|
|
Oidc,
|
|
}
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, DeriveEntityModel)]
|
|
#[sea_orm(table_name = "auth")]
|
|
pub struct Model {
|
|
pub created_at: DateTime,
|
|
pub updated_at: DateTime,
|
|
#[sea_orm(primary_key)]
|
|
pub id: i32,
|
|
pub pid: String,
|
|
pub subscriber_id: i32,
|
|
pub auth_type: AuthType,
|
|
pub avatar_url: Option<String>,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {
|
|
#[sea_orm(
|
|
belongs_to = "super::subscribers::Entity",
|
|
from = "Column::SubscriberId",
|
|
to = "super::subscribers::Column::Id"
|
|
)]
|
|
SubscriberId,
|
|
}
|
|
|
|
impl Related<super::subscribers::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::SubscriberId.def()
|
|
}
|
|
}
|