This commit is contained in:
2026-02-21 10:39:52 +01:00
parent f7c975a3f0
commit 66c1fe0025
38 changed files with 1543 additions and 616 deletions

View File

@@ -0,0 +1,50 @@
use crate::models::channel;
use crate::models::channel::ChannelType;
use sea_orm::Set;
use serde::Serialize;
use uuid::Uuid;
#[derive(Debug, Serialize)]
pub struct ChannelResponse {
pub id: Uuid,
pub server_id: Option<Uuid>,
pub category_id: Option<Uuid>,
pub position: i32,
pub channel_type: ChannelType,
pub name: Option<String>,
}
impl From<channel::Model> for ChannelResponse {
fn from(model: channel::Model) -> Self {
Self {
id: model.id,
server_id: model.server_id,
category_id: model.category_id,
position: model.position,
channel_type: model.channel_type,
name: model.name,
}
}
}
#[derive(Debug, Serialize)]
pub struct CreateChannelRequest {
pub server_id: Option<Uuid>,
pub category_id: Option<Uuid>,
pub position: i32,
pub channel_type: ChannelType,
pub name: Option<String>,
}
impl From<CreateChannelRequest> for channel::ActiveModel {
fn from(request: CreateChannelRequest) -> Self {
Self {
server_id: Set(request.server_id),
category_id: Set(request.category_id),
position: Set(request.position),
channel_type: Set(request.channel_type),
name: Set(request.name),
..Default::default()
}
}
}