Skip to content

Commit

Permalink
flow: fix bug (inst search failed) (#884)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZzIsGod1019 authored Dec 20, 2024
1 parent 584bb1f commit 8df06f2
Show file tree
Hide file tree
Showing 14 changed files with 490 additions and 319 deletions.
2 changes: 1 addition & 1 deletion backend/gateways/spacegate-plugins/src/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use self::audit_log_param::LogParamContent;
pub mod audit_log_param;
pub mod before_encrypt_body;
pub mod cert_info;
pub mod request_crypto_status;
pub mod notification;
pub mod request_crypto_status;
pub enum ExtensionPackEnum {
LogParamContent(),
None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ impl NotificationContext {
}
}


#[derive(Debug, Serialize)]
pub struct ReachMsgSendReq {
pub scene_code: String,
Expand Down
2 changes: 1 addition & 1 deletion backend/gateways/spacegate-plugins/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ pub mod anti_xss;
pub mod audit_log;
pub mod auth;
pub mod ip_time;
pub mod notify;
pub mod op_redis_publisher;
pub mod rewrite_ns_b_ip;
pub mod notify;
28 changes: 16 additions & 12 deletions backend/middlewares/flow/src/dto/flow_inst_dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ use tardis::{
};

use super::{
flow_model_dto::FlowModelRelTransitionExt, flow_state_dto::{FlowGuardConf, FlowStateKind, FlowStateOperatorKind, FlowStateRelModelExt, FlowStateVar, FlowSysStateKind}, flow_transition_dto::FlowTransitionDoubleCheckInfo, flow_var_dto::FlowVarInfo
flow_model_dto::FlowModelRelTransitionExt,
flow_state_dto::{FlowGuardConf, FlowStateKind, FlowStateOperatorKind, FlowStateRelModelExt, FlowStateVar, FlowSysStateKind},
flow_transition_dto::FlowTransitionDoubleCheckInfo,
flow_var_dto::FlowVarInfo,
};

#[derive(Serialize, Deserialize, Debug, poem_openapi::Object)]
Expand Down Expand Up @@ -234,17 +237,17 @@ pub struct FlowInstArtifacts {
// 流程实例中数据存储更新
#[derive(Serialize, Deserialize, PartialEq, Clone, Debug, Default, sea_orm::FromJsonQueryResult)]
pub struct FlowInstArtifactsModifyReq {
pub guard_conf: Option<FlowGuardConf>, // 当前操作人权限
pub prohibit_guard_conf_account_ids: Option<Vec<String>>, // 禁止操作人ID列表
pub guard_conf_account_ids: Option<Vec<String>>, // 更新操作人列表
pub add_approval_result: Option<(String, FlowApprovalResultKind)>, // 增加审批结果
pub form_state_map: Option<HashMap<String, Value>>, // 录入节点映射 key为节点ID,对应的value为节点中的录入的参数
pub clear_form_result: Option<String>, // 清除节点录入信息
pub clear_approval_result: Option<String>, // 清除节点录入信息
pub prev_non_auto_state_id: Option<Vec<String>>, // 上一个非自动节点ID
pub prev_non_auto_account_id: Option<String>, // 上一个节点操作人ID
pub curr_approval_total: Option<usize>, // 当前审批总数
pub curr_vars: Option<HashMap<String, Value>>, // 当前参数列表
pub guard_conf: Option<FlowGuardConf>, // 当前操作人权限
pub prohibit_guard_conf_account_ids: Option<Vec<String>>, // 禁止操作人ID列表
pub guard_conf_account_ids: Option<Vec<String>>, // 更新操作人列表
pub add_approval_result: Option<(String, FlowApprovalResultKind)>, // 增加审批结果
pub form_state_map: Option<HashMap<String, Value>>, // 录入节点映射 key为节点ID,对应的value为节点中的录入的参数
pub clear_form_result: Option<String>, // 清除节点录入信息
pub clear_approval_result: Option<String>, // 清除节点录入信息
pub prev_non_auto_state_id: Option<Vec<String>>, // 上一个非自动节点ID
pub prev_non_auto_account_id: Option<String>, // 上一个节点操作人ID
pub curr_approval_total: Option<usize>, // 当前审批总数
pub curr_vars: Option<HashMap<String, Value>>, // 当前参数列表
}

/// 审批结果类型
Expand Down Expand Up @@ -478,6 +481,7 @@ pub struct FlowInstFilterReq {
pub ids: Option<Vec<String>>,
pub code: Option<String>,
/// 关联模型ID
pub flow_model_id: Option<String>,
pub flow_version_id: Option<String>,
/// 业务ID
pub rel_business_obj_ids: Option<Vec<String>>,
Expand Down
2 changes: 1 addition & 1 deletion backend/middlewares/flow/src/dto/flow_model_dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,4 +477,4 @@ pub struct FlowModelSyncModifiedFieldReq {
/// 参数列表
pub add_fields: Vec<String>,
pub delete_fields: Vec<String>,
}
}
2 changes: 1 addition & 1 deletion backend/middlewares/flow/src/dto/flow_state_dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,4 +470,4 @@ impl FromStr for FlowStateOperatorKind {
_ => Err(TardisError::bad_request(&format!("invalid FlowStateOperatorKind: {}", s), "400-operator-invalid-param")),
}
}
}
}
5 changes: 1 addition & 4 deletions backend/middlewares/flow/src/dto/flow_transition_dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,10 +629,7 @@ impl FlowTransitionFrontActionInfoRelevanceRelation {
{
let left_values = TardisFuns::json.str_to_obj::<Vec<Value>>(&left_value).unwrap_or_default();
if left_values.len() == 1 {
left_value = left_values
.first().cloned()
.unwrap_or_default().as_str()
.unwrap_or("").to_string();
left_value = left_values.first().cloned().unwrap_or_default().as_str().unwrap_or("").to_string();
} else {
return false;
}
Expand Down
47 changes: 29 additions & 18 deletions backend/middlewares/flow/src/serv/clients/search_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,27 @@ use bios_sdk_invoke::{
event_client::{get_topic, EventCenterClient, SPI_RPC_TOPIC},
spi_search_client::SpiSearchClient,
},
dto::search_item_dto::{SearchItemAddReq, SearchItemModifyReq, SearchItemQueryReq, SearchItemSearchCtxReq, SearchItemSearchPageReq, SearchItemSearchReq, SearchItemSearchResp, SearchItemVisitKeysReq},
dto::search_item_dto::{
SearchItemAddReq, SearchItemModifyReq, SearchItemQueryReq, SearchItemSearchCtxReq, SearchItemSearchPageReq, SearchItemSearchReq, SearchItemSearchResp,
SearchItemVisitKeysReq,
},
};
use itertools::Itertools;
use serde_json::json;
use tardis::{
basic::{dto::TardisContext, field::TrimString, result::TardisResult}, log::debug, tokio, web::web_resp::TardisPage, TardisFuns, TardisFunsInst
basic::{dto::TardisContext, field::TrimString, result::TardisResult},
log::debug,
tokio,
web::web_resp::TardisPage,
TardisFuns, TardisFunsInst,
};

use crate::{
dto::{
flow_inst_dto::FlowInstFilterReq,
flow_model_dto::{FlowModelDetailResp, FlowModelFilterReq, FlowModelRelTransitionExt},
flow_model_version_dto::FlowModelVersionFilterReq, flow_state_dto::FlowGuardConf,
flow_model_version_dto::FlowModelVersionFilterReq,
flow_state_dto::FlowGuardConf,
},
flow_constants,
serv::{
Expand Down Expand Up @@ -258,10 +266,7 @@ impl FlowSearchClient {
}

pub async fn search_guard_account_num(guard_conf: &FlowGuardConf, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<Option<u64>> {
if guard_conf.guard_by_spec_account_ids.is_empty()
&& guard_conf.guard_by_spec_org_ids.is_empty()
&& guard_conf.guard_by_spec_role_ids.is_empty()
{
if guard_conf.guard_by_spec_account_ids.is_empty() && guard_conf.guard_by_spec_org_ids.is_empty() && guard_conf.guard_by_spec_role_ids.is_empty() {
debug!("flow search_guard_account_num result : 0");
return Ok(Some(0));
}
Expand All @@ -279,18 +284,24 @@ impl FlowSearchClient {
if !guard_conf.guard_by_spec_role_ids.is_empty() {
search_ctx_req.roles = Some(guard_conf.guard_by_spec_role_ids.clone());
}
let result = SpiSearchClient::search(&SearchItemSearchReq {
tag: "iam_account".to_string(),
ctx: search_ctx_req,
query: SearchItemQueryReq { ..Default::default() },
adv_query: None,
sort: None,
page:SearchItemSearchPageReq {
number: 1,
size: 1,
fetch_total: true,
let result = SpiSearchClient::search(
&SearchItemSearchReq {
tag: "iam_account".to_string(),
ctx: search_ctx_req,
query: SearchItemQueryReq { ..Default::default() },
adv_query: None,
sort: None,
page: SearchItemSearchPageReq {
number: 1,
size: 1,
fetch_total: true,
},
},
}, funs, ctx).await?.map(|result| result.total_size);
funs,
ctx,
)
.await?
.map(|result| result.total_size);
debug!("flow search_guard_account_num result : {:?}", result);
Ok(result)
}
Expand Down
7 changes: 5 additions & 2 deletions backend/middlewares/flow/src/serv/flow_external_serv.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use bios_sdk_invoke::{clients::spi_kv_client::SpiKvClient, invoke_constants::TARDIS_CONTEXT};
use itertools::Itertools;
use tardis::{
basic::{dto::TardisContext, result::TardisResult}, log::debug, tokio, TardisFuns, TardisFunsInst
basic::{dto::TardisContext, result::TardisResult},
log::debug,
tokio, TardisFuns, TardisFunsInst,
};

use crate::{
Expand All @@ -12,7 +14,8 @@ use crate::{
},
flow_state_dto::FlowSysStateKind,
flow_transition_dto::{FlowTransitionActionByVarChangeInfoChangedKind, FlowTransitionDetailResp, TagRelKind},
}, flow_constants
},
flow_constants,
};

pub struct FlowExternalServ;
Expand Down
Loading

0 comments on commit 8df06f2

Please sign in to comment.