Refactor mentor and user schemas to centralize personal data management
- Updated `seed_mentor_user.rs` to include additional fields in the `app_users` creation and removed redundant fields from `app_mentors`. - Modified `seed_users.rs` to initialize new user fields including legal name, domicile, and professional links. - Adjusted `mentors_dto.rs` to remove personal data fields from `MentorDetailWithUserDto` and `MentorDetailResponseDto`, now sourced from `UsersSchema`. - Updated `mentors_repository.rs` to search for user data through `user_id` instead of mentor fields. - Refined `mentors_schema.rs` to remove personal data fields, now managed in `UsersSchema`. - Enhanced `mentors_service.rs` to populate mentor responses with user data from `UsersSchema`. - Removed identity document URL and related fields from various DTOs and schemas across the codebase. - Updated tests to reflect the removal of identity document URL and ensure compatibility with the new schema structure.
This commit is contained in:
@@ -18,15 +18,9 @@ pub struct MentorListResponseDto {
|
||||
pub struct MentorDetailWithUserDto {
|
||||
pub id: Thing,
|
||||
pub user_id: Thing,
|
||||
pub fullname: Option<String>,
|
||||
pub email: Option<String>,
|
||||
pub legal_name: String,
|
||||
pub identity_document_url: String,
|
||||
pub phone_for_verification: String,
|
||||
pub bio: String,
|
||||
pub linkedin_url: Option<String>,
|
||||
pub github_url: Option<String>,
|
||||
pub cv_url: Option<String>,
|
||||
// Personal data is now in UsersSchema, access via user_id
|
||||
// Removed: fullname, email, legal_name, identity_document_url,
|
||||
// phone_for_verification, bio, linkedin_url, github_url, cv_url
|
||||
pub industries: Vec<String>,
|
||||
pub expertise: Vec<String>,
|
||||
pub languages: Vec<String>,
|
||||
@@ -47,15 +41,20 @@ pub struct MentorDetailWithUserDto {
|
||||
pub struct MentorDetailResponseDto {
|
||||
pub id: String,
|
||||
pub user_id: String,
|
||||
// Personal data fields from UsersSchema
|
||||
pub fullname: Option<String>,
|
||||
pub email: Option<String>,
|
||||
pub legal_name: String,
|
||||
pub identity_document_url: String,
|
||||
pub phone_for_verification: String,
|
||||
pub bio: String,
|
||||
pub legal_name: Option<String>,
|
||||
pub gender: Option<String>,
|
||||
pub domicile: Option<String>,
|
||||
pub phone_for_verification: Option<String>,
|
||||
pub bio: Option<String>,
|
||||
pub last_education: Option<String>,
|
||||
pub linkedin_url: Option<String>,
|
||||
pub github_url: Option<String>,
|
||||
pub cv_url: Option<String>,
|
||||
pub portfolio_url: Option<String>,
|
||||
// Professional data from MentorSchema
|
||||
pub industries: Vec<String>,
|
||||
pub expertise: Vec<String>,
|
||||
pub languages: Vec<String>,
|
||||
@@ -94,9 +93,6 @@ pub struct MentorUpdateRequestDto {
|
||||
pub gender: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub domicile: Option<String>,
|
||||
#[validate(url(message = "Invalid identity document URL"))]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub identity_document_url: Option<String>,
|
||||
#[validate(length(
|
||||
min = 10,
|
||||
max = 15,
|
||||
@@ -279,18 +275,7 @@ pub struct MentoringRate {
|
||||
pub struct MentorInsertDto {
|
||||
pub id: Thing,
|
||||
pub user_id: Option<Thing>,
|
||||
pub email: Option<String>,
|
||||
pub legal_name: String,
|
||||
pub gender: Option<String>,
|
||||
pub domicile: Option<String>,
|
||||
pub identity_document_url: String,
|
||||
pub phone_for_verification: String,
|
||||
pub bio: String,
|
||||
pub last_education: Option<String>,
|
||||
pub linkedin_url: Option<String>,
|
||||
pub github_url: Option<String>,
|
||||
pub cv_url: Option<String>,
|
||||
pub portfolio_url: Option<String>,
|
||||
// Personal data removed - now stored in UsersSchema
|
||||
pub industries: Vec<String>,
|
||||
pub expertise: Vec<String>,
|
||||
pub languages: Vec<String>,
|
||||
@@ -313,18 +298,7 @@ impl From<MentorSchema> for MentorInsertDto {
|
||||
MentorInsertDto {
|
||||
id: schema.id,
|
||||
user_id: schema.user_id,
|
||||
email: schema.email,
|
||||
legal_name: schema.legal_name,
|
||||
gender: schema.gender,
|
||||
domicile: schema.domicile,
|
||||
identity_document_url: schema.identity_document_url,
|
||||
phone_for_verification: schema.phone_for_verification,
|
||||
bio: schema.bio,
|
||||
last_education: schema.last_education,
|
||||
linkedin_url: schema.linkedin_url,
|
||||
github_url: schema.github_url,
|
||||
cv_url: schema.cv_url,
|
||||
portfolio_url: schema.portfolio_url,
|
||||
// Personal data removed from MentorSchema
|
||||
industries: schema.industries,
|
||||
expertise: schema.expertise,
|
||||
languages: schema.languages,
|
||||
@@ -354,19 +328,10 @@ pub struct MentorVerifyRequestDto {
|
||||
pub struct MentorDetailQueryDto {
|
||||
pub id: Thing,
|
||||
pub user_id: Thing,
|
||||
pub fullname: Option<String>,
|
||||
pub email: Option<String>,
|
||||
pub legal_name: String,
|
||||
pub gender: Option<String>,
|
||||
pub domicile: Option<String>,
|
||||
pub identity_document_url: String,
|
||||
pub phone_for_verification: String,
|
||||
pub bio: String,
|
||||
pub last_education: Option<String>,
|
||||
pub linkedin_url: Option<String>,
|
||||
pub github_url: Option<String>,
|
||||
pub cv_url: Option<String>,
|
||||
pub portfolio_url: Option<String>,
|
||||
// Personal data has been moved to UsersSchema
|
||||
// Use user_id to get: fullname, email, legal_name, gender, domicile,
|
||||
// identity_document_url, phone_for_verification, bio, last_education,
|
||||
// linkedin_url, github_url, cv_url, portfolio_url
|
||||
pub industries: Vec<String>,
|
||||
pub expertise: Vec<String>,
|
||||
pub languages: Vec<String>,
|
||||
@@ -388,8 +353,8 @@ impl From<MentorDetailQueryDto> for MentorListResponseDto {
|
||||
fn from(dto: MentorDetailQueryDto) -> Self {
|
||||
Self {
|
||||
id: extract_id(&dto.id),
|
||||
fullname: dto.fullname,
|
||||
email: dto.email,
|
||||
fullname: None, // now in user table, must be populated from service layer
|
||||
email: None, // now in user table, must be populated from service layer
|
||||
status: dto.status,
|
||||
created_at: dto.created_at,
|
||||
updated_at: dto.updated_at,
|
||||
@@ -402,15 +367,20 @@ impl From<MentorDetailQueryDto> for MentorDetailResponseDto {
|
||||
Self {
|
||||
id: extract_id(&dto.id),
|
||||
user_id: extract_id(&dto.user_id),
|
||||
fullname: dto.fullname,
|
||||
email: dto.email,
|
||||
legal_name: dto.legal_name,
|
||||
identity_document_url: dto.identity_document_url,
|
||||
phone_for_verification: dto.phone_for_verification,
|
||||
bio: dto.bio,
|
||||
linkedin_url: dto.linkedin_url,
|
||||
github_url: dto.github_url,
|
||||
cv_url: dto.cv_url,
|
||||
// Personal data fields are populated in service layer from UsersSchema
|
||||
fullname: None, // populated from user table in service layer
|
||||
email: None, // populated from user table in service layer
|
||||
legal_name: None, // populated from user table in service layer
|
||||
gender: None, // populated from user table in service layer
|
||||
domicile: None, // populated from user table in service layer
|
||||
phone_for_verification: None, // populated from user table in service layer
|
||||
bio: None, // populated from user table in service layer
|
||||
last_education: None, // populated from user table in service layer
|
||||
linkedin_url: None, // populated from user table in service layer
|
||||
github_url: None, // populated from user table in service layer
|
||||
cv_url: None, // populated from user table in service layer
|
||||
portfolio_url: None, // populated from user table in service layer
|
||||
// Professional data from mentor
|
||||
industries: dto.industries,
|
||||
expertise: dto.expertise,
|
||||
languages: dto.languages,
|
||||
@@ -433,7 +403,7 @@ impl From<MentorSchema> for MentorRegisterResponseDto {
|
||||
Self {
|
||||
id: schema.id.to_string(),
|
||||
user_id: schema.user_id.map(|id| extract_id(&id)).unwrap_or_default(),
|
||||
email: schema.email,
|
||||
email: None, // schema.email - now in user table
|
||||
status: schema.status,
|
||||
created_at: schema.created_at,
|
||||
updated_at: schema.updated_at,
|
||||
@@ -446,19 +416,7 @@ impl From<MentorDetailWithUserDto> for MentorDetailQueryDto {
|
||||
MentorDetailQueryDto {
|
||||
id: dto.id,
|
||||
user_id: dto.user_id,
|
||||
fullname: dto.fullname,
|
||||
email: dto.email,
|
||||
legal_name: dto.legal_name,
|
||||
gender: None, // Frontend form implies these are optional, not present in original MentorDetailWithUserDto
|
||||
domicile: None, // Frontend form implies these are optional, not present in original MentorDetailWithUserDto
|
||||
identity_document_url: dto.identity_document_url,
|
||||
phone_for_verification: dto.phone_for_verification,
|
||||
bio: dto.bio,
|
||||
last_education: None, // Frontend form implies these are optional, not present in original MentorDetailWithUserDto
|
||||
linkedin_url: dto.linkedin_url,
|
||||
github_url: dto.github_url,
|
||||
cv_url: dto.cv_url,
|
||||
portfolio_url: None, // Frontend form implies these are optional, not present in original MentorDetailWithUserDto
|
||||
// Personal data removed from MentorDetailWithUserDto - now in UsersSchema
|
||||
industries: dto.industries,
|
||||
expertise: dto.expertise,
|
||||
languages: dto.languages,
|
||||
|
||||
@@ -28,19 +28,11 @@ impl<'a> MentorsRepository<'a> {
|
||||
let db = &self.state.surrealdb_ws;
|
||||
let mentors_table = ResourceEnum::Mentors.to_string();
|
||||
let builder = QueryListBuilder::new(db, &mentors_table, &meta)
|
||||
.search_field("legal_name")
|
||||
.search_field("user_id.legal_name") // Search in user data instead
|
||||
.select_fields(vec![
|
||||
"id",
|
||||
"user_id",
|
||||
"user_id.fullname as fullname",
|
||||
"email",
|
||||
"legal_name",
|
||||
"identity_document_url",
|
||||
"phone_for_verification",
|
||||
"bio",
|
||||
"linkedin_url",
|
||||
"github_url",
|
||||
"cv_url",
|
||||
// Personal data comes from user relation, not mentor table
|
||||
"industries",
|
||||
"expertise",
|
||||
"languages",
|
||||
@@ -80,19 +72,11 @@ impl<'a> MentorsRepository<'a> {
|
||||
let now = Instant::now();
|
||||
let db = &self.state.surrealdb_ws;
|
||||
let mut builder = DetailQueryBuilder::new(ResourceEnum::Mentors.to_string())
|
||||
.with_where("email", Some(email.clone()))
|
||||
.with_where("user_id.email", Some(email.clone())) // Search in user table
|
||||
.with_select_fields(vec![
|
||||
"id",
|
||||
"user_id",
|
||||
"user_id.fullname as fullname",
|
||||
"email",
|
||||
"legal_name",
|
||||
"identity_document_url",
|
||||
"phone_for_verification",
|
||||
"bio",
|
||||
"linkedin_url",
|
||||
"github_url",
|
||||
"cv_url",
|
||||
// Personal data comes from user relation, not mentor table
|
||||
"industries",
|
||||
"expertise",
|
||||
"languages",
|
||||
@@ -143,15 +127,7 @@ impl<'a> MentorsRepository<'a> {
|
||||
.with_select_fields(vec![
|
||||
"id",
|
||||
"user_id",
|
||||
"user_id.fullname as fullname",
|
||||
"email",
|
||||
"legal_name",
|
||||
"identity_document_url",
|
||||
"phone_for_verification",
|
||||
"bio",
|
||||
"linkedin_url",
|
||||
"github_url",
|
||||
"cv_url",
|
||||
// Personal data comes from user relation, not mentor table
|
||||
"industries",
|
||||
"expertise",
|
||||
"languages",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::{
|
||||
IdentityAndVerification, MentorDetailQueryDto, MentorUpdateRequestDto,
|
||||
MentorDetailQueryDto, MentorUpdateRequestDto,
|
||||
MentoringLogistics, MentoringRate, ProfessionalProfile,
|
||||
};
|
||||
use imphnen_libs::ResourceEnum;
|
||||
@@ -12,18 +12,9 @@ pub struct MentorSchema {
|
||||
pub id: Thing,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub user_id: Option<Thing>,
|
||||
pub email: Option<String>,
|
||||
pub legal_name: String,
|
||||
pub gender: Option<String>,
|
||||
pub domicile: Option<String>,
|
||||
pub identity_document_url: String,
|
||||
pub phone_for_verification: String,
|
||||
pub bio: String,
|
||||
pub last_education: Option<String>,
|
||||
pub linkedin_url: Option<String>,
|
||||
pub github_url: Option<String>,
|
||||
pub cv_url: Option<String>,
|
||||
pub portfolio_url: Option<String>,
|
||||
// Personal data has been moved to UsersSchema - use user_id to reference
|
||||
// phone_for_verification, bio, last_education, linkedin_url, github_url,
|
||||
// cv_url, portfolio_url
|
||||
pub industries: Vec<String>,
|
||||
pub expertise: Vec<String>,
|
||||
pub languages: Vec<String>,
|
||||
@@ -52,18 +43,6 @@ impl Default for MentorSchema {
|
||||
ResourceEnum::Users.to_string().as_str(),
|
||||
&Uuid::new_v4().to_string(),
|
||||
)),
|
||||
email: None,
|
||||
legal_name: String::new(),
|
||||
gender: None,
|
||||
domicile: None,
|
||||
identity_document_url: String::new(),
|
||||
phone_for_verification: String::new(),
|
||||
bio: String::new(),
|
||||
last_education: None,
|
||||
linkedin_url: None,
|
||||
github_url: None,
|
||||
cv_url: None,
|
||||
portfolio_url: None,
|
||||
industries: Vec::new(),
|
||||
expertise: Vec::new(),
|
||||
languages: Vec::new(),
|
||||
@@ -89,11 +68,9 @@ impl Default for MentorSchema {
|
||||
|
||||
impl MentorSchema {
|
||||
pub fn create(
|
||||
identity_and_verification: IdentityAndVerification,
|
||||
professional_profile: ProfessionalProfile,
|
||||
mentoring_logistics: MentoringLogistics,
|
||||
user_id_raw: String,
|
||||
email_str: String,
|
||||
) -> Self {
|
||||
Self {
|
||||
id: make_thing(
|
||||
@@ -101,18 +78,7 @@ impl MentorSchema {
|
||||
&Uuid::new_v4().to_string(),
|
||||
),
|
||||
user_id: Some(make_thing(&ResourceEnum::Users.to_string(), &user_id_raw)),
|
||||
email: Some(email_str),
|
||||
legal_name: identity_and_verification.legal_name,
|
||||
gender: identity_and_verification.gender,
|
||||
domicile: identity_and_verification.domicile,
|
||||
identity_document_url: identity_and_verification.identity_document_url,
|
||||
phone_for_verification: identity_and_verification.phone_for_verification,
|
||||
bio: professional_profile.bio,
|
||||
last_education: professional_profile.last_education,
|
||||
linkedin_url: professional_profile.linkedin_url,
|
||||
github_url: professional_profile.github_url,
|
||||
cv_url: professional_profile.cv_url,
|
||||
portfolio_url: professional_profile.portfolio_url,
|
||||
// Personal data now stored in UsersSchema, not here
|
||||
industries: professional_profile.industries,
|
||||
expertise: professional_profile.expertise,
|
||||
languages: professional_profile.languages,
|
||||
@@ -139,18 +105,7 @@ impl MentorSchema {
|
||||
Self {
|
||||
id: dto.id,
|
||||
user_id: Some(dto.user_id),
|
||||
email: dto.email,
|
||||
legal_name: dto.legal_name,
|
||||
gender: dto.gender,
|
||||
domicile: dto.domicile,
|
||||
identity_document_url: dto.identity_document_url,
|
||||
phone_for_verification: dto.phone_for_verification,
|
||||
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,
|
||||
// Personal data now comes from UsersSchema via user_id
|
||||
industries: dto.industries,
|
||||
expertise: dto.expertise,
|
||||
languages: dto.languages,
|
||||
@@ -170,40 +125,10 @@ impl MentorSchema {
|
||||
}
|
||||
|
||||
pub fn update(mut self, dto: MentorUpdateRequestDto) -> Self {
|
||||
// Update fields only if they are Some(value), otherwise preserve current value
|
||||
if let Some(val) = dto.legal_name {
|
||||
self.legal_name = val;
|
||||
}
|
||||
if let Some(val) = dto.gender {
|
||||
self.gender = Some(val);
|
||||
}
|
||||
if let Some(val) = dto.domicile {
|
||||
self.domicile = Some(val);
|
||||
}
|
||||
if let Some(val) = dto.identity_document_url {
|
||||
self.identity_document_url = val;
|
||||
}
|
||||
if let Some(val) = dto.phone_for_verification {
|
||||
self.phone_for_verification = val;
|
||||
}
|
||||
if let Some(val) = dto.bio {
|
||||
self.bio = val;
|
||||
}
|
||||
if let Some(val) = dto.last_education {
|
||||
self.last_education = Some(val);
|
||||
}
|
||||
if let Some(val) = dto.linkedin_url {
|
||||
self.linkedin_url = Some(val);
|
||||
}
|
||||
if let Some(val) = dto.github_url {
|
||||
self.github_url = Some(val);
|
||||
}
|
||||
if let Some(val) = dto.cv_url {
|
||||
self.cv_url = Some(val);
|
||||
}
|
||||
if let Some(val) = dto.portfolio_url {
|
||||
self.portfolio_url = Some(val);
|
||||
}
|
||||
// phone_for_verification, bio, last_education, linkedin_url, github_url,
|
||||
// cv_url, portfolio_url) are now updated in UsersSchema, not here
|
||||
|
||||
// Only update professional fields that are still in MentorSchema
|
||||
if let Some(val) = dto.industries {
|
||||
self.industries = val;
|
||||
}
|
||||
|
||||
@@ -60,6 +60,18 @@ impl MentorsService {
|
||||
|
||||
user_schema.fullname = dto.fullname.clone();
|
||||
user_schema.phone_number = dto.phone_number.clone();
|
||||
// Update personal data from identity_and_verification
|
||||
user_schema.legal_name = Some(dto.identity_and_verification.legal_name.clone());
|
||||
user_schema.gender = dto.identity_and_verification.gender.clone();
|
||||
user_schema.domicile = dto.identity_and_verification.domicile.clone();
|
||||
user_schema.phone_for_verification = Some(dto.identity_and_verification.phone_for_verification.clone());
|
||||
// Update personal data from professional_profile
|
||||
user_schema.bio = Some(dto.professional_profile.bio.clone());
|
||||
user_schema.last_education = dto.professional_profile.last_education.clone();
|
||||
user_schema.linkedin_url = dto.professional_profile.linkedin_url.clone();
|
||||
user_schema.github_url = dto.professional_profile.github_url.clone();
|
||||
user_schema.cv_url = dto.professional_profile.cv_url.clone();
|
||||
user_schema.portfolio_url = dto.professional_profile.portfolio_url.clone();
|
||||
user_schema.updated_at = imphnen_utils::get_iso_date();
|
||||
|
||||
let hashed_password = match imphnen_utils::hash_password(&dto.password) {
|
||||
@@ -135,6 +147,18 @@ impl MentorsService {
|
||||
fullname: dto.fullname.clone(),
|
||||
password: hashed_password,
|
||||
phone_number: dto.phone_number.clone(),
|
||||
// Store personal data from identity_and_verification in user
|
||||
legal_name: Some(dto.identity_and_verification.legal_name.clone()),
|
||||
gender: dto.identity_and_verification.gender.clone(),
|
||||
domicile: dto.identity_and_verification.domicile.clone(),
|
||||
phone_for_verification: Some(dto.identity_and_verification.phone_for_verification.clone()),
|
||||
// Store personal data from professional_profile in user
|
||||
bio: Some(dto.professional_profile.bio.clone()),
|
||||
last_education: dto.professional_profile.last_education.clone(),
|
||||
linkedin_url: dto.professional_profile.linkedin_url.clone(),
|
||||
github_url: dto.professional_profile.github_url.clone(),
|
||||
cv_url: dto.professional_profile.cv_url.clone(),
|
||||
portfolio_url: dto.professional_profile.portfolio_url.clone(),
|
||||
created_at: imphnen_utils::get_iso_date(),
|
||||
updated_at: imphnen_utils::get_iso_date(),
|
||||
role: imphnen_utils::make_thing(
|
||||
@@ -187,11 +211,9 @@ impl MentorsService {
|
||||
}
|
||||
|
||||
let mentor_schema = MentorSchema::create(
|
||||
dto.identity_and_verification,
|
||||
dto.professional_profile,
|
||||
dto.mentoring_logistics,
|
||||
user_id.to_raw(),
|
||||
final_user_email.clone(),
|
||||
);
|
||||
|
||||
match mentor_repo.query_create_mentor(mentor_schema.clone()).await {
|
||||
@@ -233,16 +255,27 @@ impl MentorsService {
|
||||
|
||||
pub async fn get_mentor_list(state: &AppState, meta: MetaRequestDto) -> Response {
|
||||
let repo = MentorsRepository::new(state);
|
||||
let user_repo = UsersRepository::new(state);
|
||||
|
||||
match repo.query_mentor_list(meta).await {
|
||||
Ok(result) => {
|
||||
let data: Vec<MentorListResponseDto> = result
|
||||
.data
|
||||
.into_iter()
|
||||
.map(MentorDetailQueryDto::from)
|
||||
.map(MentorListResponseDto::from)
|
||||
.collect();
|
||||
let mut mentor_list_data: Vec<MentorListResponseDto> = Vec::new();
|
||||
|
||||
for mentor_with_user in result.data {
|
||||
let mentor_dto = MentorDetailQueryDto::from(mentor_with_user);
|
||||
let mut list_item = MentorListResponseDto::from(mentor_dto.clone());
|
||||
|
||||
// Get user data to populate personal fields
|
||||
if let Ok(user) = user_repo.query_user_by_id(&mentor_dto.user_id).await {
|
||||
list_item.fullname = Some(user.fullname);
|
||||
list_item.email = Some(user.email);
|
||||
}
|
||||
|
||||
mentor_list_data.push(list_item);
|
||||
}
|
||||
|
||||
success_list_response(ResponseListSuccessDto {
|
||||
data,
|
||||
data: mentor_list_data,
|
||||
meta: result.meta,
|
||||
})
|
||||
}
|
||||
@@ -251,12 +284,56 @@ impl MentorsService {
|
||||
}
|
||||
|
||||
pub async fn get_mentor_by_id(state: &AppState, id: &str) -> Response {
|
||||
let repo = MentorsRepository::new(state);
|
||||
let mentor_repo = MentorsRepository::new(state);
|
||||
let user_repo = UsersRepository::new(state);
|
||||
let thing_id = Thing::from((ResourceEnum::Mentors.to_string().as_str(), id));
|
||||
match repo.query_mentor_by_id(&thing_id, false).await {
|
||||
|
||||
match mentor_repo.query_mentor_by_id(&thing_id, false).await {
|
||||
Ok(mentor) => {
|
||||
let dto = MentorDetailResponseDto::from(MentorDetailQueryDto::from(mentor));
|
||||
success_response(ResponseSuccessDto { data: dto })
|
||||
// Get user data separately
|
||||
let user_result = user_repo.query_user_by_id(&mentor.user_id).await;
|
||||
match user_result {
|
||||
Ok(user) => {
|
||||
// Combine mentor and user data
|
||||
let dto = MentorDetailResponseDto {
|
||||
id: mentor.id.to_raw(),
|
||||
user_id: mentor.user_id.to_raw(),
|
||||
// Personal data from user
|
||||
fullname: Some(user.fullname),
|
||||
email: Some(user.email),
|
||||
legal_name: user.legal_name,
|
||||
gender: user.gender,
|
||||
domicile: user.domicile,
|
||||
phone_for_verification: user.phone_for_verification,
|
||||
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,
|
||||
// Professional data from mentor
|
||||
industries: mentor.industries,
|
||||
expertise: mentor.expertise,
|
||||
languages: mentor.languages,
|
||||
current_company: mentor.current_company,
|
||||
current_role: mentor.current_role,
|
||||
years_of_experience: mentor.years_of_experience,
|
||||
topics_of_interest: mentor.topics_of_interest,
|
||||
preferred_mentee_level: mentor.preferred_mentee_level,
|
||||
preferred_mentoring_formats: mentor.preferred_mentoring_formats,
|
||||
availability_commitment: mentor.availability_commitment,
|
||||
mentoring_rate: mentor.mentoring_rate,
|
||||
status: mentor.status,
|
||||
created_at: mentor.created_at,
|
||||
updated_at: mentor.updated_at,
|
||||
};
|
||||
success_response(ResponseSuccessDto { data: dto })
|
||||
}
|
||||
Err(_e) => {
|
||||
error!("Failed to get user data for mentor {}: {}", id, _e);
|
||||
common_response(StatusCode::INTERNAL_SERVER_ERROR, "Failed to get mentor user data")
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(_e) => common_response(StatusCode::NOT_FOUND, &_e.to_string()),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user