From 68e816f95627b94b3e3a042aaaaa6a8a4e307aa1 Mon Sep 17 00:00:00 2001 From: Maulana Sodiqin Date: Thu, 22 May 2025 15:25:24 +0700 Subject: [PATCH] fix: schema default value --- imphnen-iam/src/v1/roles/roles_repository.rs | 1 - imphnen-iam/src/v1/roles/roles_schema.rs | 2 +- imphnen-iam/src/v1/users/users_schema.rs | 22 +++++++++++++------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/imphnen-iam/src/v1/roles/roles_repository.rs b/imphnen-iam/src/v1/roles/roles_repository.rs index d7d51e8..13fce3d 100644 --- a/imphnen-iam/src/v1/roles/roles_repository.rs +++ b/imphnen-iam/src/v1/roles/roles_repository.rs @@ -28,7 +28,6 @@ impl<'a> RolesRepository<'a> { &ResourceEnum::Roles.to_string(), &meta, ) - .with_condition("is_deleted = false") .search_field("name") .build() .await?; diff --git a/imphnen-iam/src/v1/roles/roles_schema.rs b/imphnen-iam/src/v1/roles/roles_schema.rs index 16e8ec9..a408d62 100644 --- a/imphnen-iam/src/v1/roles/roles_schema.rs +++ b/imphnen-iam/src/v1/roles/roles_schema.rs @@ -46,7 +46,7 @@ impl RolesSchema { .permissions .into_iter() .map(|perm| { - make_thing(&ResourceEnum::Permissions.to_string(), &perm.id.to_raw()) + make_thing(&ResourceEnum::Permissions.to_string(), &perm.id.id.to_raw()) }) .collect(), is_deleted: dto.is_deleted, diff --git a/imphnen-iam/src/v1/users/users_schema.rs b/imphnen-iam/src/v1/users/users_schema.rs index d80f911..fa5393d 100644 --- a/imphnen-iam/src/v1/users/users_schema.rs +++ b/imphnen-iam/src/v1/users/users_schema.rs @@ -24,19 +24,25 @@ pub struct UsersSchema { impl Default for UsersSchema { fn default() -> Self { Self { - id: Thing::from(("app_users", "dummy")), - fullname: "".into(), - email: "".into(), - password: "".into(), + id: make_thing( + &ResourceEnum::Users.to_string(), + &Uuid::new_v4().to_string(), + ), + fullname: String::new(), + email: String::new(), + password: hash_password("").unwrap(), avatar: None, - phone_number: "".into(), + phone_number: String::new(), is_active: false, is_deleted: false, gender: None, birthdate: None, - role: Thing::from(("app_roles", "dummy")), - created_at: "".into(), - updated_at: "".into(), + role: make_thing( + &ResourceEnum::Roles.to_string(), + "5713cb37-dc02-4e87-8048-d7a41d352059", + ), + created_at: get_iso_date(), + updated_at: get_iso_date(), } } }