From 377d2633c70a8bfa0eb686aec87f27545c713563 Mon Sep 17 00:00:00 2001 From: Sebastian Pravda Date: Sat, 14 Jan 2023 10:48:17 +0100 Subject: [PATCH] feat!: school izo / name & health insurance number --- core/src/models/candidate.rs | 4 ++++ core/src/models/candidate_details.rs | 16 ++++++++++++++++ core/src/services/parent_service.rs | 2 ++ core/src/utils/csv.rs | 2 ++ entity/src/candidate.rs | 4 ++-- .../src/m20221024_121621_create_candidate.rs | 6 ++++-- 6 files changed, 30 insertions(+), 4 deletions(-) diff --git a/core/src/models/candidate.rs b/core/src/models/candidate.rs index ba1c049..b121094 100644 --- a/core/src/models/candidate.rs +++ b/core/src/models/candidate.rs @@ -52,6 +52,8 @@ pub struct CandidateDetails { pub sex: String, pub study: String, pub personal_id_number: String, + pub school_name: String, + pub health_insurance: String, } #[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)] #[serde(rename_all = "camelCase")] @@ -87,6 +89,8 @@ pub struct Row { pub sex: Option, pub study: Option, pub personal_identification_number: Option, + pub school_name: Option, + pub health_insurance: Option, pub parent_name: Option, pub parent_surname: Option, diff --git a/core/src/models/candidate_details.rs b/core/src/models/candidate_details.rs index eb89e45..c11ab68 100644 --- a/core/src/models/candidate_details.rs +++ b/core/src/models/candidate_details.rs @@ -24,6 +24,8 @@ pub struct EncryptedCandidateDetails { pub email: Option, pub sex: Option, pub personal_id_number: Option, + pub school_name: Option, + pub health_insurance: Option, pub study: Option, } @@ -128,6 +130,8 @@ impl EncryptedCandidateDetails { EncryptedString::new_option(&form.email, recipients), EncryptedString::new_option(&form.sex, recipients), EncryptedString::new_option(&form.personal_id_number, recipients), + EncryptedString::new_option(&form.school_name, recipients), + EncryptedString::new_option(&form.health_insurance, recipients), )?; Ok( @@ -142,6 +146,8 @@ impl EncryptedCandidateDetails { email: d.7, sex: d.8, personal_id_number: d.9, + school_name: d.10, + health_insurance: d.11, study: Some(form.study.clone()), } ) @@ -159,6 +165,8 @@ impl EncryptedCandidateDetails { EncryptedString::decrypt_option(&self.email, priv_key), // 7 EncryptedString::decrypt_option(&self.sex, priv_key), // 8 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 { @@ -172,6 +180,8 @@ impl EncryptedCandidateDetails { email: d.7.unwrap_or_default(), sex: d.8.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(), } ) @@ -206,6 +216,8 @@ impl From<&candidate::Model> for EncryptedCandidateDetails { email: EncryptedString::try_from(&candidate.email).ok(), sex: EncryptedString::try_from(&candidate.sex).ok(), 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(), } } @@ -342,6 +354,8 @@ impl TryFrom for EncryptedApplicationDetails { email: EncryptedString::try_from(&cp.email).ok(), sex: EncryptedString::try_from(&cp.sex).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(), }, parents: vec![EncryptedParentDetails { @@ -394,6 +408,8 @@ pub mod tests { email: "email".to_string(), sex: "sex".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(), }, parents: vec![ParentDetails { diff --git a/core/src/services/parent_service.rs b/core/src/services/parent_service.rs index be2b2f5..2ee3e9b 100644 --- a/core/src/services/parent_service.rs +++ b/core/src/services/parent_service.rs @@ -71,6 +71,8 @@ mod tests { email: "email".to_string(), sex: "sex".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(), }, parents: vec![ParentDetails { diff --git a/core/src/utils/csv.rs b/core/src/utils/csv.rs index 216ade4..6d6cef9 100644 --- a/core/src/utils/csv.rs +++ b/core/src/utils/csv.rs @@ -16,6 +16,8 @@ impl From<(i32, ApplicationDetails)> for Row { email: Some(c.email), sex: Some(c.sex), study: Some(c.study), + health_insurance: Some(c.health_insurance), + school_name: Some(c.school_name), personal_identification_number: Some(c.personal_id_number), parent_name: d.parents.get(0).map(|p| p.name.clone()), diff --git a/entity/src/candidate.rs b/entity/src/candidate.rs index fdfbc46..5960976 100644 --- a/entity/src/candidate.rs +++ b/entity/src/candidate.rs @@ -20,8 +20,8 @@ pub struct Model { pub sex: Option, pub study: Option, pub personal_identification_number: String, - #[sea_orm(column_type = "Text", nullable)] - pub personal_identification_number_hash: Option, + pub school_name: Option, + pub health_insurance: Option, pub public_key: String, pub private_key: String, pub created_at: DateTime, diff --git a/migration/src/m20221024_121621_create_candidate.rs b/migration/src/m20221024_121621_create_candidate.rs index 89e0522..5ee04bf 100644 --- a/migration/src/m20221024_121621_create_candidate.rs +++ b/migration/src/m20221024_121621_create_candidate.rs @@ -31,7 +31,8 @@ impl MigrationTrait for Migration { .col(ColumnDef::new(Candidate::Sex).string()) .col(ColumnDef::new(Candidate::Study).string()) .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::PrivateKey).string().not_null()) .col(ColumnDef::new(Candidate::CreatedAt).date_time().not_null()) @@ -65,7 +66,8 @@ pub enum Candidate { Sex, Study, PersonalIdentificationNumber, - PersonalIdentificationNumberHash, + SchoolName, + HealthInsurance, PublicKey, PrivateKey, CreatedAt,