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

@ -0,0 +1,35 @@
use pagetop::db::entity::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "role_permission")]
pub struct Model {
#[sea_orm(primary_key)]
pub rid : u32,
#[sea_orm(primary_key)]
pub permission: String,
pub module : String,
}
#[derive(Copy, Clone, Debug, EnumIter)]
pub enum Relation {
Role,
}
impl RelationTrait for Relation {
fn def(&self) -> RelationDef {
match self {
Self::Role => Entity::belongs_to(super::role::Entity)
.from(Column::Rid)
.to(super::role::Column::Rid)
.into(),
}
}
}
impl Related<super::role::Entity> for Entity {
fn to() -> RelationDef {
Relation::Role.def()
}
}
impl ActiveModelBehavior for ActiveModel {}