Skip to content

Commit

Permalink
flow: merge modify field req (#706)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZzIsGod1019 authored Apr 10, 2024
1 parent 0394c8c commit 20eb833
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 75 deletions.
75 changes: 41 additions & 34 deletions backend/middlewares/flow/src/serv/flow_event_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ impl FlowEventServ {
return Ok(());
}

// merge modify field
let mut modify_self_field_params = vec![];

for post_change in post_changes {
let post_change = FlowTransitionActionChangeAgg::from(post_change);
match post_change.kind {
Expand Down Expand Up @@ -275,40 +278,14 @@ impl FlowEventServ {
}
}
} else {
FlowExternalServ::do_modify_field(
&flow_model.tag,
&next_transition_detail,
&flow_inst_detail.rel_business_obj_id,
&flow_inst_detail.id,
FlowExternalCallbackOp::PostAction,
next_flow_state.name.clone(),
next_flow_state.sys_state.clone(),
prev_flow_state.name.clone(),
prev_flow_state.sys_state.clone(),
vec![FlowExternalParams {
rel_kind: None,
rel_tag: None,
var_id: None,
var_name: Some(change_info.var_name.clone()),
value: change_info.changed_val.clone(),
changed_kind: change_info.changed_kind,
}],
ctx,
funs,
)
.await?;
if let Some(ws_client) = ws_flow_client().await {
ws_client
.publish_front_change(
flow_inst_detail.id.clone(),
default_flow_avatar().await.clone(),
funs.conf::<FlowConfig>().invoke.spi_app_id.clone(),
ctx,
)
.await?;
} else {
FlowEventServ::do_front_change(&flow_inst_detail.id, ctx, funs).await?;
}
modify_self_field_params.push(FlowExternalParams {
rel_kind: None,
rel_tag: None,
var_id: None,
var_name: Some(change_info.var_name.clone()),
value: change_info.changed_val.clone(),
changed_kind: change_info.changed_kind,
});
}
}
}
Expand All @@ -332,6 +309,36 @@ impl FlowEventServ {
}
}

if !modify_self_field_params.is_empty() {
FlowExternalServ::do_modify_field(
&flow_model.tag,
&next_transition_detail,
&flow_inst_detail.rel_business_obj_id,
&flow_inst_detail.id,
FlowExternalCallbackOp::PostAction,
next_flow_state.name.clone(),
next_flow_state.sys_state.clone(),
prev_flow_state.name.clone(),
prev_flow_state.sys_state.clone(),
modify_self_field_params,
ctx,
funs,
)
.await?;
if let Some(ws_client) = ws_flow_client().await {
ws_client
.publish_front_change(
flow_inst_detail.id.clone(),
default_flow_avatar().await.clone(),
funs.conf::<FlowConfig>().invoke.spi_app_id.clone(),
ctx,
)
.await?;
} else {
FlowEventServ::do_front_change(&flow_inst_detail.id, ctx, funs).await?;
}
}

Ok(())
}

Expand Down
88 changes: 47 additions & 41 deletions backend/middlewares/flow/tests/config/conf-default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,51 +12,57 @@ kv = "https://127.0.0.1:8080/spi-kv"
port = 8080
tls_key = """
-----BEGIN RSA PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCq4QyODxghypMz
u3wSNYAH7qsekRasbkFWlzRlfCkVfxMynGh8uRfNod4UrHAWTXDJAneHoFgqXemI
Vf1z87r0T2NFf3+oochAKvE6z9hNSeBbLIeZXPQQcabtO9T5cS4anK3k0mbgRpdM
bDhv4p+fbwCp6gOA/qeqs58p/f5UoXYVcjKmSQQAA5KSm4bPbBl89fiUFv1Rcp5H
L+sMIkFpwq8lYnEqKvV/1V8isMvhVDUo7MrIUwgqn6+n7KJIIsugOqxVKrYA4E6R
oFC1V3O5jdTrDvWhzlHel5VWHX6rG/4J4GvD+6nMZ2CvgK8DeW/vEsRUlPDPoTc0
QRftHEO3AgMBAAECggEAGJC42tVNrVHvfoDl8cIyMTG89Ox7u3cwOnALTsmeKGJ3
0o9MsB110BCEmik+Bd7FJ4iMwXkqI5ETqQ9fm+M+ja+6ADw3kHkNjjf+LOvDVz0X
HVRV/BSyW4jTLAitcdy0+YtrrlkXBAfx6UEnjeIg+20cRdEIBuvVE8O1znYesXC2
oALXl2f1lJE8n83rijn5ecxuJIM3fKt/tgfMPEfyz7OqY3USKGzaDUZyScLW1b0V
D2m1os7lzEuIkqK6J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dVBGkpoW
oR6kHDAaMRgwFgYDVQQDDA9wb255dG93biBSU0EgQ0GCAXswOwYDVR0RBDQwMoIO
dGVzdHNlcnZlci5jb22CFXNlY29uZC50ZXN0c2VydmVyLmNvbYIJbG9jYWxob3N0
MA0GCSqGSIb3DQEBCwUAA4IBgQBsk5ivAaRAcNgjc7LEiWXFkMg703AqDDNx7kB1
RDgLalLvrjOfOp2jsDfST7N1tKLBSQ9bMw9X4Jve+j7XXRUthcwuoYTeeo+Cy0/T
1Q78ctoX74E2nB958zwmtRykGrgE/6JAJDwGcgpY9kBPycGxTlCN926uGxHsDwVs
98cL6ZXptMLTR6T2XP36dAJZuOICSqmCSbFR8knc/gjUO36rXTxhwci8iDbmEVaf
BHpgBXGU5+SQ+QM++v6bHGf4LNQC5NZ4e4xvGax8ioYu/BRsB/T3Lx+RlItz4zdU
XuxCNcm3nhQV2ZHquRdbSdoyIxV5kJXel4wCmOhWIq7A2OBKdu5fQzIAzzLi65EN
RPAKsKB4h7hGgvciZQ7dsMrlGw0DLdJ6UrFyiR5Io7dXYT/+JP91lP5xsl6Lhg9O
FgALt7GSYRm2cZdgi9pO9rRr83Br1VjQT1vHz6yoZMXSqc4A2zcN2a2ZVq//rHvc
FZygs8miAhWPzqnpmgTj1cPiU1M=
-----END CERTIFICATE-----
"""
[fw.web_server.modules.flow]
Expand Down
6 changes: 6 additions & 0 deletions backend/middlewares/flow/tests/test_flow_scenes_fsm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ pub async fn test(flow_client: &mut TestHttpClient) -> TardisResult<()> {
.await;
assert!(result.into_iter().find(|resp| resp.tag == "MOCK").unwrap().model_id.is_none());

ctx.owner = "".to_string();
flow_client.set_auth(&ctx)?;

let rel_business_obj_id = TardisFuns::field.nanoid();
let _: String = flow_client
.post(
Expand Down Expand Up @@ -138,6 +141,7 @@ pub async fn test(flow_client: &mut TestHttpClient) -> TardisResult<()> {
)
.await;
// 2. enter tenant
ctx.owner = "u001".to_string();
ctx.own_paths = "t1".to_string();
flow_client.set_auth(&ctx)?;
// 2-1. Get states list
Expand Down Expand Up @@ -806,6 +810,8 @@ pub async fn test(flow_client: &mut TestHttpClient) -> TardisResult<()> {
}),
)
.await;
ctx.owner = "".to_string();
flow_client.set_auth(&ctx)?;
let _: Void = flow_client.get("/ci/inst/trigger_front_action").await;
tokio::time::sleep(tokio::time::Duration::from_secs(3)).await;
let state_and_next_transitions: Vec<FlowInstFindStateAndTransitionsResp> = flow_client
Expand Down

0 comments on commit 20eb833

Please sign in to comment.