diff options
Diffstat (limited to 'src/models.rs')
| -rw-r--r-- | src/models.rs | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/models.rs b/src/models.rs index 4821ec3..e815b73 100644 --- a/src/models.rs +++ b/src/models.rs | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | use entity::{queues, users}; | 1 | use chrono::NaiveDateTime; |
| 2 | use entity::{invite_tokens, queues, users}; | ||
| 2 | use serde::Serialize; | 3 | use serde::Serialize; |
| 3 | use utoipa::ToSchema; | 4 | use utoipa::ToSchema; |
| 5 | use uuid::Uuid; | ||
| 4 | 6 | ||
| 5 | #[derive(Serialize, ToSchema)] | 7 | #[derive(Serialize, ToSchema)] |
| 6 | #[schema(description = "Account information")] | 8 | #[schema(description = "Account information")] |
| @@ -42,3 +44,28 @@ impl From<queues::Model> for Queue { | |||
| 42 | } | 44 | } |
| 43 | } | 45 | } |
| 44 | } | 46 | } |
| 47 | |||
| 48 | #[derive(Serialize, ToSchema)] | ||
| 49 | pub struct InviteToken { | ||
| 50 | #[schema(examples(1))] | ||
| 51 | pub id: i64, | ||
| 52 | pub token: Uuid, | ||
| 53 | #[schema(examples(1))] | ||
| 54 | pub queue_id: i64, | ||
| 55 | #[schema(examples("For classmates", "Для однокурсников"))] | ||
| 56 | pub name: String, | ||
| 57 | #[schema(examples(false))] | ||
| 58 | pub expiration_date: Option<NaiveDateTime>, | ||
| 59 | } | ||
| 60 | |||
| 61 | impl From<invite_tokens::Model> for InviteToken { | ||
| 62 | fn from(value: invite_tokens::Model) -> Self { | ||
| 63 | Self { | ||
| 64 | id: value.id, | ||
| 65 | token: value.token, | ||
| 66 | queue_id: value.queue_id, | ||
| 67 | name: value.name, | ||
| 68 | expiration_date: value.expiration_date, | ||
| 69 | } | ||
| 70 | } | ||
| 71 | } | ||
