Skip to content

Commit 62b060c

Browse files
authored
flow: update external dto (#528)
* flow:update * flow: update external dto * flow: update
1 parent 8dc511c commit 62b060c

File tree

4 files changed

+15
-25
lines changed

4 files changed

+15
-25
lines changed

middleware/flow/src/dto/flow_external_dto.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub enum FlowExternalKind {
3434
#[derive(Debug, Deserialize, Serialize, poem_openapi::Object, Clone)]
3535
pub struct FlowExternalParams {
3636
pub rel_tag: Option<String>,
37+
pub rel_kind: Option<String>,
3738
pub var_id: Option<String>,
3839
pub var_name: Option<String>,
3940
pub value: Option<Value>,

middleware/flow/src/dto/flow_transition_dto.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,15 +316,15 @@ pub enum StateChangeConditionOp {
316316

317317
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug, poem_openapi::Enum)]
318318
pub enum TagRelKind {
319-
ParentFeed,
320-
SubFeed,
319+
Default,
320+
ParentOrSub,
321321
}
322322

323323
impl From<TagRelKind> for String {
324324
fn from(kind: TagRelKind) -> Self {
325325
match kind {
326-
TagRelKind::ParentFeed => "PARENT_FEED".to_string(),
327-
TagRelKind::SubFeed => "SUB_FEED".to_string(),
326+
TagRelKind::Default => "DEFAULT".to_string(),
327+
TagRelKind::ParentOrSub => "PARENT_OR_SUB".to_string(),
328328
}
329329
}
330330
}

middleware/flow/src/serv/flow_external_serv.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::{
1313
FlowExternalFetchRelObjResp, FlowExternalKind, FlowExternalModifyFieldResp, FlowExternalNotifyChangesResp, FlowExternalParams, FlowExternalQueryFieldResp,
1414
FlowExternalReq, FlowExternalResp,
1515
},
16-
flow_state_dto::FlowSysStateKind,
16+
flow_state_dto::FlowSysStateKind, flow_transition_dto::TagRelKind,
1717
},
1818
flow_config::FlowConfig,
1919
flow_constants,
@@ -26,7 +26,7 @@ impl FlowExternalServ {
2626
tag: &str,
2727
inst_id: &str,
2828
rel_business_obj_id: &str,
29-
rel_tags: Vec<String>,
29+
rel_tags: Vec<(String, Option<TagRelKind>)>,
3030
ctx: &TardisContext,
3131
funs: &TardisFunsInst,
3232
) -> TardisResult<FlowExternalFetchRelObjResp> {
@@ -39,8 +39,9 @@ impl FlowExternalServ {
3939
curr_bus_obj_id: rel_business_obj_id.to_string(),
4040
params: rel_tags
4141
.into_iter()
42-
.map(|tag| FlowExternalParams {
42+
.map(|(tag, kind)| FlowExternalParams {
4343
rel_tag: Some(tag),
44+
rel_kind: kind.map(String::from),
4445
var_id: None,
4546
var_name: None,
4647
value: None,

middleware/flow/src/serv/flow_inst_serv.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,7 @@ impl FlowInstServ {
707707
let mut params = vec![];
708708
for (var_name, value) in vars {
709709
params.push(FlowExternalParams {
710+
rel_kind: None,
710711
rel_tag: None,
711712
var_name: Some(var_name.clone()),
712713
var_id: None,
@@ -852,13 +853,8 @@ impl FlowInstServ {
852853
}
853854
let rel_tag = change_info.obj_tag.unwrap_or_default();
854855
if !rel_tag.is_empty() {
855-
let obj_tag = if let Some(obj_tag_rel_kind) = change_info.obj_tag_rel_kind.clone() {
856-
String::from(obj_tag_rel_kind)
857-
} else {
858-
rel_tag.clone()
859-
};
860856
let mut resp =
861-
FlowExternalServ::do_fetch_rel_obj(&current_model.tag, &current_inst.id, &current_inst.rel_business_obj_id, vec![obj_tag], ctx, funs).await?;
857+
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?;
862858
if !resp.rel_bus_objs.is_empty() {
863859
for rel_bus_obj_id in resp.rel_bus_objs.pop().unwrap().rel_bus_obj_ids {
864860
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 {
871867
None,
872868
None,
873869
vec![FlowExternalParams {
870+
rel_kind: None,
874871
rel_tag: None,
875872
var_id: None,
876873
var_name: Some(change_info.var_name.clone()),
@@ -893,6 +890,7 @@ impl FlowInstServ {
893890
None,
894891
None,
895892
vec![FlowExternalParams {
893+
rel_kind: None,
896894
rel_tag: None,
897895
var_id: None,
898896
var_name: Some(change_info.var_name.clone()),
@@ -908,13 +906,8 @@ impl FlowInstServ {
908906
}
909907
FlowTransitionActionChangeKind::State => {
910908
if let Some(change_info) = post_change.state_change_info {
911-
let obj_tag = if let Some(obj_tag_rel_kind) = change_info.obj_tag_rel_kind.clone() {
912-
String::from(obj_tag_rel_kind)
913-
} else {
914-
change_info.obj_tag.clone()
915-
};
916909
let mut resp =
917-
FlowExternalServ::do_fetch_rel_obj(&current_model.tag, &current_inst.id, &current_inst.rel_business_obj_id, vec![obj_tag], ctx, funs).await?;
910+
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?;
918911
if !resp.rel_bus_objs.is_empty() {
919912
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?;
920913
Self::do_modify_state_by_post_action(inst_ids, &change_info, updated_instance_list, funs, ctx).await?;
@@ -943,12 +936,7 @@ impl FlowInstServ {
943936
let mut rel_tags = vec![];
944937
for condition_item in change_condition.conditions.iter() {
945938
if condition_item.obj_tag.is_some() && !condition_item.state_id.is_empty() {
946-
let obj_tag = if let Some(obj_tag_rel_kind) = condition_item.obj_tag_rel_kind.clone() {
947-
String::from(obj_tag_rel_kind)
948-
} else {
949-
condition_item.obj_tag.clone().unwrap()
950-
};
951-
rel_tags.push(obj_tag);
939+
rel_tags.push((condition_item.obj_tag.clone().unwrap(), condition_item.obj_tag_rel_kind.clone()));
952940
}
953941
}
954942
let inst_id = Self::get_inst_ids_by_rel_business_obj_id(vec![rel_obj_id.clone()], funs, ctx).await?.pop().unwrap_or_default();

0 commit comments

Comments
 (0)