feat(users): Add optional fields to user schemas and update user avatar functionality
This commit is contained in:
@@ -9,11 +9,15 @@ use surrealdb::{Uuid, sql::Thing};
|
||||
pub struct UsersSchema {
|
||||
pub id: Thing,
|
||||
pub fullname: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub legal_name: Option<String>,
|
||||
pub email: String,
|
||||
pub password: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub avatar: Option<String>,
|
||||
pub phone_number: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub phone_for_verification: Option<String>,
|
||||
pub is_active: bool,
|
||||
pub is_deleted: bool,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
@@ -22,6 +26,22 @@ pub struct UsersSchema {
|
||||
pub gender: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub birthdate: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub domicile: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub identity_document_url: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub bio: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub last_education: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub linkedin_url: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub github_url: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub cv_url: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub portfolio_url: Option<String>,
|
||||
pub role: Thing,
|
||||
pub created_at: String,
|
||||
pub updated_at: String,
|
||||
@@ -35,10 +55,12 @@ impl Default for UsersSchema {
|
||||
&Uuid::new_v4().to_string(),
|
||||
),
|
||||
fullname: String::new(),
|
||||
legal_name: None,
|
||||
email: String::new(),
|
||||
password: hash_password("").unwrap(),
|
||||
avatar: None,
|
||||
phone_number: String::new(),
|
||||
phone_for_verification: None,
|
||||
is_active: false,
|
||||
is_deleted: false,
|
||||
mentor_id: Some(make_thing(
|
||||
@@ -47,6 +69,14 @@ impl Default for UsersSchema {
|
||||
)),
|
||||
gender: None,
|
||||
birthdate: None,
|
||||
domicile: None,
|
||||
identity_document_url: None,
|
||||
bio: None,
|
||||
last_education: None,
|
||||
linkedin_url: None,
|
||||
github_url: None,
|
||||
cv_url: None,
|
||||
portfolio_url: None,
|
||||
role: make_thing(
|
||||
&ResourceEnum::Roles.to_string(),
|
||||
"5713cb37-dc02-4e87-8048-d7a41d352059",
|
||||
@@ -62,9 +92,11 @@ impl UsersSchema {
|
||||
Self {
|
||||
id: dto.id,
|
||||
fullname: dto.fullname,
|
||||
legal_name: dto.legal_name,
|
||||
email: dto.email,
|
||||
avatar: dto.avatar,
|
||||
phone_number: dto.phone_number,
|
||||
phone_for_verification: dto.phone_for_verification,
|
||||
is_active: dto.is_active,
|
||||
is_deleted: dto.is_deleted,
|
||||
mentor_id: Some(dto.mentor_id.unwrap_or_else(|| {
|
||||
@@ -75,6 +107,14 @@ impl UsersSchema {
|
||||
})),
|
||||
gender: dto.gender,
|
||||
birthdate: dto.birthdate,
|
||||
domicile: dto.domicile,
|
||||
identity_document_url: dto.identity_document_url,
|
||||
bio: dto.bio,
|
||||
last_education: dto.last_education,
|
||||
linkedin_url: dto.linkedin_url,
|
||||
github_url: dto.github_url,
|
||||
cv_url: dto.cv_url,
|
||||
portfolio_url: dto.portfolio_url,
|
||||
password: dto.password,
|
||||
created_at: dto.created_at,
|
||||
updated_at: dto.updated_at,
|
||||
@@ -86,11 +126,21 @@ impl UsersSchema {
|
||||
Self {
|
||||
id: make_thing(&ResourceEnum::Users.to_string(), &id),
|
||||
fullname: user.fullname,
|
||||
legal_name: user.legal_name,
|
||||
email: user.email,
|
||||
phone_number: user.phone_number,
|
||||
phone_for_verification: user.phone_for_verification,
|
||||
is_active: user.is_active,
|
||||
gender: user.gender,
|
||||
birthdate: user.birthdate,
|
||||
domicile: user.domicile,
|
||||
identity_document_url: user.identity_document_url,
|
||||
bio: user.bio,
|
||||
last_education: user.last_education,
|
||||
linkedin_url: user.linkedin_url,
|
||||
github_url: user.github_url,
|
||||
cv_url: user.cv_url,
|
||||
portfolio_url: user.portfolio_url,
|
||||
avatar: user.avatar,
|
||||
is_deleted: false,
|
||||
role: make_thing(&ResourceEnum::Roles.to_string(), &user.role_id),
|
||||
@@ -107,9 +157,11 @@ impl UsersSchema {
|
||||
&Uuid::new_v4().to_string(),
|
||||
),
|
||||
fullname: user.fullname,
|
||||
legal_name: None,
|
||||
email: user.email,
|
||||
password,
|
||||
phone_number: user.phone_number,
|
||||
phone_for_verification: None,
|
||||
is_active: false,
|
||||
mentor_id: Some(make_thing(
|
||||
&ResourceEnum::Users.to_string(),
|
||||
@@ -117,6 +169,14 @@ impl UsersSchema {
|
||||
)),
|
||||
gender: None,
|
||||
birthdate: None,
|
||||
domicile: None,
|
||||
identity_document_url: None,
|
||||
bio: None,
|
||||
last_education: None,
|
||||
linkedin_url: None,
|
||||
github_url: None,
|
||||
cv_url: None,
|
||||
portfolio_url: None,
|
||||
avatar: user.avatar,
|
||||
is_deleted: false,
|
||||
role: make_thing(&ResourceEnum::Roles.to_string(), &user.role_id),
|
||||
|
||||
Reference in New Issue
Block a user