Skip to content

Commit

Permalink
flow: insert default opkind (#580)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZzIsGod1019 authored Jan 9, 2024
1 parent 752fb4e commit c663278
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion middleware/flow/src/api/cc/flow_cc_inst_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use tardis::web::poem_openapi::param::{Path, Query};
use tardis::web::poem_openapi::payload::Json;
use tardis::web::web_resp::{TardisApiResult, TardisPage, TardisResp, Void};

use crate::dto::flow_external_dto::FlowExternalCallbackOp;
use crate::dto::flow_inst_dto::{
FlowInstAbortReq, FlowInstDetailResp, FlowInstFindNextTransitionResp, FlowInstFindNextTransitionsReq, FlowInstFindStateAndTransitionsReq, FlowInstFindStateAndTransitionsResp,
FlowInstModifyAssignedReq, FlowInstModifyCurrentVarsReq, FlowInstStartReq, FlowInstSummaryResp, FlowInstTransferReq, FlowInstTransferResp,
Expand Down Expand Up @@ -92,7 +93,7 @@ impl FlowCcInstApi {
let mut funs = flow_constants::get_tardis_inst();
FlowInstServ::check_transfer_vars(&flow_inst_id.0, &transfer_req.0, &funs, &ctx.0).await?;
funs.begin().await?;
let result = FlowInstServ::transfer(&flow_inst_id.0, &transfer_req.0, false, &funs, &ctx.0).await?;
let result = FlowInstServ::transfer(&flow_inst_id.0, &transfer_req.0, false, FlowExternalCallbackOp::Default, &funs, &ctx.0).await?;
funs.commit().await?;
TardisResp::ok(result)
}
Expand Down
3 changes: 2 additions & 1 deletion middleware/flow/src/dto/flow_external_dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ pub enum FlowExternalKind {
QueryField,
}

#[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize, poem_openapi::Enum)]
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize, poem_openapi::Enum)]
pub enum FlowExternalCallbackOp {
#[default]
Default,
PostAction,
VerifyContent,
ConditionalTrigger,
Expand Down
2 changes: 2 additions & 0 deletions middleware/flow/src/serv/flow_external_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ impl FlowExternalServ {
original_sys_state: FlowSysStateKind,
transition_name: String,
is_notify: bool,
callback_op: Option<FlowExternalCallbackOp>,
ctx: &TardisContext,
funs: &TardisFunsInst,
) -> TardisResult<FlowExternalNotifyChangesResp> {
Expand All @@ -156,6 +157,7 @@ impl FlowExternalServ {
let header = Self::headers(None, funs, ctx).await?;
let body = FlowExternalReq {
kind: FlowExternalKind::NotifyChanges,
callback_op,
inst_id: inst_id.to_string(),
curr_tag: tag.to_string(),
curr_bus_obj_id: rel_business_obj_id.to_string(),
Expand Down
7 changes: 6 additions & 1 deletion middleware/flow/src/serv/flow_inst_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,12 +622,13 @@ impl FlowInstServ {
flow_inst_id: &str,
transfer_req: &FlowInstTransferReq,
skip_filter: bool,
callback_kind: FlowExternalCallbackOp,
funs: &TardisFunsInst,
ctx: &TardisContext,
) -> TardisResult<FlowInstTransferResp> {
// record updated instance id
let mut updated_instance_list: Vec<String> = Vec::new();
let result = Self::do_transfer(flow_inst_id, transfer_req, &mut updated_instance_list, skip_filter, funs, ctx).await;
let result = Self::do_transfer(flow_inst_id, transfer_req, &mut updated_instance_list, skip_filter, callback_kind, funs, ctx).await;

for updated_instance_id in updated_instance_list {
Self::do_front_change(&updated_instance_id, ctx, funs).await?;
Expand All @@ -642,6 +643,7 @@ impl FlowInstServ {
transfer_req: &FlowInstTransferReq,
updated_instance_list: &mut Vec<String>,
skip_filter: bool,
callback_kind: FlowExternalCallbackOp,
funs: &TardisFunsInst,
ctx: &TardisContext,
) -> TardisResult<FlowInstTransferResp> {
Expand Down Expand Up @@ -807,6 +809,7 @@ impl FlowInstServ {
prev_flow_state.sys_state.clone(),
next_transition_detail.name.clone(),
next_transition_detail.is_notify,
Some(callback_kind),
ctx,
funs,
)
Expand Down Expand Up @@ -1101,6 +1104,7 @@ impl FlowInstServ {
},
updated_instance_list,
true,
FlowExternalCallbackOp::PostAction,
funs,
ctx,
)
Expand Down Expand Up @@ -1326,6 +1330,7 @@ impl FlowInstServ {
vars: None,
},
true,
FlowExternalCallbackOp::ConditionalTrigger,
funs,
ctx,
)
Expand Down

0 comments on commit c663278

Please sign in to comment.