Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/ideal-world/bios
Browse files Browse the repository at this point in the history
  • Loading branch information
ljl committed May 23, 2024
2 parents 75bcb8a + 46af9f0 commit 1deb175
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions backend/middlewares/flow/src/serv/flow_event_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,26 +226,28 @@ impl FlowEventServ {
&& change_info.changed_val.clone().unwrap().as_object().unwrap().get("value").is_some()
&& change_info.changed_val.clone().unwrap().as_object().unwrap().get("op").is_some()
{
let original_value = if let Some(original_value) =
let original_value = if let Some(custom_value) =
FlowInstServ::find_var_by_inst_id(flow_inst_id, &format!("custom_{}", change_info.var_name), funs, ctx).await?
{
Some(custom_value)
} else if let Some(original_value) = FlowInstServ::find_var_by_inst_id(flow_inst_id, &change_info.var_name, funs, ctx).await? {
Some(original_value)
} else {
FlowInstServ::find_var_by_inst_id(flow_inst_id, &change_info.var_name, funs, ctx).await?
Some(json!(""))
};

let target_value = change_info.changed_val.clone().unwrap().as_object().unwrap().get("value").unwrap().as_i64().unwrap_or_default();
let target_value = change_info.changed_val.clone().unwrap().as_object().unwrap().get("value").unwrap().as_f64().unwrap_or_default();
let changed_op = change_info.changed_val.clone().unwrap().as_object().unwrap().get("op").unwrap().as_str().unwrap_or_default().to_string();
if let Some(original_value) = original_value {
change_info.changed_kind = Some(FlowTransitionActionByVarChangeInfoChangedKind::ChangeContent);
match changed_op.as_str() {
"add" => {
change_info.changed_val =
Some(json!(original_value.as_str().unwrap_or_default().parse::<i64>().unwrap_or_default() + target_value))
Some(json!(original_value.as_str().unwrap_or_default().parse::<f64>().unwrap_or_default() + target_value))
}
"sub" => {
change_info.changed_val =
Some(json!(original_value.as_str().unwrap_or_default().parse::<i64>().unwrap_or_default() - target_value))
Some(json!(original_value.as_str().unwrap_or_default().parse::<f64>().unwrap_or_default() - target_value))
}
_ => {}
}
Expand Down

0 comments on commit 1deb175

Please sign in to comment.