use chrono::NaiveDateTime; use entity::{invite_tokens, queues, users}; use serde::Serialize; use utoipa::ToSchema; use uuid::Uuid; #[derive(Serialize, ToSchema)] #[schema(description = "Account information")] pub struct Account { #[schema(examples(1))] pub id: i64, #[schema(examples("john_doe", "ivanov_ivan"))] pub username: String, #[schema(examples("John", "Иван"))] pub first_name: String, #[schema(examples("Doe", "Иванов"))] pub last_name: String, } impl From for Account { fn from(value: users::Model) -> Self { Self { id: value.id, username: value.username, first_name: value.first_name, last_name: value.last_name, } } } #[derive(Serialize, ToSchema)] pub struct Queue { #[schema(examples(1))] pub id: i64, #[schema(examples("John's queue", "Очередь Ивана"))] pub name: String, } impl From for Queue { fn from(value: queues::Model) -> Self { Self { id: value.id, name: value.name, } } } #[derive(Serialize, ToSchema)] pub struct InviteToken { #[schema(examples(1))] pub id: i64, pub token: Uuid, #[schema(examples(1))] pub queue_id: i64, #[schema(examples("For classmates", "Для однокурсников"))] pub name: String, #[schema(examples(false))] pub expiration_date: Option, } impl From for InviteToken { fn from(value: invite_tokens::Model) -> Self { Self { id: value.id, token: value.token, queue_id: value.queue_id, name: value.name, expiration_date: value.expiration_date, } } }