init
This commit is contained in:
32
src/store/models/channel.rs
Normal file
32
src/store/models/channel.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
// use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
// use uuid::Uuid;
|
||||
use sqlx::types::{Uuid, chrono::{{ DateTime, Utc}}};
|
||||
|
||||
#[derive(Debug, Clone, sqlx::FromRow, Serialize, Deserialize)]
|
||||
pub struct Channel {
|
||||
pub id: Uuid,
|
||||
pub sub_server_id: Uuid,
|
||||
pub channel_type: ChannelType,
|
||||
pub name: String,
|
||||
pub created_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, sqlx::Type, Serialize, Deserialize)]
|
||||
#[repr(i32)]
|
||||
pub enum ChannelType {
|
||||
Text = 0,
|
||||
Voice = 1,
|
||||
}
|
||||
|
||||
impl Channel {
|
||||
pub fn new(sub_server_id: Uuid, channel_type: ChannelType, name: String) -> Self {
|
||||
Self {
|
||||
id: Uuid::new_v4(),
|
||||
sub_server_id,
|
||||
channel_type,
|
||||
name,
|
||||
created_at: Utc::now(),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user