Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
ljl committed Nov 16, 2023
2 parents 7b3ba96 + 62b060c commit 1e1fec2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 25 deletions.
1 change: 1 addition & 0 deletions middleware/flow/src/dto/flow_external_dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub enum FlowExternalKind {
#[derive(Debug, Deserialize, Serialize, poem_openapi::Object, Clone)]
pub struct FlowExternalParams {
pub rel_tag: Option<String>,
pub rel_kind: Option<String>,
pub var_id: Option<String>,
pub var_name: Option<String>,
pub value: Option<Value>,
Expand Down
8 changes: 4 additions & 4 deletions middleware/flow/src/dto/flow_transition_dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TagRelKind> 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(),
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions middleware/flow/src/serv/flow_external_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -26,7 +26,7 @@ impl FlowExternalServ {
tag: &str,
inst_id: &str,
rel_business_obj_id: &str,
rel_tags: Vec<String>,
rel_tags: Vec<(String, Option<TagRelKind>)>,
ctx: &TardisContext,
funs: &TardisFunsInst,
) -> TardisResult<FlowExternalFetchRelObjResp> {
Expand All @@ -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,
Expand Down
24 changes: 6 additions & 18 deletions middleware/flow/src/serv/flow_inst_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(&current_model.tag, &current_inst.id, &current_inst.rel_business_obj_id, vec![obj_tag], ctx, funs).await?;
FlowExternalServ::do_fetch_rel_obj(&current_model.tag, &current_inst.id, &current_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();
Expand All @@ -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()),
Expand All @@ -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()),
Expand All @@ -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(&current_model.tag, &current_inst.id, &current_inst.rel_business_obj_id, vec![obj_tag], ctx, funs).await?;
FlowExternalServ::do_fetch_rel_obj(&current_model.tag, &current_inst.id, &current_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?;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 1e1fec2

Please sign in to comment.