use chrono::{DateTime, Utc};
use uuid::Uuid;
use crate::domain::entity::PasswordChangeAction;
use crate::infrastructure::schema::password_changes;
#[derive(Queryable, Insertable)]
#[table_name = "password_changes"]
pub struct PasswordChangeDiesel {
user_id: String,
date_time: DateTime<Utc>,
last_password: String,
}
impl Into<PasswordChangeAction> for PasswordChangeDiesel {
fn into(self) -> PasswordChangeAction {
PasswordChangeAction {
user_id: Uuid::parse_str(&*self.user_id).unwrap(),
date_time: self.date_time,
last_password: self.last_password
}
}
}
impl From<PasswordChangeAction> for PasswordChangeDiesel {
fn from(action: PasswordChangeAction) -> Self {
Self {
user_id: action.user_id.to_string(),
date_time: action.date_time,
last_password: action.last_password,
}
}
}