Files
imphnen-backend-service/src/apps/v1/users/users_schema.rs
T

57 lines
1.3 KiB
Rust
Raw Normal View History

2025-03-30 16:08:58 +07:00
use crate::{get_iso_date, make_thing, ResourceEnum};
2025-03-21 17:00:19 +07:00
use serde::{Deserialize, Serialize};
2025-03-30 16:08:58 +07:00
use surrealdb::{sql::Thing, Uuid};
2025-03-14 17:50:37 +07:00
2025-03-20 22:41:20 +07:00
#[derive(Clone, Debug, Serialize, Deserialize)]
2025-03-14 17:50:37 +07:00
pub struct UsersSchema {
2025-03-21 17:00:19 +07:00
pub id: Thing,
2025-03-14 17:50:37 +07:00
pub fullname: String,
2025-03-21 05:36:00 +07:00
pub email: String,
2025-03-14 17:50:37 +07:00
pub password: String,
2025-03-21 05:36:00 +07:00
pub avatar: Option<String>,
pub phone_number: String,
2025-03-18 14:13:53 +07:00
pub is_active: bool,
2025-03-23 07:56:43 +07:00
pub is_deleted: bool,
2025-03-21 05:36:00 +07:00
pub gender: Option<String>,
pub birthdate: Option<String>,
pub role: Thing,
2025-03-30 02:46:16 +07:00
pub created_at: String,
pub updated_at: String,
2025-03-14 17:50:37 +07:00
}
2025-03-20 22:41:20 +07:00
2025-03-21 13:25:22 +07:00
impl Default for UsersSchema {
fn default() -> Self {
UsersSchema {
2025-03-30 16:08:58 +07:00
id: make_thing(
&ResourceEnum::Users.to_string(),
&Uuid::new_v4().to_string(),
),
2025-03-21 13:25:22 +07:00
fullname: String::new(),
email: String::new(),
password: String::new(),
avatar: None,
phone_number: String::new(),
is_active: false,
2025-03-23 07:56:43 +07:00
is_deleted: false,
2025-03-21 13:25:22 +07:00
gender: None,
birthdate: None,
2025-03-30 16:08:58 +07:00
role: make_thing(
&ResourceEnum::Roles.to_string(),
&Uuid::new_v4().to_string(),
),
2025-03-30 02:46:16 +07:00
created_at: get_iso_date(),
updated_at: get_iso_date(),
2025-03-21 13:25:22 +07:00
}
}
}
2025-03-20 22:41:20 +07:00
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct UsersSetNewPasswordSchema {
2025-03-21 05:36:00 +07:00
pub password: String,
2025-03-20 22:41:20 +07:00
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct UsersActiveInactiveSchema {
pub is_active: bool,
}