Añade las entidades asociadas a roles y usuarios
This commit is contained in:
parent
4af6586003
commit
d07611d044
5 changed files with 156 additions and 11 deletions
35
pagetop-user/src/entity/role_permission.rs
Normal file
35
pagetop-user/src/entity/role_permission.rs
Normal 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 {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue