From f68b1d8a16f0d592d6a8a8eaf7c1bd3d003a21c6 Mon Sep 17 00:00:00 2001 From: ZzIsGod1019 <1498852723@qq.com> Date: Mon, 26 Aug 2024 19:13:31 +0800 Subject: [PATCH] iam: find accounts support filter app_ids (#834) * iam: find accounts support filter app_ids * iam:fix bug (move rbum set cate ) --------- Co-authored-by: ZzIsGod1019 <1498852723@11.com> --- backend/basic/src/rbum/serv/rbum_set_serv.rs | 41 ++++++------------- .../api/iam_ci_account_api.rs | 12 ++++++ 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/backend/basic/src/rbum/serv/rbum_set_serv.rs b/backend/basic/src/rbum/serv/rbum_set_serv.rs index a81f38e6..25e1fca5 100644 --- a/backend/basic/src/rbum/serv/rbum_set_serv.rs +++ b/backend/basic/src/rbum/serv/rbum_set_serv.rs @@ -851,7 +851,18 @@ impl RbumSetCateServ { ctx, ) .await?; - + let set_item_ids = RbumSetItemServ::find_id_rbums( + &RbumSetItemFilterReq { + sys_code_query_kind: Some(RbumSetCateLevelQueryKind::Current), + rel_rbum_set_cate_sys_codes: Some(vec![set_cate_detail.sys_code.clone()]), + ..Default::default() + }, + None, + None, + funs, + ctx, + ) + .await?; let result = Self::modify_rbum( set_cate_id, &mut RbumSetCateModifyReq { @@ -867,37 +878,11 @@ impl RbumSetCateServ { ctx, ) .await; - let new_sys_code = Self::get_rbum( - set_cate_id, - &RbumSetCateFilterReq { - basic: RbumBasicFilterReq { - with_sub_own_paths: true, - ..Default::default() - }, - ..Default::default() - }, - funs, - ctx, - ) - .await? - .sys_code; - let set_item_ids = RbumSetItemServ::find_id_rbums( - &RbumSetItemFilterReq { - sys_code_query_kind: Some(RbumSetCateLevelQueryKind::Current), - rel_rbum_set_cate_sys_codes: Some(vec![]), - ..Default::default() - }, - None, - None, - funs, - ctx, - ) - .await?; for set_item_id in set_item_ids { RbumSetItemServ::modify_rbum( &set_item_id, &mut RbumSetItemModifyReq { - rel_rbum_set_cate_id: Some(new_sys_code.clone()), + rel_rbum_set_cate_id: Some(set_cate_id.to_string()), sort: None, }, funs, diff --git a/backend/supports/iam/src/console_interface/api/iam_ci_account_api.rs b/backend/supports/iam/src/console_interface/api/iam_ci_account_api.rs index 337a3769..2fbfa2fe 100644 --- a/backend/supports/iam/src/console_interface/api/iam_ci_account_api.rs +++ b/backend/supports/iam/src/console_interface/api/iam_ci_account_api.rs @@ -42,6 +42,7 @@ impl IamCiAccountApi { ids: Query>, name: Query>, role_ids: Query>, + app_ids: Query>, cate_ids: Query>, status: Query>, tenant_id: Query>, @@ -67,6 +68,16 @@ impl IamCiAccountApi { ..Default::default() } }); + let rel2 = app_ids.0.map(|app_ids| { + let app_ids = app_ids.split(',').map(|r| r.to_string()).collect::>(); + RbumItemRelFilterReq { + rel_by_from: true, + tag: Some(IamRelKind::IamAccountApp.to_string()), + from_rbum_kind: Some(RbumRelFromKind::Item), + rel_item_ids: Some(app_ids), + ..Default::default() + } + }); let set_rel = if let Some(cate_ids) = cate_ids.0 { let cate_ids = cate_ids.split(',').map(|r| r.to_string()).collect::>(); let set_cate_vec = IamSetServ::find_set_cate( @@ -108,6 +119,7 @@ impl IamCiAccountApi { ..Default::default() }, rel, + rel2, set_rel, ..Default::default() },