diff --git a/backend/middlewares/flow/src/api/ca/flow_ca_model_api.rs b/backend/middlewares/flow/src/api/ca/flow_ca_model_api.rs
index f4432e819..8b4fc3172 100644
--- a/backend/middlewares/flow/src/api/ca/flow_ca_model_api.rs
+++ b/backend/middlewares/flow/src/api/ca/flow_ca_model_api.rs
@@ -1,18 +1,14 @@
use std::collections::HashMap;
-use bios_basic::rbum::{helper::rbum_scope_helper, rbum_enumeration::RbumScopeLevelKind};
-use tardis::{
- basic::dto::TardisContext,
- web::{
- context_extractor::TardisContextExtractor,
- poem::{web::Json, Request},
- poem_openapi,
- web_resp::{TardisApiResult, TardisResp},
- },
+use tardis::web::{
+ context_extractor::TardisContextExtractor,
+ poem::{web::Json, Request},
+ poem_openapi,
+ web_resp::{TardisApiResult, TardisResp},
};
use crate::{
- dto::flow_model_dto::{FlowModelAggResp, FlowModelAssociativeOperationKind, FlowModelCopyOrReferenceReq, FlowModelSingleCopyOrReferenceReq},
+ dto::flow_model_dto::{FlowModelAggResp, FlowModelCopyOrReferenceReq, FlowModelKind, FlowModelSingleCopyOrReferenceReq},
flow_constants,
serv::{flow_inst_serv::FlowInstServ, flow_model_serv::FlowModelServ},
};
@@ -37,16 +33,18 @@ impl FlowCaModelApi {
funs.begin().await?;
let _orginal_models = FlowModelServ::clean_rel_models(None, None, None, &funs, &ctx.0).await?;
let mut result = HashMap::new();
- let mock_ctx = match req.0.op {
- FlowModelAssociativeOperationKind::Copy => ctx.0.clone(),
- FlowModelAssociativeOperationKind::Reference => TardisContext {
- own_paths: rbum_scope_helper::get_path_item(RbumScopeLevelKind::L1.to_int(), &ctx.0.own_paths).unwrap_or_default(),
- ..ctx.0.clone()
- },
- };
for (_, rel_model_id) in req.0.rel_model_ids {
- let new_model = FlowModelServ::copy_or_reference_model(&rel_model_id, Some(ctx.0.own_paths.clone()), &req.0.op, Some(false), &funs, &mock_ctx).await?;
- FlowInstServ::batch_update_when_switch_model(None, &new_model.tag, &new_model.id, new_model.states.clone(), &new_model.init_state_id, &funs, &ctx.0).await?;
+ let new_model = FlowModelServ::copy_or_reference_model(&rel_model_id, &req.0.op, FlowModelKind::AsModel, &funs, &ctx.0).await?;
+ FlowInstServ::batch_update_when_switch_model(
+ None,
+ &new_model.tag,
+ &new_model.current_version_id,
+ new_model.states.clone(),
+ &new_model.init_state_id,
+ &funs,
+ &ctx.0,
+ )
+ .await?;
result.insert(rel_model_id.clone(), new_model);
}
@@ -69,15 +67,17 @@ impl FlowCaModelApi {
let mut funs = flow_constants::get_tardis_inst();
funs.begin().await?;
let _orginal_models = FlowModelServ::clean_rel_models(None, None, Some(vec![req.0.tag.clone()]), &funs, &ctx.0).await?;
- let mock_ctx = match req.0.op {
- FlowModelAssociativeOperationKind::Copy => ctx.0.clone(),
- FlowModelAssociativeOperationKind::Reference => TardisContext {
- own_paths: rbum_scope_helper::get_path_item(RbumScopeLevelKind::L1.to_int(), &ctx.0.own_paths).unwrap_or_default(),
- ..ctx.0.clone()
- },
- };
- let new_model = FlowModelServ::copy_or_reference_model(&req.0.rel_model_id, Some(ctx.0.own_paths.clone()), &req.0.op, Some(false), &funs, &mock_ctx).await?;
- FlowInstServ::batch_update_when_switch_model(None, &new_model.tag, &new_model.id, new_model.states.clone(), &new_model.init_state_id, &funs, &ctx.0).await?;
+ let new_model = FlowModelServ::copy_or_reference_model(&req.0.rel_model_id, &req.0.op, FlowModelKind::AsModel, &funs, &ctx.0).await?;
+ FlowInstServ::batch_update_when_switch_model(
+ None,
+ &new_model.tag,
+ &new_model.current_version_id,
+ new_model.states.clone(),
+ &new_model.init_state_id,
+ &funs,
+ &ctx.0,
+ )
+ .await?;
funs.commit().await?;
ctx.0.execute_task().await?;
diff --git a/backend/middlewares/flow/src/api/cc.rs b/backend/middlewares/flow/src/api/cc.rs
index 883039a4a..16838ffc2 100644
--- a/backend/middlewares/flow/src/api/cc.rs
+++ b/backend/middlewares/flow/src/api/cc.rs
@@ -1,3 +1,4 @@
pub mod flow_cc_inst_api;
pub mod flow_cc_model_api;
+pub mod flow_cc_model_version_api;
pub mod flow_cc_state_api;
diff --git a/backend/middlewares/flow/src/api/cc/flow_cc_inst_api.rs b/backend/middlewares/flow/src/api/cc/flow_cc_inst_api.rs
index 9f3b0aa65..d54a3774a 100644
--- a/backend/middlewares/flow/src/api/cc/flow_cc_inst_api.rs
+++ b/backend/middlewares/flow/src/api/cc/flow_cc_inst_api.rs
@@ -66,6 +66,7 @@ impl FlowCcInstApi {
async fn paginate(
&self,
flow_model_id: Query