diff --git a/middleware/flow/src/dto/flow_external_dto.rs b/middleware/flow/src/dto/flow_external_dto.rs index 766ff4f1b..499abcf61 100644 --- a/middleware/flow/src/dto/flow_external_dto.rs +++ b/middleware/flow/src/dto/flow_external_dto.rs @@ -34,6 +34,7 @@ pub enum FlowExternalKind { #[derive(Debug, Deserialize, Serialize, poem_openapi::Object, Clone)] pub struct FlowExternalParams { pub rel_tag: Option, + pub rel_kind: Option, pub var_id: Option, pub var_name: Option, pub value: Option, diff --git a/middleware/flow/src/dto/flow_transition_dto.rs b/middleware/flow/src/dto/flow_transition_dto.rs index 168fec12c..c71209f46 100644 --- a/middleware/flow/src/dto/flow_transition_dto.rs +++ b/middleware/flow/src/dto/flow_transition_dto.rs @@ -316,15 +316,15 @@ pub enum StateChangeConditionOp { #[derive(Serialize, Deserialize, Clone, PartialEq, Debug, poem_openapi::Enum)] pub enum TagRelKind { - ParentFeed, - SubFeed, + Default, + ParentOrSub, } impl From for String { fn from(kind: TagRelKind) -> Self { match kind { - TagRelKind::ParentFeed => "PARENT_FEED".to_string(), - TagRelKind::SubFeed => "SUB_FEED".to_string(), + TagRelKind::Default => "DEFAULT".to_string(), + TagRelKind::ParentOrSub => "PARENT_OR_SUB".to_string(), } } } diff --git a/middleware/flow/src/serv/flow_external_serv.rs b/middleware/flow/src/serv/flow_external_serv.rs index 98d750e4e..d0569b256 100644 --- a/middleware/flow/src/serv/flow_external_serv.rs +++ b/middleware/flow/src/serv/flow_external_serv.rs @@ -13,7 +13,7 @@ use crate::{ FlowExternalFetchRelObjResp, FlowExternalKind, FlowExternalModifyFieldResp, FlowExternalNotifyChangesResp, FlowExternalParams, FlowExternalQueryFieldResp, FlowExternalReq, FlowExternalResp, }, - flow_state_dto::FlowSysStateKind, + flow_state_dto::FlowSysStateKind, flow_transition_dto::TagRelKind, }, flow_config::FlowConfig, flow_constants, @@ -26,7 +26,7 @@ impl FlowExternalServ { tag: &str, inst_id: &str, rel_business_obj_id: &str, - rel_tags: Vec, + rel_tags: Vec<(String, Option)>, ctx: &TardisContext, funs: &TardisFunsInst, ) -> TardisResult { @@ -39,8 +39,9 @@ impl FlowExternalServ { curr_bus_obj_id: rel_business_obj_id.to_string(), params: rel_tags .into_iter() - .map(|tag| FlowExternalParams { + .map(|(tag, kind)| FlowExternalParams { rel_tag: Some(tag), + rel_kind: kind.map(String::from), var_id: None, var_name: None, value: None, diff --git a/middleware/flow/src/serv/flow_inst_serv.rs b/middleware/flow/src/serv/flow_inst_serv.rs index b1e23e806..02b20d387 100644 --- a/middleware/flow/src/serv/flow_inst_serv.rs +++ b/middleware/flow/src/serv/flow_inst_serv.rs @@ -707,6 +707,7 @@ impl FlowInstServ { let mut params = vec![]; for (var_name, value) in vars { params.push(FlowExternalParams { + rel_kind: None, rel_tag: None, var_name: Some(var_name.clone()), var_id: None, @@ -852,13 +853,8 @@ impl FlowInstServ { } let rel_tag = change_info.obj_tag.unwrap_or_default(); if !rel_tag.is_empty() { - let obj_tag = if let Some(obj_tag_rel_kind) = change_info.obj_tag_rel_kind.clone() { - String::from(obj_tag_rel_kind) - } else { - rel_tag.clone() - }; let mut resp = - FlowExternalServ::do_fetch_rel_obj(¤t_model.tag, ¤t_inst.id, ¤t_inst.rel_business_obj_id, vec![obj_tag], ctx, funs).await?; + FlowExternalServ::do_fetch_rel_obj(¤t_model.tag, ¤t_inst.id, ¤t_inst.rel_business_obj_id, vec![(rel_tag.clone(), change_info.obj_tag_rel_kind.clone())], ctx, funs).await?; if !resp.rel_bus_objs.is_empty() { for rel_bus_obj_id in resp.rel_bus_objs.pop().unwrap().rel_bus_obj_ids { let inst_id = Self::get_inst_ids_by_rel_business_obj_id(vec![rel_bus_obj_id.clone()], funs, ctx).await?.pop().unwrap_or_default(); @@ -871,6 +867,7 @@ impl FlowInstServ { None, None, vec![FlowExternalParams { + rel_kind: None, rel_tag: None, var_id: None, var_name: Some(change_info.var_name.clone()), @@ -893,6 +890,7 @@ impl FlowInstServ { None, None, vec![FlowExternalParams { + rel_kind: None, rel_tag: None, var_id: None, var_name: Some(change_info.var_name.clone()), @@ -908,13 +906,8 @@ impl FlowInstServ { } FlowTransitionActionChangeKind::State => { if let Some(change_info) = post_change.state_change_info { - let obj_tag = if let Some(obj_tag_rel_kind) = change_info.obj_tag_rel_kind.clone() { - String::from(obj_tag_rel_kind) - } else { - change_info.obj_tag.clone() - }; let mut resp = - FlowExternalServ::do_fetch_rel_obj(¤t_model.tag, ¤t_inst.id, ¤t_inst.rel_business_obj_id, vec![obj_tag], ctx, funs).await?; + FlowExternalServ::do_fetch_rel_obj(¤t_model.tag, ¤t_inst.id, ¤t_inst.rel_business_obj_id, vec![(change_info.obj_tag.clone(), change_info.obj_tag_rel_kind.clone())], ctx, funs).await?; if !resp.rel_bus_objs.is_empty() { let inst_ids = Self::find_inst_ids_by_rel_obj_ids(resp.rel_bus_objs.pop().unwrap().rel_bus_obj_ids, &change_info, funs, ctx).await?; Self::do_modify_state_by_post_action(inst_ids, &change_info, updated_instance_list, funs, ctx).await?; @@ -943,12 +936,7 @@ impl FlowInstServ { let mut rel_tags = vec![]; for condition_item in change_condition.conditions.iter() { if condition_item.obj_tag.is_some() && !condition_item.state_id.is_empty() { - let obj_tag = if let Some(obj_tag_rel_kind) = condition_item.obj_tag_rel_kind.clone() { - String::from(obj_tag_rel_kind) - } else { - condition_item.obj_tag.clone().unwrap() - }; - rel_tags.push(obj_tag); + rel_tags.push((condition_item.obj_tag.clone().unwrap(), condition_item.obj_tag_rel_kind.clone())); } } let inst_id = Self::get_inst_ids_by_rel_business_obj_id(vec![rel_obj_id.clone()], funs, ctx).await?.pop().unwrap_or_default();