mirror of
https://github.com/danbulant/Portfolio
synced 2026-05-27 14:02:14 +00:00
feat!: letterAddress, birthSurname fields
This commit is contained in:
parent
29ce46106f
commit
79d5a29959
7 changed files with 71 additions and 41 deletions
|
|
@ -308,9 +308,11 @@ mod tests {
|
||||||
\"candidate\": {
|
\"candidate\": {
|
||||||
\"name\": \"idk\",
|
\"name\": \"idk\",
|
||||||
\"surname\": \"idk\",
|
\"surname\": \"idk\",
|
||||||
|
\"birthSurname\": \"surname\",
|
||||||
\"birthplace\": \"Praha 1\",
|
\"birthplace\": \"Praha 1\",
|
||||||
\"birthdate\": \"2015-09-18\",
|
\"birthdate\": \"2015-09-18\",
|
||||||
\"address\": \"Stefanikova jidelna\",
|
\"address\": \"Stefanikova jidelna\",
|
||||||
|
\"letterAddress\": \"Stefanikova jidelna\",
|
||||||
\"telephone\": \"000111222333\",
|
\"telephone\": \"000111222333\",
|
||||||
\"citizenship\": \"Czech Republic\",
|
\"citizenship\": \"Czech Republic\",
|
||||||
\"email\": \"magor@magor.cz\",
|
\"email\": \"magor@magor.cz\",
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,11 @@ impl Mutation {
|
||||||
|
|
||||||
candidate.name = Set(enc_candidate.name.map(|e| e.into()));
|
candidate.name = Set(enc_candidate.name.map(|e| e.into()));
|
||||||
candidate.surname = Set(enc_candidate.surname.map(|e| e.into()));
|
candidate.surname = Set(enc_candidate.surname.map(|e| e.into()));
|
||||||
|
candidate.birth_surname = Set(enc_candidate.birth_surname.map(|e| e.into()));
|
||||||
candidate.birthplace = Set(enc_candidate.birthplace.map(|e| e.into()));
|
candidate.birthplace = Set(enc_candidate.birthplace.map(|e| e.into()));
|
||||||
candidate.birthdate = Set(enc_candidate.birthdate.map(|e| e.into()));
|
candidate.birthdate = Set(enc_candidate.birthdate.map(|e| e.into()));
|
||||||
candidate.address = Set(enc_candidate.address.map(|e| e.into()));
|
candidate.address = Set(enc_candidate.address.map(|e| e.into()));
|
||||||
|
candidate.letter_address = Set(enc_candidate.letter_address.map(|e| e.into()));
|
||||||
candidate.telephone = Set(enc_candidate.telephone.map(|e| e.into()));
|
candidate.telephone = Set(enc_candidate.telephone.map(|e| e.into()));
|
||||||
candidate.citizenship = Set(enc_candidate.citizenship.map(|e| e.into()));
|
candidate.citizenship = Set(enc_candidate.citizenship.map(|e| e.into()));
|
||||||
candidate.email = Set(enc_candidate.email.map(|e| e.into()));
|
candidate.email = Set(enc_candidate.email.map(|e| e.into()));
|
||||||
|
|
|
||||||
|
|
@ -62,9 +62,11 @@ pub struct CreateCandidateResponse {
|
||||||
pub struct CandidateDetails {
|
pub struct CandidateDetails {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub surname: String,
|
pub surname: String,
|
||||||
|
pub birth_surname: String,
|
||||||
pub birthplace: String,
|
pub birthplace: String,
|
||||||
pub birthdate: NaiveDate,
|
pub birthdate: NaiveDate,
|
||||||
pub address: String,
|
pub address: String,
|
||||||
|
pub letter_address: String,
|
||||||
pub telephone: String,
|
pub telephone: String,
|
||||||
pub citizenship: String,
|
pub citizenship: String,
|
||||||
pub email: String,
|
pub email: String,
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,11 @@ pub struct EncryptedString(String);
|
||||||
pub struct EncryptedCandidateDetails {
|
pub struct EncryptedCandidateDetails {
|
||||||
pub name: Option<EncryptedString>,
|
pub name: Option<EncryptedString>,
|
||||||
pub surname: Option<EncryptedString>,
|
pub surname: Option<EncryptedString>,
|
||||||
|
pub birth_surname: Option<EncryptedString>,
|
||||||
pub birthplace: Option<EncryptedString>,
|
pub birthplace: Option<EncryptedString>,
|
||||||
pub birthdate: Option<EncryptedString>,
|
pub birthdate: Option<EncryptedString>,
|
||||||
pub address: Option<EncryptedString>,
|
pub address: Option<EncryptedString>,
|
||||||
|
pub letter_address: Option<EncryptedString>,
|
||||||
pub telephone: Option<EncryptedString>,
|
pub telephone: Option<EncryptedString>,
|
||||||
pub citizenship: Option<EncryptedString>,
|
pub citizenship: Option<EncryptedString>,
|
||||||
pub email: Option<EncryptedString>,
|
pub email: Option<EncryptedString>,
|
||||||
|
|
@ -128,9 +130,11 @@ impl EncryptedCandidateDetails {
|
||||||
let d = tokio::try_join!(
|
let d = tokio::try_join!(
|
||||||
EncryptedString::new_option(&form.name, recipients),
|
EncryptedString::new_option(&form.name, recipients),
|
||||||
EncryptedString::new_option(&form.surname, recipients),
|
EncryptedString::new_option(&form.surname, recipients),
|
||||||
|
EncryptedString::new_option(&form.birth_surname, recipients),
|
||||||
EncryptedString::new_option(&form.birthplace, recipients),
|
EncryptedString::new_option(&form.birthplace, recipients),
|
||||||
EncryptedString::new_option(&birthdate_str, recipients),
|
EncryptedString::new_option(&birthdate_str, recipients),
|
||||||
EncryptedString::new_option(&form.address, recipients),
|
EncryptedString::new_option(&form.address, recipients),
|
||||||
|
EncryptedString::new_option(&form.letter_address, recipients),
|
||||||
EncryptedString::new_option(&form.telephone, recipients),
|
EncryptedString::new_option(&form.telephone, recipients),
|
||||||
EncryptedString::new_option(&form.citizenship, recipients),
|
EncryptedString::new_option(&form.citizenship, recipients),
|
||||||
EncryptedString::new_option(&form.email, recipients),
|
EncryptedString::new_option(&form.email, recipients),
|
||||||
|
|
@ -147,19 +151,21 @@ impl EncryptedCandidateDetails {
|
||||||
EncryptedCandidateDetails {
|
EncryptedCandidateDetails {
|
||||||
name: d.0,
|
name: d.0,
|
||||||
surname: d.1,
|
surname: d.1,
|
||||||
birthplace: d.2,
|
birth_surname: d.2,
|
||||||
birthdate: d.3,
|
birthplace: d.3,
|
||||||
address: d.4,
|
birthdate: d.4,
|
||||||
telephone: d.5,
|
address: d.5,
|
||||||
citizenship: d.6,
|
letter_address: d.6,
|
||||||
email: d.7,
|
telephone: d.7,
|
||||||
sex: d.8,
|
citizenship: d.8,
|
||||||
personal_id_number: d.9,
|
email: d.9,
|
||||||
school_name: d.10,
|
sex: d.10,
|
||||||
health_insurance: d.11,
|
personal_id_number: d.11,
|
||||||
grades_json: d.12,
|
school_name: d.12,
|
||||||
first_school: d.13,
|
health_insurance: d.13,
|
||||||
second_school: d.14,
|
grades_json: d.14,
|
||||||
|
first_school: d.15,
|
||||||
|
second_school: d.16,
|
||||||
test_language: Some(form.test_language.to_owned()),
|
test_language: Some(form.test_language.to_owned()),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
@ -169,37 +175,41 @@ impl EncryptedCandidateDetails {
|
||||||
let d = tokio::try_join!(
|
let d = tokio::try_join!(
|
||||||
EncryptedString::decrypt_option(&self.name, priv_key), // 0
|
EncryptedString::decrypt_option(&self.name, priv_key), // 0
|
||||||
EncryptedString::decrypt_option(&self.surname, priv_key), // 1
|
EncryptedString::decrypt_option(&self.surname, priv_key), // 1
|
||||||
EncryptedString::decrypt_option(&self.birthplace, priv_key), // 2
|
EncryptedString::decrypt_option(&self.birth_surname, priv_key), // 2
|
||||||
EncryptedString::decrypt_option(&self.birthdate, priv_key), // 3
|
EncryptedString::decrypt_option(&self.birthplace, priv_key), // 3
|
||||||
EncryptedString::decrypt_option(&self.address, priv_key), // 4
|
EncryptedString::decrypt_option(&self.birthdate, priv_key), // 4
|
||||||
EncryptedString::decrypt_option(&self.telephone, priv_key), // 5
|
EncryptedString::decrypt_option(&self.address, priv_key), // 5
|
||||||
EncryptedString::decrypt_option(&self.citizenship, priv_key), // 6
|
EncryptedString::decrypt_option(&self.letter_address, priv_key), // 6
|
||||||
EncryptedString::decrypt_option(&self.email, priv_key), // 7
|
EncryptedString::decrypt_option(&self.telephone, priv_key), // 7
|
||||||
EncryptedString::decrypt_option(&self.sex, priv_key), // 8
|
EncryptedString::decrypt_option(&self.citizenship, priv_key), // 8
|
||||||
EncryptedString::decrypt_option(&self.personal_id_number, priv_key),// 9
|
EncryptedString::decrypt_option(&self.email, priv_key), // 9
|
||||||
EncryptedString::decrypt_option(&self.school_name, priv_key), // 10
|
EncryptedString::decrypt_option(&self.sex, priv_key), // 10
|
||||||
EncryptedString::decrypt_option(&self.health_insurance, priv_key), // 11
|
EncryptedString::decrypt_option(&self.personal_id_number, priv_key),// 11
|
||||||
EncryptedString::decrypt_option(&self.grades_json, priv_key), // 12
|
EncryptedString::decrypt_option(&self.school_name, priv_key), // 12
|
||||||
EncryptedString::decrypt_option(&self.first_school, priv_key), // 13
|
EncryptedString::decrypt_option(&self.health_insurance, priv_key), // 13
|
||||||
EncryptedString::decrypt_option(&self.second_school, priv_key), // 14
|
EncryptedString::decrypt_option(&self.grades_json, priv_key), // 14
|
||||||
|
EncryptedString::decrypt_option(&self.first_school, priv_key), // 15
|
||||||
|
EncryptedString::decrypt_option(&self.second_school, priv_key), // 16
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok(CandidateDetails {
|
Ok(CandidateDetails {
|
||||||
name: d.0.unwrap_or_default(),
|
name: d.0.unwrap_or_default(),
|
||||||
surname: d.1.unwrap_or_default(),
|
surname: d.1.unwrap_or_default(),
|
||||||
birthplace: d.2.unwrap_or_default(),
|
birth_surname: d.2.unwrap_or_default(),
|
||||||
birthdate: parse_naive_date_from_opt_str(d.3, NAIVE_DATE_FMT)?,
|
birthplace: d.3.unwrap_or_default(),
|
||||||
address: d.4.unwrap_or_default(),
|
birthdate: parse_naive_date_from_opt_str(d.4, NAIVE_DATE_FMT)?,
|
||||||
telephone: d.5.unwrap_or_default(),
|
address: d.5.unwrap_or_default(),
|
||||||
citizenship: d.6.unwrap_or_default(),
|
letter_address: d.6.unwrap_or_default(),
|
||||||
email: d.7.unwrap_or_default(),
|
telephone: d.7.unwrap_or_default(),
|
||||||
sex: d.8.unwrap_or_default(),
|
citizenship: d.8.unwrap_or_default(),
|
||||||
personal_id_number: d.9.unwrap_or_default(),
|
email: d.9.unwrap_or_default(),
|
||||||
school_name: d.10.unwrap_or_default(),
|
sex: d.10.unwrap_or_default(),
|
||||||
health_insurance: d.11.unwrap_or_default(),
|
personal_id_number: d.11.unwrap_or_default(),
|
||||||
grades: GradeList::from_opt_str(d.12).unwrap_or_default(),
|
school_name: d.12.unwrap_or_default(),
|
||||||
first_school: School::from_opt_str(d.13).unwrap_or_default(),
|
health_insurance: d.13.unwrap_or_default(),
|
||||||
second_school: School::from_opt_str(d.14).unwrap_or_default(),
|
grades: GradeList::from_opt_str(d.14).unwrap_or_default(),
|
||||||
|
first_school: School::from_opt_str(d.15).unwrap_or_default(),
|
||||||
|
second_school: School::from_opt_str(d.16).unwrap_or_default(),
|
||||||
test_language: self.test_language.to_owned().unwrap_or_default().to_string(),
|
test_language: self.test_language.to_owned().unwrap_or_default().to_string(),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
@ -214,8 +224,13 @@ impl EncryptedCandidateDetails {
|
||||||
self.telephone.is_some() &&
|
self.telephone.is_some() &&
|
||||||
self.citizenship.is_some() &&
|
self.citizenship.is_some() &&
|
||||||
self.email.is_some() &&
|
self.email.is_some() &&
|
||||||
// self.sex.is_some() &&
|
self.personal_id_number.is_some() &&
|
||||||
self.personal_id_number.is_some()
|
self.school_name.is_some() &&
|
||||||
|
self.health_insurance.is_some() &&
|
||||||
|
self.grades_json.is_some() &&
|
||||||
|
self.first_school.is_some() &&
|
||||||
|
self.second_school.is_some()
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<&candidate::Model> for EncryptedCandidateDetails {
|
impl From<&candidate::Model> for EncryptedCandidateDetails {
|
||||||
|
|
@ -225,9 +240,11 @@ impl From<&candidate::Model> for EncryptedCandidateDetails {
|
||||||
EncryptedCandidateDetails {
|
EncryptedCandidateDetails {
|
||||||
name: EncryptedString::try_from(&candidate.name).ok(),
|
name: EncryptedString::try_from(&candidate.name).ok(),
|
||||||
surname: EncryptedString::try_from(&candidate.surname).ok(),
|
surname: EncryptedString::try_from(&candidate.surname).ok(),
|
||||||
|
birth_surname: EncryptedString::try_from(&candidate.birth_surname).ok(),
|
||||||
birthplace: EncryptedString::try_from(&candidate.birthplace).ok(),
|
birthplace: EncryptedString::try_from(&candidate.birthplace).ok(),
|
||||||
birthdate: EncryptedString::try_from(&candidate.birthdate).ok(),
|
birthdate: EncryptedString::try_from(&candidate.birthdate).ok(),
|
||||||
address: EncryptedString::try_from(&candidate.address).ok(),
|
address: EncryptedString::try_from(&candidate.address).ok(),
|
||||||
|
letter_address: EncryptedString::try_from(&candidate.letter_address).ok(),
|
||||||
telephone: EncryptedString::try_from(&candidate.telephone).ok(),
|
telephone: EncryptedString::try_from(&candidate.telephone).ok(),
|
||||||
citizenship: EncryptedString::try_from(&candidate.citizenship).ok(),
|
citizenship: EncryptedString::try_from(&candidate.citizenship).ok(),
|
||||||
email: EncryptedString::try_from(&candidate.email).ok(),
|
email: EncryptedString::try_from(&candidate.email).ok(),
|
||||||
|
|
@ -377,9 +394,11 @@ pub mod tests {
|
||||||
candidate: CandidateDetails {
|
candidate: CandidateDetails {
|
||||||
name: "name".to_string(),
|
name: "name".to_string(),
|
||||||
surname: "surname".to_string(),
|
surname: "surname".to_string(),
|
||||||
|
birth_surname: "birth_surname".to_string(),
|
||||||
birthplace: "birthplace".to_string(),
|
birthplace: "birthplace".to_string(),
|
||||||
birthdate: chrono::NaiveDate::from_ymd_opt(2000, 1, 1).unwrap(),
|
birthdate: chrono::NaiveDate::from_ymd_opt(2000, 1, 1).unwrap(),
|
||||||
address: "address".to_string(),
|
address: "address".to_string(),
|
||||||
|
letter_address: "letter_address".to_string(),
|
||||||
telephone: "telephone".to_string(),
|
telephone: "telephone".to_string(),
|
||||||
citizenship: "citizenship".to_string(),
|
citizenship: "citizenship".to_string(),
|
||||||
email: "email".to_string(),
|
email: "email".to_string(),
|
||||||
|
|
|
||||||
|
|
@ -61,9 +61,11 @@ mod tests {
|
||||||
candidate: CandidateDetails {
|
candidate: CandidateDetails {
|
||||||
name: "name".to_string(),
|
name: "name".to_string(),
|
||||||
surname: "surname".to_string(),
|
surname: "surname".to_string(),
|
||||||
|
birth_surname: "birth_surname".to_string(),
|
||||||
birthplace: "birthplace".to_string(),
|
birthplace: "birthplace".to_string(),
|
||||||
birthdate: chrono::NaiveDate::from_ymd_opt(2000, 1, 1).unwrap(),
|
birthdate: chrono::NaiveDate::from_ymd_opt(2000, 1, 1).unwrap(),
|
||||||
address: "address".to_string(),
|
address: "address".to_string(),
|
||||||
|
letter_address: "letter_address".to_string(),
|
||||||
telephone: "telephone".to_string(),
|
telephone: "telephone".to_string(),
|
||||||
citizenship: "citizenship".to_string(),
|
citizenship: "citizenship".to_string(),
|
||||||
email: "email".to_string(),
|
email: "email".to_string(),
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ pub struct Model {
|
||||||
pub birthplace: Option<String>,
|
pub birthplace: Option<String>,
|
||||||
pub birthdate: Option<String>,
|
pub birthdate: Option<String>,
|
||||||
pub address: Option<String>,
|
pub address: Option<String>,
|
||||||
|
pub letter_address: Option<String>,
|
||||||
pub telephone: Option<String>,
|
pub telephone: Option<String>,
|
||||||
pub citizenship: Option<String>,
|
pub citizenship: Option<String>,
|
||||||
pub email: Option<String>,
|
pub email: Option<String>,
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ impl MigrationTrait for Migration {
|
||||||
.col(ColumnDef::new(Candidate::Birthplace).string())
|
.col(ColumnDef::new(Candidate::Birthplace).string())
|
||||||
.col(ColumnDef::new(Candidate::Birthdate).string())
|
.col(ColumnDef::new(Candidate::Birthdate).string())
|
||||||
.col(ColumnDef::new(Candidate::Address).string())
|
.col(ColumnDef::new(Candidate::Address).string())
|
||||||
|
.col(ColumnDef::new(Candidate::LetterAddress).string())
|
||||||
.col(ColumnDef::new(Candidate::Telephone).string())
|
.col(ColumnDef::new(Candidate::Telephone).string())
|
||||||
.col(ColumnDef::new(Candidate::Citizenship).string())
|
.col(ColumnDef::new(Candidate::Citizenship).string())
|
||||||
.col(ColumnDef::new(Candidate::Email).string())
|
.col(ColumnDef::new(Candidate::Email).string())
|
||||||
|
|
@ -60,6 +61,7 @@ pub enum Candidate {
|
||||||
Birthplace,
|
Birthplace,
|
||||||
Birthdate,
|
Birthdate,
|
||||||
Address,
|
Address,
|
||||||
|
LetterAddress,
|
||||||
Telephone,
|
Telephone,
|
||||||
Citizenship,
|
Citizenship,
|
||||||
Email,
|
Email,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue