Añade las entidades asociadas a roles y usuarios

This commit is contained in:
Manuel Cillero 2022-04-20 00:21:49 +02:00
parent 4af6586003
commit d07611d044
5 changed files with 156 additions and 11 deletions

View file

@ -1,18 +1,39 @@
use crate::db::entity::*;
use serde::{Deserialize, Serialize};
use pagetop::db::entity::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Deserialize, Serialize)]
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "user")]
pub struct Model {
#[sea_orm(primary_key)]
#[serde(skip_deserializing)]
pub id: i32,
pub title: String,
#[sea_orm(column_type = "Text")]
pub text: String,
#[sea_orm(primary_key, auto_increment = false)]
pub uid : u32,
#[sea_orm(unique)]
pub name : String,
pub pass : String,
pub mail : Option<String>,
pub created : DateTimeUtc,
pub changed : DateTimeUtc,
pub access : DateTimeUtc,
pub login : DateTimeUtc,
pub status : bool,
pub timezone: Option<String>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
#[derive(Copy, Clone, Debug, EnumIter)]
pub enum Relation {
UserRole,
}
impl RelationTrait for Relation {
fn def(&self) -> RelationDef {
match self {
Self::UserRole => Entity::has_many(super::user_role::Entity).into(),
}
}
}
impl Related<super::user_role::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserRole.def()
}
}
impl ActiveModelBehavior for ActiveModel {}