add models
This commit is contained in:
26
src/web/model/audit.rs
Normal file
26
src/web/model/audit.rs
Normal 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 {}
|
@ -2,4 +2,6 @@
|
||||
|
||||
pub mod prelude;
|
||||
|
||||
pub mod audit;
|
||||
pub mod user;
|
||||
pub mod user_password;
|
||||
|
@ -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;
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
34
src/web/model/user_password.rs
Normal file
34
src/web/model/user_password.rs
Normal 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 {}
|
Reference in New Issue
Block a user