From c0b4801f6dd65d2a217861b5cc79220e945644b9 Mon Sep 17 00:00:00 2001 From: ZzIsGod1019 <1498852723@qq.com> Date: Tue, 30 Jul 2024 09:18:15 +0800 Subject: [PATCH] iam: add api:build res tree (#816) Co-authored-by: ZzIsGod1019 <1498852723@11.com> --- .../middlewares/flow/src/serv/flow_model_serv.rs | 2 +- .../iam/src/console_common/api/iam_cc_res_api.rs | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/backend/middlewares/flow/src/serv/flow_model_serv.rs b/backend/middlewares/flow/src/serv/flow_model_serv.rs index 58961f5c5..f4bf39f14 100644 --- a/backend/middlewares/flow/src/serv/flow_model_serv.rs +++ b/backend/middlewares/flow/src/serv/flow_model_serv.rs @@ -1397,7 +1397,7 @@ impl FlowModelServ { // 2、template_id为单元素数组,则表示 pub async fn check_post_action_ring(model_desp: &FlowModelDetailResp, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult { let mut model_details = HashMap::new(); - if model_desp.template && model_desp.rel_model_id.is_empty() { + if model_desp.template { model_details.insert(model_desp.tag.clone(), model_desp.clone()); } else { let template_ids = if model_desp.rel_template_ids.is_empty() { diff --git a/backend/supports/iam/src/console_common/api/iam_cc_res_api.rs b/backend/supports/iam/src/console_common/api/iam_cc_res_api.rs index e45b12f61..88033596f 100644 --- a/backend/supports/iam/src/console_common/api/iam_cc_res_api.rs +++ b/backend/supports/iam/src/console_common/api/iam_cc_res_api.rs @@ -6,7 +6,7 @@ use crate::basic::serv::iam_set_serv::IamSetServ; use crate::iam_constants; use crate::iam_enumeration::IamSetKind; use bios_basic::helper::request_helper::try_set_real_ip_from_req_to_ctx; -use bios_basic::rbum::dto::rbum_set_dto::RbumSetTreeResp; +use bios_basic::rbum::dto::rbum_set_dto::{RbumSetTreeCateResp, RbumSetTreeResp}; use tardis::web::context_extractor::TardisContextExtractor; use tardis::web::poem::web::Json; use tardis::web::poem::Request; @@ -33,6 +33,18 @@ impl IamCcResApi { TardisResp::ok(result) } + /// build Menu Tree + /// 构造菜单树 + #[oai(path = "/tree/build", method = "get")] + async fn build_menu_tree(&self, ctx: TardisContextExtractor, request: &Request) -> TardisApiResult { + try_set_real_ip_from_req_to_ctx(request, &ctx.0).await?; + let funs = iam_constants::get_tardis_inst(); + let set_id = IamSetServ::get_set_id_by_code(&IamSetServ::get_default_code(&IamSetKind::Res, ""), true, &funs, &ctx.0).await?; + let result = IamSetServ::get_menu_tree_by_roles(&set_id, &ctx.0.roles, &funs, &ctx.0).await?; + ctx.0.execute_task().await?; + TardisResp::ok(result.to_trees()) + } + /// Find res by apps /// 根据应用查找资源 #[oai(path = "/res", method = "get")]