use sea_orm::entity::prelude::*;
use super::role::GroupWorkerRole;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "group_worker")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i64,
pub group_id: i64,
pub worker_id: i64,
pub role: GroupWorkerRole,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::groups::Entity",
from = "Column::GroupId",
to = "super::groups::Column::Id",
on_update = "Cascade",
on_delete = "Restrict"
)]
Groups,
#[sea_orm(
belongs_to = "super::workers::Entity",
from = "Column::WorkerId",
to = "super::workers::Column::Id",
on_update = "Cascade",
on_delete = "Restrict"
)]
Workers,
}
impl Related<super::groups::Entity> for Entity {
fn to() -> RelationDef {
Relation::Groups.def()
}
}
impl Related<super::workers::Entity> for Entity {
fn to() -> RelationDef {
Relation::Workers.def()
}
}
impl ActiveModelBehavior for ActiveModel {}