mirror of
https://github.com/danbulant/Portfolio
synced 2026-07-05 11:00:56 +00:00
feat!: school izo / name & health insurance number
This commit is contained in:
parent
a8761c9fdf
commit
377d2633c7
6 changed files with 30 additions and 4 deletions
|
|
@ -52,6 +52,8 @@ pub struct CandidateDetails {
|
||||||
pub sex: String,
|
pub sex: String,
|
||||||
pub study: String,
|
pub study: String,
|
||||||
pub personal_id_number: String,
|
pub personal_id_number: String,
|
||||||
|
pub school_name: String,
|
||||||
|
pub health_insurance: String,
|
||||||
}
|
}
|
||||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
|
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
|
|
@ -87,6 +89,8 @@ pub struct Row {
|
||||||
pub sex: Option<String>,
|
pub sex: Option<String>,
|
||||||
pub study: Option<String>,
|
pub study: Option<String>,
|
||||||
pub personal_identification_number: Option<String>,
|
pub personal_identification_number: Option<String>,
|
||||||
|
pub school_name: Option<String>,
|
||||||
|
pub health_insurance: Option<String>,
|
||||||
|
|
||||||
pub parent_name: Option<String>,
|
pub parent_name: Option<String>,
|
||||||
pub parent_surname: Option<String>,
|
pub parent_surname: Option<String>,
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ pub struct EncryptedCandidateDetails {
|
||||||
pub email: Option<EncryptedString>,
|
pub email: Option<EncryptedString>,
|
||||||
pub sex: Option<EncryptedString>,
|
pub sex: Option<EncryptedString>,
|
||||||
pub personal_id_number: Option<EncryptedString>,
|
pub personal_id_number: Option<EncryptedString>,
|
||||||
|
pub school_name: Option<EncryptedString>,
|
||||||
|
pub health_insurance: Option<EncryptedString>,
|
||||||
pub study: Option<String>,
|
pub study: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,6 +130,8 @@ impl EncryptedCandidateDetails {
|
||||||
EncryptedString::new_option(&form.email, recipients),
|
EncryptedString::new_option(&form.email, recipients),
|
||||||
EncryptedString::new_option(&form.sex, recipients),
|
EncryptedString::new_option(&form.sex, recipients),
|
||||||
EncryptedString::new_option(&form.personal_id_number, recipients),
|
EncryptedString::new_option(&form.personal_id_number, recipients),
|
||||||
|
EncryptedString::new_option(&form.school_name, recipients),
|
||||||
|
EncryptedString::new_option(&form.health_insurance, recipients),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok(
|
Ok(
|
||||||
|
|
@ -142,6 +146,8 @@ impl EncryptedCandidateDetails {
|
||||||
email: d.7,
|
email: d.7,
|
||||||
sex: d.8,
|
sex: d.8,
|
||||||
personal_id_number: d.9,
|
personal_id_number: d.9,
|
||||||
|
school_name: d.10,
|
||||||
|
health_insurance: d.11,
|
||||||
study: Some(form.study.clone()),
|
study: Some(form.study.clone()),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
@ -159,6 +165,8 @@ impl EncryptedCandidateDetails {
|
||||||
EncryptedString::decrypt_option(&self.email, priv_key), // 7
|
EncryptedString::decrypt_option(&self.email, priv_key), // 7
|
||||||
EncryptedString::decrypt_option(&self.sex, priv_key), // 8
|
EncryptedString::decrypt_option(&self.sex, priv_key), // 8
|
||||||
EncryptedString::decrypt_option(&self.personal_id_number, priv_key),// 9
|
EncryptedString::decrypt_option(&self.personal_id_number, priv_key),// 9
|
||||||
|
EncryptedString::decrypt_option(&self.school_name, priv_key), // 10
|
||||||
|
EncryptedString::decrypt_option(&self.health_insurance, priv_key), // 11
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok(CandidateDetails {
|
Ok(CandidateDetails {
|
||||||
|
|
@ -172,6 +180,8 @@ impl EncryptedCandidateDetails {
|
||||||
email: d.7.unwrap_or_default(),
|
email: d.7.unwrap_or_default(),
|
||||||
sex: d.8.unwrap_or_default(),
|
sex: d.8.unwrap_or_default(),
|
||||||
personal_id_number: d.9.unwrap_or_default(),
|
personal_id_number: d.9.unwrap_or_default(),
|
||||||
|
school_name: d.10.unwrap_or_default(),
|
||||||
|
health_insurance: d.11.unwrap_or_default(),
|
||||||
study: self.study.clone().unwrap_or_default(),
|
study: self.study.clone().unwrap_or_default(),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
@ -206,6 +216,8 @@ impl From<&candidate::Model> for EncryptedCandidateDetails {
|
||||||
email: EncryptedString::try_from(&candidate.email).ok(),
|
email: EncryptedString::try_from(&candidate.email).ok(),
|
||||||
sex: EncryptedString::try_from(&candidate.sex).ok(),
|
sex: EncryptedString::try_from(&candidate.sex).ok(),
|
||||||
personal_id_number: Some(EncryptedString::from(candidate.personal_identification_number.to_owned())),
|
personal_id_number: Some(EncryptedString::from(candidate.personal_identification_number.to_owned())),
|
||||||
|
school_name: EncryptedString::try_from(&candidate.school_name).ok(),
|
||||||
|
health_insurance: EncryptedString::try_from(&candidate.health_insurance).ok(),
|
||||||
study: candidate.study.clone(),
|
study: candidate.study.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -342,6 +354,8 @@ impl TryFrom<Row> for EncryptedApplicationDetails {
|
||||||
email: EncryptedString::try_from(&cp.email).ok(),
|
email: EncryptedString::try_from(&cp.email).ok(),
|
||||||
sex: EncryptedString::try_from(&cp.sex).ok(),
|
sex: EncryptedString::try_from(&cp.sex).ok(),
|
||||||
personal_id_number: EncryptedString::try_from(&cp.personal_identification_number).ok(),
|
personal_id_number: EncryptedString::try_from(&cp.personal_identification_number).ok(),
|
||||||
|
school_name: EncryptedString::try_from(&cp.school_name).ok(),
|
||||||
|
health_insurance: EncryptedString::try_from(&cp.health_insurance).ok(),
|
||||||
study: cp.study.ok_or(ServiceError::CandidateDetailsNotSet).ok(),
|
study: cp.study.ok_or(ServiceError::CandidateDetailsNotSet).ok(),
|
||||||
},
|
},
|
||||||
parents: vec![EncryptedParentDetails {
|
parents: vec![EncryptedParentDetails {
|
||||||
|
|
@ -394,6 +408,8 @@ pub mod tests {
|
||||||
email: "email".to_string(),
|
email: "email".to_string(),
|
||||||
sex: "sex".to_string(),
|
sex: "sex".to_string(),
|
||||||
personal_id_number: "personal_id_number".to_string(),
|
personal_id_number: "personal_id_number".to_string(),
|
||||||
|
school_name: "school_name".to_string(),
|
||||||
|
health_insurance: "health_insurance".to_string(),
|
||||||
study: "study".to_string(),
|
study: "study".to_string(),
|
||||||
},
|
},
|
||||||
parents: vec![ParentDetails {
|
parents: vec![ParentDetails {
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,8 @@ mod tests {
|
||||||
email: "email".to_string(),
|
email: "email".to_string(),
|
||||||
sex: "sex".to_string(),
|
sex: "sex".to_string(),
|
||||||
personal_id_number: "personal_id_number".to_string(),
|
personal_id_number: "personal_id_number".to_string(),
|
||||||
|
school_name: "school_name".to_string(),
|
||||||
|
health_insurance: "health_insurance".to_string(),
|
||||||
study: "study".to_string(),
|
study: "study".to_string(),
|
||||||
},
|
},
|
||||||
parents: vec![ParentDetails {
|
parents: vec![ParentDetails {
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ impl From<(i32, ApplicationDetails)> for Row {
|
||||||
email: Some(c.email),
|
email: Some(c.email),
|
||||||
sex: Some(c.sex),
|
sex: Some(c.sex),
|
||||||
study: Some(c.study),
|
study: Some(c.study),
|
||||||
|
health_insurance: Some(c.health_insurance),
|
||||||
|
school_name: Some(c.school_name),
|
||||||
personal_identification_number: Some(c.personal_id_number),
|
personal_identification_number: Some(c.personal_id_number),
|
||||||
|
|
||||||
parent_name: d.parents.get(0).map(|p| p.name.clone()),
|
parent_name: d.parents.get(0).map(|p| p.name.clone()),
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ pub struct Model {
|
||||||
pub sex: Option<String>,
|
pub sex: Option<String>,
|
||||||
pub study: Option<String>,
|
pub study: Option<String>,
|
||||||
pub personal_identification_number: String,
|
pub personal_identification_number: String,
|
||||||
#[sea_orm(column_type = "Text", nullable)]
|
pub school_name: Option<String>,
|
||||||
pub personal_identification_number_hash: Option<String>,
|
pub health_insurance: Option<String>,
|
||||||
pub public_key: String,
|
pub public_key: String,
|
||||||
pub private_key: String,
|
pub private_key: String,
|
||||||
pub created_at: DateTime,
|
pub created_at: DateTime,
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,8 @@ impl MigrationTrait for Migration {
|
||||||
.col(ColumnDef::new(Candidate::Sex).string())
|
.col(ColumnDef::new(Candidate::Sex).string())
|
||||||
.col(ColumnDef::new(Candidate::Study).string())
|
.col(ColumnDef::new(Candidate::Study).string())
|
||||||
.col(ColumnDef::new(Candidate::PersonalIdentificationNumber).string().not_null())
|
.col(ColumnDef::new(Candidate::PersonalIdentificationNumber).string().not_null())
|
||||||
.col(ColumnDef::new(Candidate::PersonalIdentificationNumberHash).text())
|
.col(ColumnDef::new(Candidate::SchoolName).string())
|
||||||
|
.col(ColumnDef::new(Candidate::HealthInsurance).string())
|
||||||
.col(ColumnDef::new(Candidate::PublicKey).string().not_null())
|
.col(ColumnDef::new(Candidate::PublicKey).string().not_null())
|
||||||
.col(ColumnDef::new(Candidate::PrivateKey).string().not_null())
|
.col(ColumnDef::new(Candidate::PrivateKey).string().not_null())
|
||||||
.col(ColumnDef::new(Candidate::CreatedAt).date_time().not_null())
|
.col(ColumnDef::new(Candidate::CreatedAt).date_time().not_null())
|
||||||
|
|
@ -65,7 +66,8 @@ pub enum Candidate {
|
||||||
Sex,
|
Sex,
|
||||||
Study,
|
Study,
|
||||||
PersonalIdentificationNumber,
|
PersonalIdentificationNumber,
|
||||||
PersonalIdentificationNumberHash,
|
SchoolName,
|
||||||
|
HealthInsurance,
|
||||||
PublicKey,
|
PublicKey,
|
||||||
PrivateKey,
|
PrivateKey,
|
||||||
CreatedAt,
|
CreatedAt,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue