Init
This commit is contained in:
50
src/interfaces/http/dto/channel.rs
Normal file
50
src/interfaces/http/dto/channel.rs
Normal 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()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user