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
+7 -28
View File
@@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
use sea_orm::prelude::async_trait::async_trait;
use sea_orm::Set;
#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "server")]
pub struct Model {
@@ -15,34 +16,12 @@ pub struct Model {
pub updated_at: DateTimeUtc,
pub is_default: bool,
pub owner_id: Option<Uuid>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::category::Entity")]
Category,
#[sea_orm(has_many = "super::channel::Entity")]
Channel,
#[sea_orm(has_many = "super::server_user::Entity")]
ServerUser,
}
impl Related<super::category::Entity> for Entity {
fn to() -> RelationDef {
Relation::Category.def()
}
}
impl Related<super::channel::Entity> for Entity {
fn to() -> RelationDef {
Relation::Channel.def()
}
}
impl Related<super::server_user::Entity> for Entity {
fn to() -> RelationDef {
Relation::ServerUser.def()
}
#[sea_orm(has_many)]
pub categories: HasMany<super::category::Entity>,
#[sea_orm(has_many)]
pub channels: HasMany<super::channel::Entity>,
#[sea_orm(has_many)]
pub server_users: HasMany<super::server_user::Entity>,
}
#[async_trait]