mirror of https://github.com/veypi/OneAuth.git
add seaorm in oab
parent
5d71525ce7
commit
bd03910ab8
File diff suppressed because it is too large
Load Diff
@ -1,89 +0,0 @@
|
|||||||
//
|
|
||||||
// app.rs
|
|
||||||
// Copyright (C) 2022 veypi <i@veypi.com>
|
|
||||||
// 2022-07-09 00:18
|
|
||||||
// Distributed under terms of the Apache license.
|
|
||||||
//
|
|
||||||
|
|
||||||
use chrono::NaiveDateTime;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use serde_repr::*;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize_repr, Deserialize_repr, Clone, sqlx::Type)]
|
|
||||||
#[repr(i64)]
|
|
||||||
pub enum AppJoin {
|
|
||||||
Auto = 0,
|
|
||||||
Disabled = 1,
|
|
||||||
Applying = 2,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, sqlx::FromRow)]
|
|
||||||
pub struct App {
|
|
||||||
pub id: String,
|
|
||||||
pub created: Option<NaiveDateTime>,
|
|
||||||
pub updated: Option<NaiveDateTime>,
|
|
||||||
pub delete_flag: bool,
|
|
||||||
|
|
||||||
pub name: Option<String>,
|
|
||||||
pub des: Option<String>,
|
|
||||||
pub icon: Option<String>,
|
|
||||||
pub user_count: i64,
|
|
||||||
|
|
||||||
pub hide: bool,
|
|
||||||
pub join_method: AppJoin,
|
|
||||||
pub role_id: Option<String>,
|
|
||||||
pub redirect: Option<String>,
|
|
||||||
|
|
||||||
pub status: i64,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl App {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
Self {
|
|
||||||
id: "".to_string(),
|
|
||||||
created: None,
|
|
||||||
updated: None,
|
|
||||||
delete_flag: false,
|
|
||||||
|
|
||||||
name: None,
|
|
||||||
des: None,
|
|
||||||
icon: None,
|
|
||||||
user_count: 0,
|
|
||||||
hide: false,
|
|
||||||
join_method: AppJoin::Auto,
|
|
||||||
role_id: None,
|
|
||||||
redirect: None,
|
|
||||||
status: 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize_repr, Serialize_repr, Clone, sqlx::Type)]
|
|
||||||
#[repr(i64)]
|
|
||||||
pub enum AUStatus {
|
|
||||||
OK = 0,
|
|
||||||
Disabled = 1,
|
|
||||||
Applying = 2,
|
|
||||||
Deny = 3,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, sqlx::FromRow)]
|
|
||||||
pub struct AppUser {
|
|
||||||
pub created: Option<NaiveDateTime>,
|
|
||||||
pub updated: Option<NaiveDateTime>,
|
|
||||||
pub app_id: String,
|
|
||||||
pub user_id: String,
|
|
||||||
pub status: AUStatus,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AppUser {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
Self {
|
|
||||||
created: None,
|
|
||||||
updated: None,
|
|
||||||
app_id: "".to_string(),
|
|
||||||
user_id: "".to_string(),
|
|
||||||
status: AUStatus::OK,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,47 @@
|
|||||||
|
//
|
||||||
|
// app.rs
|
||||||
|
// Copyright (C) 2022 veypi <i@veypi.com>
|
||||||
|
// 2022-07-09 00:18
|
||||||
|
// Distributed under terms of the Apache license.
|
||||||
|
//
|
||||||
|
|
||||||
|
use serde_repr::*;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize_repr, Deserialize_repr, Clone, sqlx::Type)]
|
||||||
|
#[repr(i32)]
|
||||||
|
pub enum AppJoin {
|
||||||
|
Auto = 0,
|
||||||
|
Disabled = 1,
|
||||||
|
Applying = 2,
|
||||||
|
}
|
||||||
|
impl From<i32> for AppJoin {
|
||||||
|
fn from(v: i32) -> Self {
|
||||||
|
match v {
|
||||||
|
x if x == AppJoin::Auto as i32 => AppJoin::Auto,
|
||||||
|
x if x == AppJoin::Disabled as i32 => AppJoin::Disabled,
|
||||||
|
x if x == AppJoin::Applying as i32 => AppJoin::Applying,
|
||||||
|
_ => AppJoin::Auto,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize_repr, Serialize_repr, Clone, sqlx::Type)]
|
||||||
|
#[repr(i32)]
|
||||||
|
pub enum AUStatus {
|
||||||
|
OK = 0,
|
||||||
|
Disabled = 1,
|
||||||
|
Applying = 2,
|
||||||
|
Deny = 3,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<i32> for AUStatus {
|
||||||
|
fn from(v: i32) -> Self {
|
||||||
|
match v {
|
||||||
|
x if x == AUStatus::OK as i32 => AUStatus::OK,
|
||||||
|
x if x == AUStatus::Disabled as i32 => AUStatus::Disabled,
|
||||||
|
x if x == AUStatus::Applying as i32 => AUStatus::Applying,
|
||||||
|
x if x == AUStatus::Deny as i32 => AUStatus::Deny,
|
||||||
|
_ => AUStatus::OK,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
//! `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: Option<DateTime>,
|
||||||
|
pub updated: Option<DateTime>,
|
||||||
|
pub delete_flag: i8,
|
||||||
|
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 {}
|
@ -0,0 +1,80 @@
|
|||||||
|
//! `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 = "app")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key, auto_increment = false)]
|
||||||
|
pub id: String,
|
||||||
|
pub created: Option<DateTime>,
|
||||||
|
pub updated: Option<DateTime>,
|
||||||
|
pub delete_flag: i8,
|
||||||
|
pub key: String,
|
||||||
|
pub name: String,
|
||||||
|
pub icon: Option<String>,
|
||||||
|
pub des: Option<String>,
|
||||||
|
pub user_count: i32,
|
||||||
|
pub hide: i8,
|
||||||
|
pub join_method: i32,
|
||||||
|
pub role_id: Option<String>,
|
||||||
|
pub redirect: Option<String>,
|
||||||
|
pub status: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
|
pub enum Relation {
|
||||||
|
#[sea_orm(has_many = "super::app_user::Entity")]
|
||||||
|
AppUser,
|
||||||
|
#[sea_orm(has_many = "super::resource::Entity")]
|
||||||
|
Resource,
|
||||||
|
#[sea_orm(
|
||||||
|
belongs_to = "super::role::Entity",
|
||||||
|
from = "Column::RoleId",
|
||||||
|
to = "super::role::Column::Id",
|
||||||
|
on_update = "NoAction",
|
||||||
|
on_delete = "NoAction"
|
||||||
|
)]
|
||||||
|
Role,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::app_user::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::AppUser.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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::access::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
super::resource::Relation::Access.def()
|
||||||
|
}
|
||||||
|
fn via() -> Option<RelationDef> {
|
||||||
|
Some(super::resource::Relation::App.def().rev())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::user::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
super::app_user::Relation::User.def()
|
||||||
|
}
|
||||||
|
fn via() -> Option<RelationDef> {
|
||||||
|
Some(super::app_user::Relation::App.def().rev())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
@ -0,0 +1,52 @@
|
|||||||
|
//! `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 = "app_user")]
|
||||||
|
pub struct Model {
|
||||||
|
pub created: Option<DateTime>,
|
||||||
|
pub updated: Option<DateTime>,
|
||||||
|
#[sea_orm(primary_key, auto_increment = false)]
|
||||||
|
pub app_id: String,
|
||||||
|
#[sea_orm(primary_key, auto_increment = false)]
|
||||||
|
pub user_id: String,
|
||||||
|
pub status: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
|
pub enum Relation {
|
||||||
|
#[sea_orm(
|
||||||
|
belongs_to = "super::app::Entity",
|
||||||
|
from = "Column::AppId",
|
||||||
|
to = "super::app::Column::Id",
|
||||||
|
on_update = "NoAction",
|
||||||
|
on_delete = "NoAction"
|
||||||
|
)]
|
||||||
|
App,
|
||||||
|
#[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::app::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::App.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::user::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::User.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
@ -0,0 +1,11 @@
|
|||||||
|
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.3
|
||||||
|
|
||||||
|
pub mod prelude;
|
||||||
|
|
||||||
|
pub mod access;
|
||||||
|
pub mod app;
|
||||||
|
pub mod app_user;
|
||||||
|
pub mod resource;
|
||||||
|
pub mod role;
|
||||||
|
pub mod user;
|
||||||
|
pub mod user_role;
|
@ -0,0 +1,9 @@
|
|||||||
|
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.3
|
||||||
|
|
||||||
|
pub use super::access::Entity as Access;
|
||||||
|
pub use super::app::Entity as App;
|
||||||
|
pub use super::app_user::Entity as AppUser;
|
||||||
|
pub use super::resource::Entity as Resource;
|
||||||
|
pub use super::role::Entity as Role;
|
||||||
|
pub use super::user::Entity as User;
|
||||||
|
pub use super::user_role::Entity as UserRole;
|
@ -0,0 +1,47 @@
|
|||||||
|
//! `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 = "resource")]
|
||||||
|
pub struct Model {
|
||||||
|
pub created: Option<DateTime>,
|
||||||
|
pub updated: Option<DateTime>,
|
||||||
|
pub delete_flag: i8,
|
||||||
|
#[sea_orm(primary_key, auto_increment = false)]
|
||||||
|
pub app_id: String,
|
||||||
|
#[sea_orm(primary_key, auto_increment = false)]
|
||||||
|
pub name: String,
|
||||||
|
pub des: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
|
pub enum Relation {
|
||||||
|
#[sea_orm(has_many = "super::access::Entity")]
|
||||||
|
Access,
|
||||||
|
#[sea_orm(
|
||||||
|
belongs_to = "super::app::Entity",
|
||||||
|
from = "Column::AppId",
|
||||||
|
to = "super::app::Column::Id",
|
||||||
|
on_update = "NoAction",
|
||||||
|
on_delete = "NoAction"
|
||||||
|
)]
|
||||||
|
App,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::access::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::Access.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::app::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::App.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
@ -0,0 +1,65 @@
|
|||||||
|
//! `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 = "role")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key, auto_increment = false)]
|
||||||
|
pub id: String,
|
||||||
|
pub created: Option<DateTime>,
|
||||||
|
pub updated: Option<DateTime>,
|
||||||
|
pub delete_flag: i8,
|
||||||
|
pub app_id: String,
|
||||||
|
pub name: String,
|
||||||
|
pub des: Option<String>,
|
||||||
|
pub user_count: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
|
pub enum Relation {
|
||||||
|
#[sea_orm(has_many = "super::access::Entity")]
|
||||||
|
Access,
|
||||||
|
#[sea_orm(
|
||||||
|
belongs_to = "super::app::Entity",
|
||||||
|
from = "Column::AppId",
|
||||||
|
to = "super::app::Column::Id",
|
||||||
|
on_update = "NoAction",
|
||||||
|
on_delete = "NoAction"
|
||||||
|
)]
|
||||||
|
App,
|
||||||
|
#[sea_orm(has_many = "super::user_role::Entity")]
|
||||||
|
UserRole,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::access::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::Access.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::app::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::App.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::user_role::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::UserRole.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::user::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
super::user_role::Relation::User.def()
|
||||||
|
}
|
||||||
|
fn via() -> Option<RelationDef> {
|
||||||
|
Some(super::user_role::Relation::Role.def().rev())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
@ -0,0 +1,17 @@
|
|||||||
|
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.3
|
||||||
|
|
||||||
|
use sea_orm::entity::prelude::*;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)]
|
||||||
|
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "status")]
|
||||||
|
pub enum Status {
|
||||||
|
#[sea_orm(string_value = "ok")]
|
||||||
|
Ok,
|
||||||
|
#[sea_orm(string_value = "disabled")]
|
||||||
|
Disabled,
|
||||||
|
#[sea_orm(string_value = "applying")]
|
||||||
|
Applying,
|
||||||
|
#[sea_orm(string_value = "deny")]
|
||||||
|
Deny,
|
||||||
|
}
|
@ -0,0 +1,85 @@
|
|||||||
|
//! `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 = "user")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key, auto_increment = false)]
|
||||||
|
pub id: String,
|
||||||
|
pub created: Option<DateTime>,
|
||||||
|
pub updated: Option<DateTime>,
|
||||||
|
pub delete_flag: i8,
|
||||||
|
#[sea_orm(unique)]
|
||||||
|
pub username: String,
|
||||||
|
pub nickname: Option<String>,
|
||||||
|
#[sea_orm(unique)]
|
||||||
|
pub email: Option<String>,
|
||||||
|
#[sea_orm(unique)]
|
||||||
|
pub phone: Option<String>,
|
||||||
|
pub icon: Option<String>,
|
||||||
|
#[sea_orm(column_name = "_real_code")]
|
||||||
|
#[serde(skip)]
|
||||||
|
pub real_code: Option<String>,
|
||||||
|
#[sea_orm(
|
||||||
|
column_name = "_check_code",
|
||||||
|
column_type = "Binary(BlobSize::Blob(Some(48)))",
|
||||||
|
nullable
|
||||||
|
)]
|
||||||
|
#[serde(skip)]
|
||||||
|
pub check_code: Option<Vec<u8>>,
|
||||||
|
pub status: i32,
|
||||||
|
pub used: i32,
|
||||||
|
pub space: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
|
pub enum Relation {
|
||||||
|
#[sea_orm(has_many = "super::access::Entity")]
|
||||||
|
Access,
|
||||||
|
#[sea_orm(has_many = "super::app_user::Entity")]
|
||||||
|
AppUser,
|
||||||
|
#[sea_orm(has_many = "super::user_role::Entity")]
|
||||||
|
UserRole,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::access::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::Access.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::app_user::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::AppUser.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::user_role::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::UserRole.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::app::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
super::app_user::Relation::App.def()
|
||||||
|
}
|
||||||
|
fn via() -> Option<RelationDef> {
|
||||||
|
Some(super::app_user::Relation::User.def().rev())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::role::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
super::user_role::Relation::Role.def()
|
||||||
|
}
|
||||||
|
fn via() -> Option<RelationDef> {
|
||||||
|
Some(super::user_role::Relation::User.def().rev())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
@ -0,0 +1,52 @@
|
|||||||
|
//! `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 = "user_role")]
|
||||||
|
pub struct Model {
|
||||||
|
pub created: Option<DateTime>,
|
||||||
|
pub updated: Option<DateTime>,
|
||||||
|
#[sea_orm(primary_key, auto_increment = false)]
|
||||||
|
pub user_id: String,
|
||||||
|
#[sea_orm(primary_key, auto_increment = false)]
|
||||||
|
pub role_id: String,
|
||||||
|
pub status: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
|
pub enum Relation {
|
||||||
|
#[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::role::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::Role.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::user::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::User.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
Loading…
Reference in New Issue