From 4257bf90cb31bab404d9717fc8e0710d74d3e4d3 Mon Sep 17 00:00:00 2001 From: ZzIsGod1019 <1498852723@qq.com> Date: Sat, 21 Sep 2024 23:52:04 +0800 Subject: [PATCH] flow: fix bug (instance transation not found) (#849) * flow: fix bug * flow: fix bug (bind model template) * flow: update --- .../flow/src/api/ci/flow_ci_inst_api.rs | 18 +++++++++++++++--- .../middlewares/flow/src/dto/flow_inst_dto.rs | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/backend/middlewares/flow/src/api/ci/flow_ci_inst_api.rs b/backend/middlewares/flow/src/api/ci/flow_ci_inst_api.rs index 43bff64d..95ed6511 100644 --- a/backend/middlewares/flow/src/api/ci/flow_ci_inst_api.rs +++ b/backend/middlewares/flow/src/api/ci/flow_ci_inst_api.rs @@ -1,6 +1,8 @@ use std::collections::HashMap; use bios_basic::rbum::helper::rbum_scope_helper::check_without_owner_and_unsafe_fill_ctx; +use itertools::Itertools; +use tardis::chrono::Utc; use tardis::log::debug; use tardis::serde_json::Value; use tardis::web::context_extractor::TardisContextExtractor; @@ -13,8 +15,7 @@ use tardis::{log, tokio}; use crate::dto::flow_external_dto::FlowExternalCallbackOp; use crate::dto::flow_inst_dto::{ - FlowInstAbortReq, FlowInstBatchBindReq, FlowInstBatchBindResp, FlowInstBindReq, FlowInstDetailResp, FlowInstFindStateAndTransitionsReq, FlowInstFindStateAndTransitionsResp, - FlowInstModifyAssignedReq, FlowInstModifyCurrentVarsReq, FlowInstStartReq, FlowInstTransferReq, FlowInstTransferResp, + FlowInstAbortReq, FlowInstBatchBindReq, FlowInstBatchBindResp, FlowInstBindReq, FlowInstDetailResp, FlowInstFindNextTransitionsReq, FlowInstFindStateAndTransitionsReq, FlowInstFindStateAndTransitionsResp, FlowInstModifyAssignedReq, FlowInstModifyCurrentVarsReq, FlowInstStartReq, FlowInstTransferReq, FlowInstTransferResp, FlowInstTransitionInfo, FlowOperationContext }; use crate::flow_constants; use crate::helper::loop_check_helper; @@ -46,7 +47,18 @@ impl FlowCiInstApi { async fn get(&self, flow_inst_id: Path, mut ctx: TardisContextExtractor, request: &Request) -> TardisApiResult { let funs = flow_constants::get_tardis_inst(); check_without_owner_and_unsafe_fill_ctx(request, &funs, &mut ctx.0)?; - let result = FlowInstServ::get(&flow_inst_id.0, &funs, &ctx.0).await?; + let mut result = FlowInstServ::get(&flow_inst_id.0, &funs, &ctx.0).await?; + // @TODO 临时处理方式,后续需增加接口 + result.transitions = Some( + FlowInstServ::find_next_transitions(&flow_inst_id.0, &FlowInstFindNextTransitionsReq { + vars: None, + }, &funs, &ctx.0).await?.into_iter().map(|tran| FlowInstTransitionInfo { + id: tran.next_flow_transition_id, + start_time: Utc::now(), + op_ctx: FlowOperationContext::default(), + output_message: Some(tran.next_flow_transition_name), + }).collect_vec() + ); ctx.0.execute_task().await?; TardisResp::ok(result) } diff --git a/backend/middlewares/flow/src/dto/flow_inst_dto.rs b/backend/middlewares/flow/src/dto/flow_inst_dto.rs index 637152df..deecd0e7 100644 --- a/backend/middlewares/flow/src/dto/flow_inst_dto.rs +++ b/backend/middlewares/flow/src/dto/flow_inst_dto.rs @@ -175,7 +175,7 @@ pub struct FlowInstTransitionInfo { } /// 操作上下文信息 -#[derive(Serialize, Deserialize, Clone, PartialEq, Debug, poem_openapi::Object, sea_orm::FromJsonQueryResult)] +#[derive(Serialize, Deserialize, Clone, PartialEq, Default, Debug, poem_openapi::Object, sea_orm::FromJsonQueryResult)] pub struct FlowOperationContext { pub own_paths: String, pub ak: String,