This commit is contained in:
2026-07-13 09:27:07 +02:00
parent 09cf5f37fb
commit 843dad8d79
18 changed files with 427 additions and 563 deletions
+9 -24
View File
@@ -2,6 +2,7 @@
use sea_orm::entity::prelude::*;
#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "role_user")]
pub struct Model {
@@ -9,38 +10,22 @@ pub struct Model {
pub role_id: Uuid,
#[sea_orm(primary_key, auto_increment = false)]
pub user_id: Uuid,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::role::Entity",
from = "Column::RoleId",
to = "super::role::Column::Id",
belongs_to,
from = "role_id",
to = "id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Group,
pub role: HasOne<super::role::Entity>,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
belongs_to,
from = "user_id",
to = "id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::role::Entity> for Entity {
fn to() -> RelationDef {
Relation::Group.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
pub user: HasOne<super::user::Entity>,
}
impl ActiveModelBehavior for ActiveModel {}