mirror of https://github.com/veypi/OneAuth.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
1.9 KiB
Rust
79 lines
1.9 KiB
Rust
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.3
|
|
|
|
use sea_orm::entity::prelude::*;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(
|
|
Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize, Default, sqlx :: FromRow,
|
|
)]
|
|
#[sea_orm(table_name = "access")]
|
|
pub struct Model {
|
|
#[sea_orm(primary_key)]
|
|
pub id: i32,
|
|
pub created: DateTime,
|
|
pub updated: DateTime,
|
|
pub app_id: String,
|
|
pub name: String,
|
|
pub role_id: Option<String>,
|
|
pub user_id: Option<String>,
|
|
pub rid: Option<String>,
|
|
pub level: i32,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {
|
|
#[sea_orm(
|
|
belongs_to = "super::resource::Entity",
|
|
from = "(Column::AppId, Column::Name)",
|
|
to = "(super::resource::Column::AppId, super::resource::Column::Name)",
|
|
on_update = "NoAction",
|
|
on_delete = "NoAction"
|
|
)]
|
|
Resource,
|
|
#[sea_orm(
|
|
belongs_to = "super::role::Entity",
|
|
from = "Column::RoleId",
|
|
to = "super::role::Column::Id",
|
|
on_update = "NoAction",
|
|
on_delete = "NoAction"
|
|
)]
|
|
Role,
|
|
#[sea_orm(
|
|
belongs_to = "super::user::Entity",
|
|
from = "Column::UserId",
|
|
to = "super::user::Column::Id",
|
|
on_update = "NoAction",
|
|
on_delete = "NoAction"
|
|
)]
|
|
User,
|
|
}
|
|
|
|
impl Related<super::resource::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::Resource.def()
|
|
}
|
|
}
|
|
|
|
impl Related<super::role::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::Role.def()
|
|
}
|
|
}
|
|
|
|
impl Related<super::user::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::User.def()
|
|
}
|
|
}
|
|
|
|
impl Related<super::app::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
super::resource::Relation::App.def()
|
|
}
|
|
fn via() -> Option<RelationDef> {
|
|
Some(super::resource::Relation::Access.def().rev())
|
|
}
|
|
}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|