postmasterlib/dto/
user.rs

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use chrono::NaiveDateTime;
use common::enums::gender::Gender;
use common::enums::r_status::RStatus;
use serde::{Deserialize, Serialize};
use uuid::Uuid;

#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
#[serde(rename_all = "camelCase")]
pub struct User {
    pub first_name: String,
    pub middle_name: Option<String>,
    pub last_name: String,
    pub nickname: Option<String>,
    pub shapass: String,
    pub birthday: Option<NaiveDateTime>,
    pub email: String,
    pub phone: Option<String>,
    pub site: Option<String>,
    pub last_online: Option<NaiveDateTime>,
    pub last_offline: Option<NaiveDateTime>,
    pub updt: Option<NaiveDateTime>,
    pub ver: i32,
    pub language: Option<String>,
    pub terms_accepted: Option<i32>,
    pub is_first_login: Option<bool>,
    pub uuid: Uuid,
    pub updu: Option<Uuid>,
    pub avatar_path: Option<String>,
    pub status_name: String,
    pub gender: Gender,
    pub time_zone: Option<String>,
    pub bad_attempts: i32,
    pub title: Option<String>,
    pub rstatus: Option<RStatus>,
}

impl User {
    pub fn get_full_name(&self) -> String {
        if self.title.is_some() && !self.title.clone().unwrap().is_empty() {
            self.title.clone().unwrap()
                + " "
                + &*self.first_name.clone()
                + " "
                + &*self.last_name.clone()
        } else {
            self.first_name.clone() + " " + &*self.last_name.clone()
        }
    }
}