aboutsummaryrefslogtreecommitdiff
path: root/src/models.rs
blob: b7631a491d97aa2e1eb69c4603e3a7b88110ecdc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use entity::users;
use serde::Serialize;
use utoipa::ToSchema;

#[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<users::Model> 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,
        }
    }
}