From a70660dec746332bf26902f0af99e0707d9e5b57 Mon Sep 17 00:00:00 2001 From: ZzIsGod1019 <1498852723@qq.com> Date: Wed, 26 Jun 2024 10:49:41 +0800 Subject: [PATCH] iam-kv: add key-name func (#787) --- .../src/basic/serv/clients/iam_kv_client.rs | 29 +++++++++++++++++++ .../iam/src/basic/serv/iam_role_serv.rs | 5 ++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/backend/supports/iam/src/basic/serv/clients/iam_kv_client.rs b/backend/supports/iam/src/basic/serv/clients/iam_kv_client.rs index f9309d448..ecba2f44f 100644 --- a/backend/supports/iam/src/basic/serv/clients/iam_kv_client.rs +++ b/backend/supports/iam/src/basic/serv/clients/iam_kv_client.rs @@ -34,6 +34,26 @@ impl IamKvClient { .await } + pub async fn async_add_or_modify_key_name( + key: String, + name: String, + _funs: &TardisFunsInst, + ctx: &TardisContext, + ) -> TardisResult<()> { + let ctx_clone = ctx.clone(); + ctx.add_async_task(Box::new(|| { + Box::pin(async move { + let task_handle = tokio::spawn(async move { + let funs = iam_constants::get_tardis_inst(); + let _ = Self::add_or_modify_key_name(&key, &name, &funs, &ctx_clone).await; + }); + task_handle.await.unwrap(); + Ok(()) + }) + })) + .await + } + pub async fn async_delete_item(key: String, _funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<()> { let ctx_clone = ctx.clone(); ctx.add_async_task(Box::new(|| { @@ -60,6 +80,15 @@ impl IamKvClient { SpiKvClient::add_or_modify_item(key, value, info, scope_level.map(|kind| kind.to_int()), funs, ctx).await } + pub async fn add_or_modify_key_name( + key: &str, + name: &str, + funs: &TardisFunsInst, + ctx: &TardisContext, + ) -> TardisResult<()> { + SpiKvClient::add_or_modify_key_name(key, name, funs, ctx).await + } + pub async fn delete_item(key: &str, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<()> { SpiKvClient::delete_item(key, funs, ctx).await } diff --git a/backend/supports/iam/src/basic/serv/iam_role_serv.rs b/backend/supports/iam/src/basic/serv/iam_role_serv.rs index 4110f06b1..466ac4b2c 100644 --- a/backend/supports/iam/src/basic/serv/iam_role_serv.rs +++ b/backend/supports/iam/src/basic/serv/iam_role_serv.rs @@ -9,7 +9,6 @@ use tardis::db::sea_orm::prelude::Expr; use tardis::db::sea_orm::sea_query::SelectStatement; use tardis::db::sea_orm::*; use tardis::log::info; -use tardis::serde_json::json; use tardis::web::web_resp::TardisPage; use tardis::{tokio, TardisFuns, TardisFunsInst}; @@ -118,7 +117,7 @@ impl RbumItemCrudOperation