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

72 lines
1.6 KiB
Rust
Raw Normal View History

2025-03-21 13:25:22 +07:00
use crate::ResourceEnum;
2025-03-21 17:00:19 +07:00
use serde::{Deserialize, Serialize};
use surrealdb::{
sql::{Id, 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,
pub referral_code: Option<String>,
pub referred_by: Option<String>,
pub identity_number: Option<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 student_type: String,
pub religion: Option<String>,
pub gender: Option<String>,
pub birthdate: Option<String>,
2025-03-21 13:25:22 +07:00
pub is_profile_completed: bool,
2025-03-21 05:36:00 +07:00
pub role: Thing,
pub created_at: Option<String>,
pub updated_at: Option<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-21 17:00:19 +07:00
id: Thing::from((
ResourceEnum::Users.to_string(),
Id::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(),
referral_code: None,
referred_by: None,
identity_number: None,
is_active: false,
2025-03-23 07:56:43 +07:00
is_deleted: false,
2025-03-21 13:25:22 +07:00
student_type: String::new(),
religion: None,
gender: None,
birthdate: None,
2025-03-21 17:00:19 +07:00
is_profile_completed: false,
2025-03-21 13:25:22 +07:00
role: Thing::from((
ResourceEnum::Roles.to_string(),
2025-03-21 17:00:19 +07:00
Id::String(Uuid::new_v4().to_string()),
2025-03-21 13:25:22 +07:00
)),
created_at: None,
updated_at: None,
}
}
}
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,
}