use sea_orm::entity::prelude::*;
use super::state::GroupState;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "groups")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i64,
#[sea_orm(column_type = "Text", unique)]
pub group_name: String,
pub creator_id: i64,
pub created_at: TimeDateTimeWithTimeZone,
pub updated_at: TimeDateTimeWithTimeZone,
pub state: GroupState,
pub task_count: i64,
pub storage_quota: i64,
pub storage_used: i64,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::active_tasks::Entity")]
ActiveTasks,
#[sea_orm(has_many = "super::archived_tasks::Entity")]
ArchivedTasks,
#[sea_orm(has_many = "super::attachments::Entity")]
Attachments,
#[sea_orm(has_many = "super::group_worker::Entity")]
GroupWorker,
#[sea_orm(has_many = "super::user_group::Entity")]
UserGroup,
#[sea_orm(
belongs_to = "super::users::Entity",
from = "Column::CreatorId",
to = "super::users::Column::Id",
on_update = "Cascade",
on_delete = "Restrict"
)]
Users,
}
impl Related<super::active_tasks::Entity> for Entity {
fn to() -> RelationDef {
Relation::ActiveTasks.def()
}
}
impl Related<super::archived_tasks::Entity> for Entity {
fn to() -> RelationDef {
Relation::ArchivedTasks.def()
}
}
impl Related<super::attachments::Entity> for Entity {
fn to() -> RelationDef {
Relation::Attachments.def()
}
}
impl Related<super::group_worker::Entity> for Entity {
fn to() -> RelationDef {
Relation::GroupWorker.def()
}
}
impl Related<super::user_group::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserGroup.def()
}
}
impl Related<super::users::Entity> for Entity {
fn to() -> RelationDef {
Relation::Users.def()
}
}
impl ActiveModelBehavior for ActiveModel {}