diff --git a/pagetop-user/Cargo.toml b/pagetop-user/Cargo.toml index d5e3aa84..3395241f 100644 --- a/pagetop-user/Cargo.toml +++ b/pagetop-user/Cargo.toml @@ -14,5 +14,4 @@ repository = "https://gitlab.com/manuelcillero/pagetop" [dependencies] pagetop = { path = "../pagetop" } -sea-orm = { version = "0.7.1" } serde = { version = "1.0", features = ["derive"] } diff --git a/pagetop-user/src/entity/mod.rs b/pagetop-user/src/entity/mod.rs deleted file mode 100644 index a8287bfe..00000000 --- a/pagetop-user/src/entity/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod role; -pub mod role_permission; -pub mod user; -pub mod user_role; diff --git a/pagetop-user/src/entity/role.rs b/pagetop-user/src/entity/role.rs deleted file mode 100644 index 2520ebe8..00000000 --- a/pagetop-user/src/entity/role.rs +++ /dev/null @@ -1,41 +0,0 @@ -use pagetop::db::entity::*; - -#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] -#[sea_orm(table_name = "role")] -pub struct Model { - #[sea_orm(primary_key)] - pub rid : u32, - #[sea_orm(unique)] - pub name : String, - #[sea_orm(default_value = 0)] - pub weight: i32, -} - -#[derive(Copy, Clone, Debug, EnumIter)] -pub enum Relation { - RolePermission, - UserRole, -} - -impl RelationTrait for Relation { - fn def(&self) -> RelationDef { - match self { - Self::RolePermission => Entity::has_many(super::role_permission::Entity).into(), - Self::UserRole => Entity::has_many(super::user_role::Entity).into(), - } - } -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::RolePermission.def() - } -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::UserRole.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/pagetop-user/src/entity/role_permission.rs b/pagetop-user/src/entity/role_permission.rs deleted file mode 100644 index 2c2859d1..00000000 --- a/pagetop-user/src/entity/role_permission.rs +++ /dev/null @@ -1,35 +0,0 @@ -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 for Entity { - fn to() -> RelationDef { - Relation::Role.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/pagetop-user/src/entity/user.rs b/pagetop-user/src/entity/user.rs deleted file mode 100644 index 8bec2f1e..00000000 --- a/pagetop-user/src/entity/user.rs +++ /dev/null @@ -1,39 +0,0 @@ -use pagetop::db::entity::*; - -#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] -#[sea_orm(table_name = "user")] -pub struct Model { - #[sea_orm(primary_key, auto_increment = false)] - pub uid : u32, - #[sea_orm(unique)] - pub name : String, - pub pass : String, - pub mail : Option, - pub created : DateTimeUtc, - pub changed : DateTimeUtc, - pub access : DateTimeUtc, - pub login : DateTimeUtc, - pub status : bool, - pub timezone: Option, -} - -#[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 for Entity { - fn to() -> RelationDef { - Relation::UserRole.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/pagetop-user/src/entity/user_role.rs b/pagetop-user/src/entity/user_role.rs deleted file mode 100644 index 23a6af8f..00000000 --- a/pagetop-user/src/entity/user_role.rs +++ /dev/null @@ -1,45 +0,0 @@ -use pagetop::db::entity::*; - -#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] -#[sea_orm(table_name = "user_role")] -pub struct Model { - #[sea_orm(primary_key)] - pub uid: u32, - #[sea_orm(primary_key)] - pub rid: u32, -} - -#[derive(Copy, Clone, Debug, EnumIter)] -pub enum Relation { - User, - Role, -} - -impl RelationTrait for Relation { - fn def(&self) -> RelationDef { - match self { - Self::User => Entity::belongs_to(super::user::Entity) - .from(Column::Uid) - .to(super::user::Column::Uid) - .into(), - Self::Role => Entity::belongs_to(super::role::Entity) - .from(Column::Rid) - .to(super::role::Column::Rid) - .into(), - } - } -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::User.def() - } -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::Role.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/pagetop-user/src/lib.rs b/pagetop-user/src/lib.rs index 4059cc79..a55ea4e8 100644 --- a/pagetop-user/src/lib.rs +++ b/pagetop-user/src/lib.rs @@ -2,7 +2,6 @@ use pagetop::prelude::*; localize!("src/locales"); -mod entity; mod migration; pub struct UserModule;