This commit is contained in:
2026-03-01 03:33:36 +01:00
parent 68f16055a8
commit e982ea372f
26 changed files with 496 additions and 550 deletions

View File

@@ -1,7 +1,7 @@
use crate::models::channel;
use crate::models::channel::ChannelType;
use sea_orm::Set;
use serde::Serialize;
use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[derive(Debug, Serialize)]
@@ -27,11 +27,11 @@ impl From<channel::Model> for ChannelResponse {
}
}
#[derive(Debug, Serialize)]
#[derive(Debug, Deserialize)]
pub struct CreateChannelRequest {
pub server_id: Option<Uuid>,
pub category_id: Option<Uuid>,
pub position: i32,
pub position: Option<i32>,
pub channel_type: ChannelType,
pub name: Option<String>,
}
@@ -41,10 +41,21 @@ impl From<CreateChannelRequest> for channel::ActiveModel {
Self {
server_id: Set(request.server_id),
category_id: Set(request.category_id),
position: Set(request.position),
position: Set(request.position.unwrap_or(0)),
channel_type: Set(request.channel_type),
name: Set(request.name),
..Default::default()
}
}
}
impl CreateChannelRequest {
pub fn apply_to(self, mut am: channel::ActiveModel) -> channel::ActiveModel {
am.server_id = Set(self.server_id);
am.category_id = Set(self.category_id);
am.position = Set(self.position.unwrap_or(0));
am.channel_type = Set(self.channel_type);
am.name = Set(self.name);
am
}
}