init
This commit is contained in:
@@ -1,5 +1,44 @@
|
||||
use super::{domain::Channel, dto::ChannelResponse};
|
||||
use crate::models::channel;
|
||||
use crate::routes::channel::dto::{ChannelResponse, CreateChannelRequest, UpdateChannelRequest};
|
||||
use sea_orm::Set;
|
||||
use uuid::Uuid;
|
||||
|
||||
pub fn to_response(_item: Channel) -> ChannelResponse {
|
||||
todo!()
|
||||
pub fn channel_model_to_channel_response(model: channel::Model) -> ChannelResponse {
|
||||
ChannelResponse {
|
||||
id: model.id,
|
||||
server_id: model.server_id,
|
||||
category_id: model.category_id,
|
||||
position: model.position,
|
||||
channel_type: model.channel_type,
|
||||
name: model.name,
|
||||
created_at: model.created_at,
|
||||
updated_at: model.updated_at,
|
||||
default_permissions: model.default_permissions,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_request_to_am(req: CreateChannelRequest) -> channel::ActiveModel {
|
||||
channel::ActiveModel {
|
||||
id: Set(Uuid::new_v4()),
|
||||
server_id: Set(req.server_id),
|
||||
category_id: Set(req.category_id),
|
||||
position: Set(req.position),
|
||||
channel_type: Set(req.channel_type),
|
||||
name: Set(req.name),
|
||||
default_permissions: Set(req.default_permissions),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_request_to_am(id: Uuid, req: UpdateChannelRequest) -> channel::ActiveModel {
|
||||
channel::ActiveModel {
|
||||
id: Set(id),
|
||||
server_id: Set(req.server_id),
|
||||
category_id: Set(req.category_id),
|
||||
position: Set(req.position),
|
||||
channel_type: Set(req.channel_type),
|
||||
name: Set(req.name),
|
||||
default_permissions: Set(req.default_permissions),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user