add models

This commit is contained in:
2022-08-06 11:56:56 +08:00
parent 92979a7391
commit 4dbd95fd4b
9 changed files with 247 additions and 45 deletions

26
src/web/model/audit.rs Normal file
View File

@ -0,0 +1,26 @@
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.1
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "audit")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub created_at: String,
pub source: String,
pub r#type: String,
pub description: String,
}
#[derive(Copy, Clone, Debug, EnumIter)]
pub enum Relation {}
impl RelationTrait for Relation {
fn def(&self) -> RelationDef {
panic!("No RelationDef")
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -2,4 +2,6 @@
pub mod prelude;
pub mod audit;
pub mod user;
pub mod user_password;

View File

@ -1,3 +1,5 @@
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.1
pub use super::audit::Entity as Audit;
pub use super::user::Entity as User;
pub use super::user_password::Entity as UserPassword;

View File

@ -8,16 +8,22 @@ use serde::{Deserialize, Serialize};
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub created_at: String,
pub updated_at: String,
pub deleted_at: String,
pub name: String,
pub password: String,
pub enabled: i32,
}
#[derive(Copy, Clone, Debug, EnumIter)]
pub enum Relation {}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::user_password::Entity")]
UserPassword,
}
impl RelationTrait for Relation {
fn def(&self) -> RelationDef {
panic!("No RelationDef")
impl Related<super::user_password::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserPassword.def()
}
}

View File

@ -0,0 +1,34 @@
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.1
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "user_password")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub created_at: String,
pub user_id: i32,
pub password: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "Cascade",
on_delete = "Cascade"
)]
User,
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}