diff options
Diffstat (limited to 'src/models.rs')
| -rw-r--r-- | src/models.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/models.rs b/src/models.rs new file mode 100644 index 0000000..b7631a4 --- /dev/null +++ b/src/models.rs | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | use entity::users; | ||
| 2 | use serde::Serialize; | ||
| 3 | use utoipa::ToSchema; | ||
| 4 | |||
| 5 | #[derive(Serialize, ToSchema)] | ||
| 6 | #[schema(description = "Account information")] | ||
| 7 | pub struct Account { | ||
| 8 | #[schema(examples(1))] | ||
| 9 | pub id: i64, | ||
| 10 | #[schema(examples("john_doe", "ivanov_ivan"))] | ||
| 11 | pub username: String, | ||
| 12 | #[schema(examples("John", "Иван"))] | ||
| 13 | pub first_name: String, | ||
| 14 | #[schema(examples("Doe", "Иванов"))] | ||
| 15 | pub last_name: String, | ||
| 16 | } | ||
| 17 | |||
| 18 | impl From<users::Model> for Account { | ||
| 19 | fn from(value: users::Model) -> Self { | ||
| 20 | Self { | ||
| 21 | id: value.id, | ||
| 22 | username: value.username, | ||
| 23 | first_name: value.first_name, | ||
| 24 | last_name: value.last_name, | ||
| 25 | } | ||
| 26 | } | ||
| 27 | } | ||
