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 -22
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 = "category")]
pub struct Model {
@@ -14,32 +15,16 @@ pub struct Model {
pub position: i32,
pub created_at: DateTimeUtc,
pub updated_at: DateTimeUtc,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::channel::Entity")]
Channel,
#[sea_orm(has_many)]
pub channels: HasMany<super::channel::Entity>,
#[sea_orm(
belongs_to = "super::server::Entity",
from = "Column::ServerId",
to = "super::server::Column::Id",
belongs_to,
from = "server_id",
to = "id",
on_update = "Cascade",
on_delete = "Cascade"
)]
Server,
}
impl Related<super::channel::Entity> for Entity {
fn to() -> RelationDef {
Relation::Channel.def()
}
}
impl Related<super::server::Entity> for Entity {
fn to() -> RelationDef {
Relation::Server.def()
}
pub server: HasOne<super::server::Entity>,
}
#[async_trait]