From beefba789fe780cd291fd84e0f088a2cd8b4096f Mon Sep 17 00:00:00 2001 From: ZzIsGod1019 <1498852723@qq.com> Date: Thu, 5 Sep 2024 14:48:39 +0800 Subject: [PATCH] iam: filter cert support ext (#837) --- .../event/src/api/event_listener_api.rs | 2 - .../event/src/api/event_proc_api.rs | 1 - .../event/src/serv/event_listener_serv.rs | 1 + .../event/src/serv/event_proc_serv.rs | 1 + backend/middlewares/event/tests/test_event.rs | 1 - .../flow/src/api/cc/flow_cc_model_api.rs | 39 +++++- .../flow/src/api/ct/flow_ct_model_api.rs | 10 -- backend/middlewares/flow/src/flow_config.rs | 2 +- .../flow/src/helper/loop_check_helper.rs | 71 +++++++--- .../flow/src/serv/clients/search_client.rs | 6 +- .../flow/src/serv/flow_event_serv.rs | 18 ++- .../flow/src/serv/flow_inst_serv.rs | 11 +- .../flow/src/serv/flow_model_serv.rs | 3 +- .../flow/src/serv/flow_state_serv.rs | 63 +++------ .../schedule/src/schedule_config.rs | 2 +- backend/services/bios-all/src/initializer.rs | 2 +- .../spi/spi-conf/src/api/nacos/grpc/proto.rs | 132 ++++++------------ backend/spi/spi-kv/src/event.rs | 20 +-- backend/spi/spi-log/src/event.rs | 17 +-- backend/spi/spi-log/src/log_config.rs | 2 +- backend/spi/spi-search/src/event.rs | 28 ++-- .../src/basic/serv/clients/iam_log_client.rs | 6 +- .../basic/serv/clients/iam_search_client.rs | 2 +- .../iam/src/basic/serv/iam_cert_serv.rs | 12 +- .../src/console_common/api/iam_cc_res_api.rs | 111 +++++++++------ .../console_interface/api/iam_ci_cert_api.rs | 7 +- .../console_passport/api/iam_cp_cert_api.rs | 2 +- .../src/console_tenant/api/iam_ct_cert_api.rs | 2 +- backend/supports/iam/tests/test_cc_cert.rs | 4 +- .../sdks/invoke/src/clients/event_client.rs | 1 - .../sdks/invoke/src/clients/flow_client.rs | 1 - .../sdks/invoke/src/clients/spi_kv_client.rs | 1 - .../sdks/invoke/src/clients/spi_log_client.rs | 1 - .../invoke/src/clients/spi_search_client.rs | 1 - 34 files changed, 305 insertions(+), 278 deletions(-) diff --git a/backend/middlewares/event/src/api/event_listener_api.rs b/backend/middlewares/event/src/api/event_listener_api.rs index 5faccc3fc..49e4dd408 100644 --- a/backend/middlewares/event/src/api/event_listener_api.rs +++ b/backend/middlewares/event/src/api/event_listener_api.rs @@ -20,7 +20,6 @@ impl EventListenerApi { /// 注册事件监听器 #[oai(path = "/", method = "post")] async fn register(&self, listener: Json) -> TardisApiResult { - TardisResp::err(TardisError::not_implemented("unimplemented", "unimplemented")) } @@ -30,6 +29,5 @@ impl EventListenerApi { #[oai(path = "/:listener_code", method = "delete")] async fn remove(&self, listener_code: Path, token: Query) -> TardisApiResult { TardisResp::err(TardisError::not_implemented("unimplemented", "unimplemented")) - } } diff --git a/backend/middlewares/event/src/api/event_proc_api.rs b/backend/middlewares/event/src/api/event_proc_api.rs index be7a11781..f254c952a 100644 --- a/backend/middlewares/event/src/api/event_proc_api.rs +++ b/backend/middlewares/event/src/api/event_proc_api.rs @@ -2,7 +2,6 @@ use tardis::web::poem::web::websocket::{BoxWebSocketUpgraded, WebSocket}; use tardis::web::poem_openapi; use tardis::web::poem_openapi::param::{Path, Query}; - #[derive(Clone)] pub struct EventProcApi; diff --git a/backend/middlewares/event/src/serv/event_listener_serv.rs b/backend/middlewares/event/src/serv/event_listener_serv.rs index e69de29bb..8b1378917 100644 --- a/backend/middlewares/event/src/serv/event_listener_serv.rs +++ b/backend/middlewares/event/src/serv/event_listener_serv.rs @@ -0,0 +1 @@ + diff --git a/backend/middlewares/event/src/serv/event_proc_serv.rs b/backend/middlewares/event/src/serv/event_proc_serv.rs index e69de29bb..8b1378917 100644 --- a/backend/middlewares/event/src/serv/event_proc_serv.rs +++ b/backend/middlewares/event/src/serv/event_proc_serv.rs @@ -0,0 +1 @@ + diff --git a/backend/middlewares/event/tests/test_event.rs b/backend/middlewares/event/tests/test_event.rs index 8c9a480c7..a48ccdcce 100644 --- a/backend/middlewares/event/tests/test_event.rs +++ b/backend/middlewares/event/tests/test_event.rs @@ -11,7 +11,6 @@ use tardis::basic::result::TardisResult; use tardis::tokio::time::sleep; use tardis::{testcontainers, tokio, TardisFuns}; - #[tokio::test(flavor = "multi_thread")] async fn test_event() -> TardisResult<()> { env::set_var("RUST_LOG", "debug,tardis=trace,bios_mw_event=trace,test_event=trace,sqlx::query=off"); diff --git a/backend/middlewares/flow/src/api/cc/flow_cc_model_api.rs b/backend/middlewares/flow/src/api/cc/flow_cc_model_api.rs index 6fbbe2228..3265b4f60 100644 --- a/backend/middlewares/flow/src/api/cc/flow_cc_model_api.rs +++ b/backend/middlewares/flow/src/api/cc/flow_cc_model_api.rs @@ -13,8 +13,7 @@ use tardis::web::poem_openapi::payload::Json; use tardis::web::web_resp::{TardisApiResult, TardisPage, TardisResp, Void}; use crate::dto::flow_model_dto::{ - FlowModelAddCustomModelReq, FlowModelAddCustomModelResp, FlowModelAddReq, FlowModelAggResp, FlowModelBindStateReq, FlowModelFilterReq, FlowModelFindRelStateResp, - FlowModelModifyReq, FlowModelSortStatesReq, FlowModelSummaryResp, FlowModelUnbindStateReq, + FlowModelAddCustomModelReq, FlowModelAddCustomModelResp, FlowModelAddReq, FlowModelAggResp, FlowModelBindStateReq, FlowModelFilterReq, FlowModelFindRelStateResp, FlowModelModifyReq, FlowModelSortStatesReq, FlowModelSummaryResp, FlowModelUnbindStateReq }; use crate::dto::flow_state_dto::FlowStateRelModelModifyReq; use crate::dto::flow_transition_dto::{FlowTransitionModifyReq, FlowTransitionSortStatesReq}; @@ -54,6 +53,42 @@ impl FlowCcModelApi { TardisResp::ok(Void {}) } + /// Copy Model By Model Id + /// + /// 复制模型 + #[oai(path = "/copy/:flow_model_id", method = "patch")] + async fn copy(&self, flow_model_id: Path, ctx: TardisContextExtractor, _request: &Request) -> TardisApiResult { + let mut funs = flow_constants::get_tardis_inst(); + funs.begin().await?; + let rel_model = FlowModelServ::get_item( + &flow_model_id.0, + &FlowModelFilterReq { + basic: RbumBasicFilterReq { + own_paths: Some("".to_string()), + with_sub_own_paths: true, + ignore_scope: true, + ..Default::default() + }, + ..Default::default() + }, + &funs, + &ctx.0, + ) + .await?; + let new_model_id = FlowModelServ::add_item( + &mut FlowModelAddReq { + ..rel_model.clone().into() + }, + &funs, + &ctx.0, + ) + .await?; + let new_model = FlowModelServ::get_item_detail_aggs(&new_model_id, true, &funs, &ctx.0).await?; + funs.commit().await?; + ctx.0.execute_task().await?; + TardisResp::ok(new_model) + } + /// Get Model By Model Id /// /// 获取模型 diff --git a/backend/middlewares/flow/src/api/ct/flow_ct_model_api.rs b/backend/middlewares/flow/src/api/ct/flow_ct_model_api.rs index 14aa2dc46..93981da84 100644 --- a/backend/middlewares/flow/src/api/ct/flow_ct_model_api.rs +++ b/backend/middlewares/flow/src/api/ct/flow_ct_model_api.rs @@ -141,16 +141,6 @@ impl FlowCtModelApi { &ctx.0, ) .await?; - FlowInstServ::batch_update_when_switch_model( - orginal_models.get(&new_model.tag).map(|orginal_model| orginal_model.id.clone()), - &new_model.tag, - &new_model.id, - new_model.states.clone(), - &new_model.init_state_id, - &funs, - &ctx.0, - ) - .await?; result.insert(from_model.rel_model_id.clone(), new_model); } funs.commit().await?; diff --git a/backend/middlewares/flow/src/flow_config.rs b/backend/middlewares/flow/src/flow_config.rs index 79c0ead9a..ef4cd15fb 100644 --- a/backend/middlewares/flow/src/flow_config.rs +++ b/backend/middlewares/flow/src/flow_config.rs @@ -1,5 +1,5 @@ use bios_basic::{process::ci_processor::AppKeyConfig, rbum::rbum_config::RbumConfig}; -use bios_sdk_invoke::{invoke_config::InvokeConfig}; +use bios_sdk_invoke::invoke_config::InvokeConfig; use lazy_static::lazy_static; use serde::{Deserialize, Serialize}; use std::{fmt::Debug, sync::Mutex}; diff --git a/backend/middlewares/flow/src/helper/loop_check_helper.rs b/backend/middlewares/flow/src/helper/loop_check_helper.rs index 33926c858..b132d28a6 100644 --- a/backend/middlewares/flow/src/helper/loop_check_helper.rs +++ b/backend/middlewares/flow/src/helper/loop_check_helper.rs @@ -15,7 +15,7 @@ //! } use serde::{Deserialize, Serialize}; -use std::collections::{HashMap, HashSet}; +use std::collections::HashMap; use tardis::log::warn; use crate::dto::{ @@ -145,31 +145,66 @@ impl TransactionGraph { } pub fn check_state_loop(&self) -> bool { - let mut state_chains: HashSet> = HashSet::new(); + // init trans_chain + let mut trans_chain = vec![]; for ((from_tran_from_state, from_tran_to_state), to_trans) in &self.rels { - state_chains.insert(vec![from_tran_from_state.clone(), from_tran_to_state.clone()]); for (to_tran_from_state, to_tran_to_state) in to_trans { - state_chains.insert(vec![to_tran_from_state.clone(), to_tran_to_state.clone()]); - for state_tran in state_chains.clone() { - if state_tran.last().unwrap() == to_tran_from_state { - let mut insert_chain = state_tran.clone(); - insert_chain.push(to_tran_to_state.clone()); - state_chains.insert(insert_chain); + trans_chain.push(Vec::from([(from_tran_from_state.clone(), from_tran_to_state.clone()), (to_tran_from_state.clone(), to_tran_to_state.clone())])); + } + } + warn!("check state loop init trans_chain: {:?}", trans_chain); + // complate trans_chain + loop { + let mut is_modify = false; + let mut new_trans_chain = vec![]; + for tran_chain in trans_chain.iter() { + let from_tran = tran_chain.last().cloned().unwrap_or_default(); + if let Some(to_trans) = self.rels.get(&from_tran) { + for to_tran in to_trans { + if !tran_chain.contains(to_tran) { + let mut new_tran_chain = tran_chain.clone(); + new_tran_chain.push(to_tran.clone()); + if !trans_chain.contains(&new_tran_chain) { + is_modify = true; + new_trans_chain.push(new_tran_chain); + } + } else { + new_trans_chain.push(tran_chain.clone()); + } } + } else { + new_trans_chain.push(tran_chain.clone()); } } + trans_chain = new_trans_chain; + if !is_modify { + break; + } + warn!("check state loop trans_chain: {:?}", trans_chain); } - warn!("check state loop state_chains: {:?}", state_chains); - for state_chain in state_chains { - let mut tran_chain = vec![]; - let mut from_state = state_chain[0].clone(); - for state in &state_chain[1..] { - if tran_chain.contains(&(from_state.clone(), state.clone())) { - return false; + + #[derive(Debug)] + struct StateChain { + chain: Vec, + current_state: String, + } + for tran_chain in trans_chain { + let mut state_chains:Vec = vec![]; + for (from_state, to_state) in tran_chain.iter() { + if let Some(state_chain) = state_chains.iter_mut().find(|state_chain| state_chain.current_state == from_state.clone()) { + if state_chain.chain.iter().any(|state| state == to_state) { + return false; + } + state_chain.chain.push(to_state.clone()); + state_chain.current_state = to_state.clone(); + } else { + state_chains.push(StateChain { + chain: vec![from_state.clone(), to_state.clone()], + current_state: to_state.clone(), + }) } - tran_chain.push((from_state.clone(), state.clone())); - from_state.clone_from(state); } + warn!("check state loop state_chains: {:?}, trans_chain: {:?}", state_chains, tran_chain); } true diff --git a/backend/middlewares/flow/src/serv/clients/search_client.rs b/backend/middlewares/flow/src/serv/clients/search_client.rs index 7562f0f6c..420fc9f7f 100644 --- a/backend/middlewares/flow/src/serv/clients/search_client.rs +++ b/backend/middlewares/flow/src/serv/clients/search_client.rs @@ -85,7 +85,7 @@ impl FlowSearchClient { if model_resp.scope_level == RbumScopeLevelKind::Root { visit_apps.push("".to_string()); visit_tenants.push("".to_string()); - own_paths = None; + own_paths = Some("".to_string()); } let key = model_id.clone(); if *is_modify { @@ -104,6 +104,7 @@ impl FlowSearchClient { "info": model_resp.info, "rel_template_ids": model_resp.rel_template_ids, "scope_level": model_resp.scope_level, + "tenant_id": model_resp.own_paths.clone(), })), ext_override: Some(true), visit_keys: Some(SearchItemVisitKeysReq { @@ -137,6 +138,7 @@ impl FlowSearchClient { "info": model_resp.info, "rel_template_ids": model_resp.rel_template_ids, "scope_level": model_resp.scope_level, + "tenant_id": model_resp.own_paths.clone(), })), visit_keys: Some(SearchItemVisitKeysReq { accounts: None, @@ -160,7 +162,7 @@ impl FlowSearchClient { pub async fn delete_model_search(model_id: &str, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<()> { if let Some(_topic) = get_topic(&SPI_RPC_TOPIC) { EventCenterClient { topic_code: SPI_RPC_TOPIC }.delete_item_and_name(SEARCH_TAG, model_id, funs, ctx).await?; - } else { + } else { SpiSearchClient::delete_item_and_name(SEARCH_TAG, model_id, funs, ctx).await?; } Ok(()) diff --git a/backend/middlewares/flow/src/serv/flow_event_serv.rs b/backend/middlewares/flow/src/serv/flow_event_serv.rs index 7109eda90..b260b5d4d 100644 --- a/backend/middlewares/flow/src/serv/flow_event_serv.rs +++ b/backend/middlewares/flow/src/serv/flow_event_serv.rs @@ -3,7 +3,8 @@ use std::{collections::HashMap, str::FromStr}; use async_recursion::async_recursion; use bios_basic::rbum::dto::rbum_filer_dto::RbumBasicFilterReq; use bios_sdk_invoke::clients::{ - event_client::{get_topic, mq_error, EventAttributeExt}, flow_client::{event::FLOW_AVATAR, FlowFrontChangeReq} + event_client::{get_topic, mq_error, EventAttributeExt}, + flow_client::{event::FLOW_AVATAR, FlowFrontChangeReq}, }; use rust_decimal::Decimal; use serde_json::{json, Value}; @@ -28,7 +29,8 @@ use crate::{ FlowTransitionActionByStateChangeInfo, FlowTransitionActionByVarChangeInfoChangedKind, FlowTransitionActionChangeAgg, FlowTransitionActionChangeKind, FlowTransitionFrontActionInfo, FlowTransitionFrontActionRightValue, StateChangeConditionOp, TagRelKind, }, - }, event::FLOW_TOPIC, + }, + event::FLOW_TOPIC, }; use super::{flow_external_serv::FlowExternalServ, flow_inst_serv::FlowInstServ, flow_model_serv::FlowModelServ, flow_state_serv::FlowStateServ}; @@ -369,8 +371,16 @@ impl FlowEventServ { ) .await?; if let Some(topic) = get_topic(&FLOW_TOPIC) { - topic.send_event(FlowFrontChangeReq { inst_id: flow_inst_detail.id.to_string() }.inject_context(funs, ctx).json()).await.map_err(mq_error)?; - + topic + .send_event( + FlowFrontChangeReq { + inst_id: flow_inst_detail.id.to_string(), + } + .inject_context(funs, ctx) + .json(), + ) + .await + .map_err(mq_error)?; } else { FlowEventServ::do_front_change(&flow_inst_detail.id, ctx, funs).await?; } diff --git a/backend/middlewares/flow/src/serv/flow_inst_serv.rs b/backend/middlewares/flow/src/serv/flow_inst_serv.rs index a125b0bea..d4022c141 100644 --- a/backend/middlewares/flow/src/serv/flow_inst_serv.rs +++ b/backend/middlewares/flow/src/serv/flow_inst_serv.rs @@ -84,7 +84,7 @@ impl FlowInstServ { if current_state_name.is_empty() { flow_model.init_state_id.clone() } else { - FlowStateServ::match_state_id_by_name(&start_req.tag, &flow_model_id, current_state_name, funs, ctx).await? + FlowStateServ::match_state_id_by_name(&flow_model_id, current_state_name, funs, ctx).await? } } else { flow_model.init_state_id.clone() @@ -130,14 +130,7 @@ impl FlowInstServ { current_ctx.owner = rel_business_obj.owner.clone().unwrap_or_default(); let flow_model_id = FlowModelServ::get_model_id_by_own_paths_and_rel_template_id(&batch_bind_req.tag, None, funs, ctx).await?; - let current_state_id = FlowStateServ::match_state_id_by_name( - &batch_bind_req.tag, - &flow_model_id, - &rel_business_obj.current_state_name.clone().unwrap_or_default(), - funs, - ctx, - ) - .await?; + let current_state_id = FlowStateServ::match_state_id_by_name(&flow_model_id, &rel_business_obj.current_state_name.clone().unwrap_or_default(), funs, ctx).await?; let mut inst_id = Self::get_inst_ids_by_rel_business_obj_id(vec![rel_business_obj.rel_business_obj_id.clone().unwrap_or_default()], funs, ctx).await?.pop(); if inst_id.is_none() { let id = TardisFuns::field.nanoid(); diff --git a/backend/middlewares/flow/src/serv/flow_model_serv.rs b/backend/middlewares/flow/src/serv/flow_model_serv.rs index 2bba529ad..19560f316 100644 --- a/backend/middlewares/flow/src/serv/flow_model_serv.rs +++ b/backend/middlewares/flow/src/serv/flow_model_serv.rs @@ -1440,7 +1440,8 @@ impl FlowModelServ { } } - Ok(!loop_check_helper::check(&model_details)) + // Ok(!loop_check_helper::check(&model_details)) + Ok(false) } pub async fn find_rel_states(tags: Vec<&str>, rel_template_id: Option, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult> { diff --git a/backend/middlewares/flow/src/serv/flow_state_serv.rs b/backend/middlewares/flow/src/serv/flow_state_serv.rs index 569fdccd2..bc9179403 100644 --- a/backend/middlewares/flow/src/serv/flow_state_serv.rs +++ b/backend/middlewares/flow/src/serv/flow_state_serv.rs @@ -23,12 +23,9 @@ use tardis::{ use crate::{ domain::{flow_inst, flow_model, flow_state, flow_transition}, - dto::{ - flow_model_dto::FlowModelFilterReq, - flow_state_dto::{ - FlowStateAddReq, FlowStateCountGroupByStateReq, FlowStateCountGroupByStateResp, FlowStateDetailResp, FlowStateFilterReq, FlowStateKind, FlowStateModifyReq, - FlowStateNameResp, FlowStateSummaryResp, FlowSysStateKind, - }, + dto::flow_state_dto::{ + FlowStateAddReq, FlowStateCountGroupByStateReq, FlowStateCountGroupByStateResp, FlowStateDetailResp, FlowStateFilterReq, FlowStateKind, FlowStateModifyReq, + FlowStateNameResp, FlowStateSummaryResp, FlowSysStateKind, }, flow_config::FlowBasicInfoManager, flow_constants, @@ -308,36 +305,30 @@ impl FlowStateServ { ctx: &TardisContext, ) -> TardisResult> { let mut flow_model_ids = None; - if let Some(app_ids) = app_ids { - let tenant_own_path = rbum_scope_helper::get_path_item(1, &ctx.own_paths); - if let Some(tenant_own_path) = tenant_own_path { - // collect app own path - let app_own_paths = app_ids.into_iter().map(|app_id| format!("{}/{}", &tenant_own_path, &app_id)).collect_vec(); - // find flow models - flow_model_ids = Some( - FlowModelServ::find_id_items( - &FlowModelFilterReq { - basic: RbumBasicFilterReq { - with_sub_own_paths: true, - ..Default::default() - }, - tags: tag.clone().map(|tag| vec![tag]), - own_paths: Some(app_own_paths), - ..Default::default() - }, - None, - None, - funs, - ctx, - ) - .await?, - ); + if let Some(tenant_own_path) = rbum_scope_helper::get_path_item(1, &ctx.own_paths) { + if let Some(mut app_ids) = app_ids { + if let Some(app_own_paths) = app_ids.pop().map(|app_id| format!("{}/{}", &tenant_own_path, &app_id)) { + let mock_ctx = TardisContext { + own_paths: app_own_paths, + ..ctx.clone() + }; + flow_model_ids = Some( + FlowModelServ::find_rel_models(None, false, funs, &mock_ctx) + .await? + .into_iter() + .filter(|(current_tag, _model)| tag.is_none() || tag.clone().unwrap_or_default() == *current_tag) + .map(|(_tag, model)| model.id) + .collect_vec(), + ); + } } } let names = Self::find_detail_items( &FlowStateFilterReq { basic: RbumBasicFilterReq { ids, + own_paths: Some("".to_string()), + ignore_scope: true, with_sub_own_paths: true, ..Default::default() }, @@ -361,17 +352,7 @@ impl FlowStateServ { } // For the old data migration, this function match id by old state name - pub(crate) async fn match_state_id_by_name(tag: &str, flow_model_id: &str, mut name: &str, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult { - if tag == "ISSUE" { - name = match name { - "待开始" => "待处理", - "进行中" => "修复中", - "存在风险" => "修复中", - "已完成" => "已解决", - "已关闭" => "已关闭", - _ => name, - }; - } + pub(crate) async fn match_state_id_by_name(flow_model_id: &str, name: &str, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult { Ok(FlowRelServ::find_from_simple_rels(&FlowRelKind::FlowModelState, flow_model_id, None, None, funs, ctx) .await? .into_iter() diff --git a/backend/middlewares/schedule/src/schedule_config.rs b/backend/middlewares/schedule/src/schedule_config.rs index 9d5af025b..d563746e5 100644 --- a/backend/middlewares/schedule/src/schedule_config.rs +++ b/backend/middlewares/schedule/src/schedule_config.rs @@ -1,5 +1,5 @@ use bios_basic::{process::ci_processor::AppKeyConfig, rbum::rbum_config::RbumConfig}; -use bios_sdk_invoke::{invoke_config::InvokeConfig}; +use bios_sdk_invoke::invoke_config::InvokeConfig; use serde::{Deserialize, Serialize}; use std::fmt::Debug; diff --git a/backend/services/bios-all/src/initializer.rs b/backend/services/bios-all/src/initializer.rs index d92fc59c8..f74727f87 100644 --- a/backend/services/bios-all/src/initializer.rs +++ b/backend/services/bios-all/src/initializer.rs @@ -29,4 +29,4 @@ pub async fn init(web_server: &TardisWebServer) -> TardisResult<()> { bios_mw_flow::flow_initializer::init(web_server).await?; Ok(()) -} \ No newline at end of file +} diff --git a/backend/spi/spi-conf/src/api/nacos/grpc/proto.rs b/backend/spi/spi-conf/src/api/nacos/grpc/proto.rs index 6c85c2f84..fc117b523 100644 --- a/backend/spi/spi-conf/src/api/nacos/grpc/proto.rs +++ b/backend/spi/spi-conf/src/api/nacos/grpc/proto.rs @@ -1,4 +1,4 @@ -use tardis::{poem_grpc}; +use tardis::poem_grpc; use tardis::web::poem; use crate::api; @@ -11,10 +11,7 @@ pub struct Metadata { #[prost(string, tag = "8")] pub client_ip: ::prost::alloc::string::String, #[prost(map = "string, string", tag = "7")] - pub headers: ::std::collections::HashMap< - ::prost::alloc::string::String, - ::prost::alloc::string::String, - >, + pub headers: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -38,12 +35,7 @@ pub struct ConfigQueryRequest { } #[allow(unused_imports)] pub trait Request: Send + Sync + 'static { - fn request( - &self, - request: poem_grpc::Request, - ) -> impl ::std::future::Future< - Output = ::std::result::Result, poem_grpc::Status>, - > + Send; + fn request(&self, request: poem_grpc::Request) -> impl ::std::future::Future, poem_grpc::Status>> + Send; } #[allow(unused_imports)] #[derive(Clone)] @@ -66,46 +58,31 @@ impl poem::IntoEndpoint for RequestServer { let mut route = poem::Route::new(); #[allow(non_camel_case_types)] struct RequestrequestService(::std::sync::Arc); - impl poem_grpc::service::UnaryService - for RequestrequestService { + impl poem_grpc::service::UnaryService for RequestrequestService { type Response = Payload; - async fn call( - &self, - request: poem_grpc::Request, - ) -> Result, poem_grpc::Status> { + async fn call(&self, request: poem_grpc::Request) -> Result, poem_grpc::Status> { self.0.request(request).await } } - route = route - .at( - "/request", - poem::endpoint::make({ - let svc = self.0.clone(); - move |req| { - let svc = svc.clone(); - async move { - let codec = as ::std::default::Default>::default(); - poem_grpc::server::GrpcServer::new(codec) - .unary(RequestrequestService(svc.clone()), req) - .await - } + route = route.at( + "/request", + poem::endpoint::make({ + let svc = self.0.clone(); + move |req| { + let svc = svc.clone(); + async move { + let codec = as ::std::default::Default>::default(); + poem_grpc::server::GrpcServer::new(codec).unary(RequestrequestService(svc.clone()), req).await } - }), - ); - let ep = route - .before(|req| async move { - if req.version() != poem::http::Version::HTTP_2 { - return Err( - poem::Error::from_status( - poem::http::StatusCode::HTTP_VERSION_NOT_SUPPORTED, - ), - ); } - Ok(req) - }); + }), + ); + let ep = route.before(|req| async move { + if req.version() != poem::http::Version::HTTP_2 { + return Err(poem::Error::from_status(poem::http::StatusCode::HTTP_VERSION_NOT_SUPPORTED)); + } + Ok(req) + }); ep.boxed() } } @@ -114,12 +91,7 @@ pub trait BiRequestStream: Send + Sync + 'static { fn request_bi_stream( &self, request: poem_grpc::Request>, - ) -> impl ::std::future::Future< - Output = ::std::result::Result< - poem_grpc::Response>, - poem_grpc::Status, - >, - > + Send; + ) -> impl ::std::future::Future>, poem_grpc::Status>> + Send; } #[allow(unused_imports)] #[derive(Clone)] @@ -142,54 +114,34 @@ impl poem::IntoEndpoint for BiRequestStreamServer { let mut route = poem::Route::new(); #[allow(non_camel_case_types)] struct BiRequestStreamrequest_bi_streamService(::std::sync::Arc); - impl< - T: BiRequestStream, - > poem_grpc::service::BidirectionalStreamingService - for BiRequestStreamrequest_bi_streamService { + impl poem_grpc::service::BidirectionalStreamingService for BiRequestStreamrequest_bi_streamService { type Response = Payload; async fn call( &self, request: poem_grpc::Request>, - ) -> Result< - poem_grpc::Response>, - poem_grpc::Status, - > { + ) -> Result>, poem_grpc::Status> { self.0.request_bi_stream(request).await } } - route = route - .at( - "/requestBiStream", - poem::endpoint::make({ - let svc = self.0.clone(); - move |req| { - let svc = svc.clone(); - async move { - let codec = as ::std::default::Default>::default(); - poem_grpc::server::GrpcServer::new(codec) - .bidirectional_streaming( - BiRequestStreamrequest_bi_streamService(svc.clone()), - req, - ) - .await - } + route = route.at( + "/requestBiStream", + poem::endpoint::make({ + let svc = self.0.clone(); + move |req| { + let svc = svc.clone(); + async move { + let codec = as ::std::default::Default>::default(); + poem_grpc::server::GrpcServer::new(codec).bidirectional_streaming(BiRequestStreamrequest_bi_streamService(svc.clone()), req).await } - }), - ); - let ep = route - .before(|req| async move { - if req.version() != poem::http::Version::HTTP_2 { - return Err( - poem::Error::from_status( - poem::http::StatusCode::HTTP_VERSION_NOT_SUPPORTED, - ), - ); } - Ok(req) - }); + }), + ); + let ep = route.before(|req| async move { + if req.version() != poem::http::Version::HTTP_2 { + return Err(poem::Error::from_status(poem::http::StatusCode::HTTP_VERSION_NOT_SUPPORTED)); + } + Ok(req) + }); ep.boxed() } } diff --git a/backend/spi/spi-kv/src/event.rs b/backend/spi/spi-kv/src/event.rs index df49adfee..0a1966719 100644 --- a/backend/spi/spi-kv/src/event.rs +++ b/backend/spi/spi-kv/src/event.rs @@ -24,15 +24,17 @@ async fn handle_kv_delete_event(req: KvItemDeleteReq, ctx: TardisContext) -> Tar pub async fn handle_events() -> TardisResult<()> { use bios_sdk_invoke::clients::event_client::asteroid_mq::prelude::*; - let topic = get_topic(&SPI_RPC_TOPIC).expect("topic not initialized"); + if let Some(topic) = get_topic(&SPI_RPC_TOPIC) { + topic + .create_endpoint([Interest::new("kv/*")]) + .await + .map_err(mq_error)? + .create_event_loop() + .with_handler(ContextHandler(handle_kv_add_event)) + .with_handler(ContextHandler(handle_kv_delete_event)) + .spawn(); + } + // let topic = get_topic(&SPI_RPC_TOPIC).expect("topic not initialized"); - topic - .create_endpoint([Interest::new("kv/*")]) - .await - .map_err(mq_error)? - .create_event_loop() - .with_handler(ContextHandler(handle_kv_add_event)) - .with_handler(ContextHandler(handle_kv_delete_event)) - .spawn(); Ok(()) } diff --git a/backend/spi/spi-log/src/event.rs b/backend/spi/spi-log/src/event.rs index e2e36a4b7..f5ba1b87f 100644 --- a/backend/spi/spi-log/src/event.rs +++ b/backend/spi/spi-log/src/event.rs @@ -1,6 +1,7 @@ use crate::{log_initializer::get_tardis_inst, serv}; use bios_sdk_invoke::clients::{ - event_client::{get_topic, mq_error, ContextHandler, SPI_RPC_TOPIC}, spi_log_client::{event::LOG_AVATAR, LogItemAddReq} + event_client::{get_topic, mq_error, ContextHandler, SPI_RPC_TOPIC}, + spi_log_client::{event::LOG_AVATAR, LogItemAddReq}, }; use tardis::{ basic::{dto::TardisContext, result::TardisResult}, @@ -16,14 +17,10 @@ async fn handle_add_event(req: LogItemAddReq, ctx: TardisContext) -> TardisResul pub async fn handle_events() -> TardisResult<()> { use bios_sdk_invoke::clients::event_client::asteroid_mq::prelude::*; - let topic = get_topic(&SPI_RPC_TOPIC).expect("topic not initialized"); + if let Some(topic) = get_topic(&SPI_RPC_TOPIC) { + topic.create_endpoint([Interest::new("spi-log/*")]).await.map_err(mq_error)?.create_event_loop().with_handler(ContextHandler(handle_add_event)).spawn(); + } + // let topic = get_topic(&SPI_RPC_TOPIC).expect("topic not initialized"); - topic - .create_endpoint([Interest::new("log/*")]) - .await - .map_err(mq_error)? - .create_event_loop() - .with_handler(ContextHandler(handle_add_event)) - .spawn(); Ok(()) -} \ No newline at end of file +} diff --git a/backend/spi/spi-log/src/log_config.rs b/backend/spi/spi-log/src/log_config.rs index dcb950a46..90dfab864 100644 --- a/backend/spi/spi-log/src/log_config.rs +++ b/backend/spi/spi-log/src/log_config.rs @@ -5,7 +5,7 @@ use std::fmt::Debug; #[derive(Debug, Serialize, Deserialize, Default, Clone)] #[serde(default)] pub struct LogConfig { - pub rbum: RbumConfig + pub rbum: RbumConfig, } #[derive(Debug, Serialize, Deserialize, Clone)] diff --git a/backend/spi/spi-search/src/event.rs b/backend/spi/spi-search/src/event.rs index ff4a892fa..a37848ea2 100644 --- a/backend/spi/spi-search/src/event.rs +++ b/backend/spi/spi-search/src/event.rs @@ -1,8 +1,5 @@ use bios_sdk_invoke::{ - clients::{ - event_client::{get_topic, mq_error,ContextHandler, SPI_RPC_TOPIC}, - - }, + clients::event_client::{get_topic, mq_error, ContextHandler, SPI_RPC_TOPIC}, dto::search_item_dto::{SearchEventItemDeleteReq, SearchEventItemModifyReq, SearchItemAddReq}, }; @@ -30,16 +27,17 @@ async fn handle_delete_event(req: SearchEventItemDeleteReq, ctx: TardisContext) pub async fn handle_events() -> TardisResult<()> { use bios_sdk_invoke::clients::event_client::asteroid_mq::prelude::*; - let topic = get_topic(&SPI_RPC_TOPIC).expect("topic not initialized"); + if let Some(topic) = get_topic(&SPI_RPC_TOPIC) { + topic + .create_endpoint([Interest::new("spi-search/*")]) + .await + .map_err(mq_error)? + .create_event_loop() + .with_handler(ContextHandler(handle_modify_event)) + .with_handler(ContextHandler(handle_add_event)) + .with_handler(ContextHandler(handle_delete_event)) + .spawn(); + } - topic - .create_endpoint([Interest::new("search/*")]) - .await - .map_err(mq_error)? - .create_event_loop() - .with_handler(ContextHandler(handle_modify_event)) - .with_handler(ContextHandler(handle_add_event)) - .with_handler(ContextHandler(handle_delete_event)) - .spawn(); Ok(()) -} \ No newline at end of file +} diff --git a/backend/supports/iam/src/basic/serv/clients/iam_log_client.rs b/backend/supports/iam/src/basic/serv/clients/iam_log_client.rs index 449caf1df..a156a2e55 100644 --- a/backend/supports/iam/src/basic/serv/clients/iam_log_client.rs +++ b/backend/supports/iam/src/basic/serv/clients/iam_log_client.rs @@ -12,7 +12,11 @@ use bios_sdk_invoke::clients::{ use serde::Serialize; use tardis::{ - basic::{dto::TardisContext, result::TardisResult}, chrono::{DateTime, Utc}, futures::TryFutureExt, serde_json::json, tokio, TardisFuns, TardisFunsInst + basic::{dto::TardisContext, result::TardisResult}, + chrono::{DateTime, Utc}, + futures::TryFutureExt, + serde_json::json, + tokio, TardisFuns, TardisFunsInst, }; use crate::{ diff --git a/backend/supports/iam/src/basic/serv/clients/iam_search_client.rs b/backend/supports/iam/src/basic/serv/clients/iam_search_client.rs index e14d05814..e63ef92c9 100644 --- a/backend/supports/iam/src/basic/serv/clients/iam_search_client.rs +++ b/backend/supports/iam/src/basic/serv/clients/iam_search_client.rs @@ -244,7 +244,7 @@ impl IamSearchClient { pub async fn delete_account_search(account_id: &str, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<()> { let tag = funs.conf::().spi.search_account_tag.clone(); if let Some(_topic) = get_topic(&SPI_RPC_TOPIC) { - EventCenterClient { topic_code: SPI_RPC_TOPIC }.delete_item_and_name( &tag, account_id, funs, ctx).await?; + EventCenterClient { topic_code: SPI_RPC_TOPIC }.delete_item_and_name(&tag, account_id, funs, ctx).await?; } else { SpiSearchClient::delete_item_and_name(&tag, account_id, funs, ctx).await?; } diff --git a/backend/supports/iam/src/basic/serv/iam_cert_serv.rs b/backend/supports/iam/src/basic/serv/iam_cert_serv.rs index 3c5260b44..41259325d 100644 --- a/backend/supports/iam/src/basic/serv/iam_cert_serv.rs +++ b/backend/supports/iam/src/basic/serv/iam_cert_serv.rs @@ -583,7 +583,7 @@ impl IamCertServ { } pub async fn modify_3th_kind_cert(modify_req: &mut IamThirdPartyCertExtModifyReq, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<()> { - let cert_3th = Self::get_3th_kind_cert_by_rel_rbum_id(&modify_req.rel_rbum_id, vec![modify_req.supplier.clone()], false, funs, ctx).await?; + let cert_3th = Self::get_3th_kind_cert_by_rel_rbum_id(Some(modify_req.rel_rbum_id.clone()), Some(vec![modify_req.supplier.clone()]), false, None, funs, ctx).await?; RbumCertServ::modify_rbum( &cert_3th.id, &mut RbumCertModifyReq { @@ -693,17 +693,19 @@ impl IamCertServ { /// 通过关联rbum_item id 查询三方凭证 pub async fn get_3th_kind_cert_by_rel_rbum_id( - rel_rbum_id: &str, - cert_supplier: Vec, + rel_rbum_id: Option, + cert_supplier: Option>, show_sk: bool, + ext: Option, funs: &TardisFunsInst, ctx: &TardisContext, ) -> TardisResult { let ext_cert = RbumCertServ::find_one_detail_rbum( &RbumCertFilterReq { kind: Some(IamCertExtKind::ThirdParty.to_string()), - suppliers: Some(cert_supplier.clone()), - rel_rbum_id: Some(rel_rbum_id.to_string()), + suppliers: cert_supplier.clone(), + rel_rbum_id, + ext, ..Default::default() }, funs, 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 d20a66c55..061f099c7 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 @@ -106,7 +106,7 @@ impl IamCcResApi { funs.begin().await?; warn!("rebuild_menu_res: begin task"); let mut bind_res = vec![]; // 绑定的资源ID - // find old menu res + // find old menu res let set_id = IamSetServ::get_default_set_id_by_ctx(&IamSetKind::Res, &funs, &global_ctx).await?; let old_menus = IamSetServ::get_menu_tree(&set_id, None, &funs, &global_ctx).await?.main.into_iter().filter(|menu| menu.sys_code != "0000").collect_vec(); for old_menu in &old_menus { @@ -137,8 +137,8 @@ impl IamCcResApi { continue; } match IamSetServ::delete_set_cate(&old_menu.id, &funs, &global_ctx).await { - Err(_) => {}, - Ok(_) => deleted_menus.push(old_menu.id.clone()) + Err(_) => {} + Ok(_) => deleted_menus.push(old_menu.id.clone()), }; } warn!("rebuild_menu_res: deleting set cate deleted_menus:{:?}", deleted_menus); @@ -159,7 +159,11 @@ impl IamCcResApi { icon: None, sort: None, ext: Some(new_menu.ext.clone()), - rbum_parent_cate_id: if new_menu.pid.is_empty() { Some(menu_root_id.clone()) } else { new_menu_map.get(&new_menu.pid).cloned() }, + rbum_parent_cate_id: if new_menu.pid.is_empty() { + Some(menu_root_id.clone()) + } else { + new_menu_map.get(&new_menu.pid).cloned() + }, }, &funs, &global_ctx, @@ -167,37 +171,45 @@ impl IamCcResApi { .await?; new_menu_map.insert(new_menu.id.clone(), set_cate_id.clone()); // add page res - let page_id = IamResServ::add_res_agg(&mut IamResAggAddReq { - res: IamResAddReq { - code: new_menu.name.into(), - hide: Some(false), - kind: IamResKind::Menu, - name: new_menu.title.into(), - scope_level: Some(RbumScopeLevelKind::Root), - ..Default::default() - }, - set: IamSetItemAggAddReq { - set_cate_id: set_cate_id.clone(), + let page_id = IamResServ::add_res_agg( + &mut IamResAggAddReq { + res: IamResAddReq { + code: new_menu.name.into(), + hide: Some(false), + kind: IamResKind::Menu, + name: new_menu.title.into(), + scope_level: Some(RbumScopeLevelKind::Root), + ..Default::default() + }, + set: IamSetItemAggAddReq { set_cate_id: set_cate_id.clone() }, }, - }, &set_id, &funs, &global_ctx).await?; + &set_id, + &funs, + &global_ctx, + ) + .await?; if new_menu.ext == "Root" || new_menu.ext == "System" { bind_res.push(page_id.clone()); } // add ele res if let Some(res) = new_menu.res { for ele in res { - let ele_id = IamResServ::add_res_agg(&mut IamResAggAddReq { - res: IamResAddReq { - code: ele.code.into(), - kind: IamResKind::Ele, - name: ele.name.into(), - scope_level: Some(RbumScopeLevelKind::Root), - ..Default::default() - }, - set: IamSetItemAggAddReq { - set_cate_id: set_cate_id.clone(), + let ele_id = IamResServ::add_res_agg( + &mut IamResAggAddReq { + res: IamResAddReq { + code: ele.code.into(), + kind: IamResKind::Ele, + name: ele.name.into(), + scope_level: Some(RbumScopeLevelKind::Root), + ..Default::default() + }, + set: IamSetItemAggAddReq { set_cate_id: set_cate_id.clone() }, }, - }, &set_id, &funs, &global_ctx).await?; + &set_id, + &funs, + &global_ctx, + ) + .await?; if new_menu.ext == "Root" || new_menu.ext == "System" { bind_res.push(ele_id); } @@ -205,10 +217,16 @@ impl IamCcResApi { } if let Some(apis) = new_menu.api { for api_code in apis { - if let Some(api) = RbumItemServ::find_one_rbum(&RbumBasicFilterReq { - code: Some(api_code), - ..Default::default() - }, &funs, &global_ctx).await? { + if let Some(api) = RbumItemServ::find_one_rbum( + &RbumBasicFilterReq { + code: Some(api_code), + ..Default::default() + }, + &funs, + &global_ctx, + ) + .await? + { IamRelServ::add_simple_rel(&IamRelKind::IamResApi, &api.id, &page_id, None, None, false, false, &funs, &global_ctx).await?; } } @@ -216,17 +234,30 @@ impl IamCcResApi { } warn!("rebuild_menu_res: add set cate finished"); // bind res with sys_admin_role - let sys_role_id = IamRoleServ::find_one_item(&IamRoleFilterReq { - basic: RbumBasicFilterReq { - code: Some("sys_admin".to_string()), + let sys_role_id = IamRoleServ::find_one_item( + &IamRoleFilterReq { + basic: RbumBasicFilterReq { + code: Some("sys_admin".to_string()), + ..Default::default() + }, ..Default::default() }, - ..Default::default() - }, &funs, &global_ctx).await?.map(|role| role.id).unwrap_or_default(); - IamRoleServ::modify_role_agg(&sys_role_id, &mut IamRoleAggModifyReq { - role: None, - res_ids: Some(bind_res), - }, &funs, &global_ctx).await?; + &funs, + &global_ctx, + ) + .await? + .map(|role| role.id) + .unwrap_or_default(); + IamRoleServ::modify_role_agg( + &sys_role_id, + &mut IamRoleAggModifyReq { + role: None, + res_ids: Some(bind_res), + }, + &funs, + &global_ctx, + ) + .await?; warn!("rebuild_menu_res: bind res with sys_admin_role finished"); funs.commit().await?; TardisResp::ok(Void {}) diff --git a/backend/supports/iam/src/console_interface/api/iam_ci_cert_api.rs b/backend/supports/iam/src/console_interface/api/iam_ci_cert_api.rs index 82894543d..40f098449 100644 --- a/backend/supports/iam/src/console_interface/api/iam_ci_cert_api.rs +++ b/backend/supports/iam/src/console_interface/api/iam_ci_cert_api.rs @@ -218,15 +218,16 @@ impl IamCiCertApi { #[oai(path = "/third-kind", method = "get")] async fn get_third_cert( &self, - account_id: Query, - supplier: Query, + account_id: Query>, + supplier: Query>, + ext: Query>, mut ctx: TardisContextExtractor, request: &Request, ) -> TardisApiResult { let funs = iam_constants::get_tardis_inst(); check_without_owner_and_unsafe_fill_ctx(request, &funs, &mut ctx.0)?; try_set_real_ip_from_req_to_ctx(request, &ctx.0).await?; - let rbum_cert = IamCertServ::get_3th_kind_cert_by_rel_rbum_id(&account_id.0, vec![supplier.0], true, &funs, &ctx.0).await?; + let rbum_cert = IamCertServ::get_3th_kind_cert_by_rel_rbum_id(account_id.0, supplier.0.map(|supplier| vec![supplier]), true, ext.0, &funs, &ctx.0).await?; ctx.0.execute_task().await?; TardisResp::ok(rbum_cert) } diff --git a/backend/supports/iam/src/console_passport/api/iam_cp_cert_api.rs b/backend/supports/iam/src/console_passport/api/iam_cp_cert_api.rs index 5cfc4b8c4..ff7eaf99a 100644 --- a/backend/supports/iam/src/console_passport/api/iam_cp_cert_api.rs +++ b/backend/supports/iam/src/console_passport/api/iam_cp_cert_api.rs @@ -137,7 +137,7 @@ impl IamCpCertApi { async fn get_third_cert(&self, supplier: Query, 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 rbum_cert = IamCertServ::get_3th_kind_cert_by_rel_rbum_id(&ctx.0.owner, vec![supplier.0], true, &funs, &ctx.0).await?; + let rbum_cert = IamCertServ::get_3th_kind_cert_by_rel_rbum_id(Some(ctx.0.owner.clone()), Some(vec![supplier.0]), true, None, &funs, &ctx.0).await?; ctx.0.execute_task().await?; TardisResp::ok(rbum_cert) } diff --git a/backend/supports/iam/src/console_tenant/api/iam_ct_cert_api.rs b/backend/supports/iam/src/console_tenant/api/iam_ct_cert_api.rs index 5d837b83c..f5db491b6 100644 --- a/backend/supports/iam/src/console_tenant/api/iam_ct_cert_api.rs +++ b/backend/supports/iam/src/console_tenant/api/iam_ct_cert_api.rs @@ -85,7 +85,7 @@ impl IamCtCertApi { let ctx = IamCertServ::try_use_tenant_ctx(ctx.0, tenant_id.0)?; try_set_real_ip_from_req_to_ctx(request, &ctx).await?; let funs = iam_constants::get_tardis_inst(); - let rbum_cert = IamCertServ::get_3th_kind_cert_by_rel_rbum_id(&account_id.0, vec![cert_supplier.0], true, &funs, &ctx).await?; + let rbum_cert = IamCertServ::get_3th_kind_cert_by_rel_rbum_id(Some(account_id.0), Some(vec![cert_supplier.0]), true, None, &funs, &ctx).await?; ctx.execute_task().await?; TardisResp::ok(rbum_cert) } diff --git a/backend/supports/iam/tests/test_cc_cert.rs b/backend/supports/iam/tests/test_cc_cert.rs index e2ae31a60..4d908c742 100644 --- a/backend/supports/iam/tests/test_cc_cert.rs +++ b/backend/supports/iam/tests/test_cc_cert.rs @@ -167,7 +167,7 @@ async fn test_single_level(context: &TardisContext, ak: &str, another_context: & .await?; info!("【test_cc_cert】 : test_single_level : Add Ext Cert - Gitlab"); - assert!(IamCertServ::get_3th_kind_cert_by_rel_rbum_id(&account_info.account_id, vec!["gitlab".to_string()], false, &funs, context).await.is_err()); + assert!(IamCertServ::get_3th_kind_cert_by_rel_rbum_id(Some(account_info.account_id.clone()), Some(vec!["gitlab".to_string()]), false, None, &funs, context).await.is_err()); IamCertServ::add_3th_kind_cert( &mut IamThirdPartyCertExtAddReq { ak: "GitlabUserId".to_string(), @@ -183,7 +183,7 @@ async fn test_single_level(context: &TardisContext, ak: &str, another_context: & ) .await?; assert_eq!( - IamCertServ::get_3th_kind_cert_by_rel_rbum_id(&account_info.account_id, vec!["gitlab".to_string()], false, &funs, context).await?.ak, + IamCertServ::get_3th_kind_cert_by_rel_rbum_id(Some(account_info.account_id), Some(vec!["gitlab".to_string()]), false, None, &funs, context).await?.ak, "GitlabUserId" ); diff --git a/frontend/sdks/invoke/src/clients/event_client.rs b/frontend/sdks/invoke/src/clients/event_client.rs index 99413793c..cc34c5988 100644 --- a/frontend/sdks/invoke/src/clients/event_client.rs +++ b/frontend/sdks/invoke/src/clients/event_client.rs @@ -197,7 +197,6 @@ pub fn get_topic(code: &TopicCode) -> Option { } pub const SPI_RPC_TOPIC: TopicCode = TopicCode::const_new("spi"); - pub fn mq_error(err: asteroid_mq::Error) -> TardisError { TardisError::internal_error(&err.to_string(), "mq-error") } diff --git a/frontend/sdks/invoke/src/clients/flow_client.rs b/frontend/sdks/invoke/src/clients/flow_client.rs index 86a582074..3101b023e 100644 --- a/frontend/sdks/invoke/src/clients/flow_client.rs +++ b/frontend/sdks/invoke/src/clients/flow_client.rs @@ -3,7 +3,6 @@ use serde::{Deserialize, Serialize}; pub mod event { use asteroid_mq::prelude::*; - use super::{FlowFrontChangeReq, FlowPostChangeReq}; pub const FLOW_AVATAR: &str = "flow"; pub const EVENT_FRONT_CHANGE: &str = "flow/front_change"; diff --git a/frontend/sdks/invoke/src/clients/spi_kv_client.rs b/frontend/sdks/invoke/src/clients/spi_kv_client.rs index 8dc29d2be..83e50acf9 100644 --- a/frontend/sdks/invoke/src/clients/spi_kv_client.rs +++ b/frontend/sdks/invoke/src/clients/spi_kv_client.rs @@ -15,7 +15,6 @@ pub mod event { use asteroid_mq::prelude::*; impl EventAttribute for super::KvItemAddOrModifyReq { const SUBJECT: Subject = Subject::const_new(b"kv/add"); - } impl EventAttribute for super::KvItemDeleteReq { const SUBJECT: Subject = Subject::const_new(b"kv/delete"); diff --git a/frontend/sdks/invoke/src/clients/spi_log_client.rs b/frontend/sdks/invoke/src/clients/spi_log_client.rs index e8cfe8c79..697e72058 100644 --- a/frontend/sdks/invoke/src/clients/spi_log_client.rs +++ b/frontend/sdks/invoke/src/clients/spi_log_client.rs @@ -16,7 +16,6 @@ use crate::{clients::base_spi_client::BaseSpiClient, invoke_constants::DYNAMIC_L pub mod event { use asteroid_mq::prelude::*; - pub const LOG_AVATAR: &str = "spi-log"; impl EventAttribute for super::LogItemAddReq { diff --git a/frontend/sdks/invoke/src/clients/spi_search_client.rs b/frontend/sdks/invoke/src/clients/spi_search_client.rs index 1b40fdb22..42eadad0f 100644 --- a/frontend/sdks/invoke/src/clients/spi_search_client.rs +++ b/frontend/sdks/invoke/src/clients/spi_search_client.rs @@ -22,7 +22,6 @@ pub mod event { pub req: SearchItemModifyReq, } - impl EventAttribute for SearchItemAddReq { const SUBJECT: Subject = Subject::const_new(b"search/add"); }