Skip to content

Commit 77a60db

Browse files
author
ljl
committed
Merge remote-tracking branch 'origin/main'
2 parents 1a99b48 + b6a30a5 commit 77a60db

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

middleware/flow/src/api/ci/flow_ci_inst_api.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use tardis::web::context_extractor::TardisContextExtractor;
2-
use tardis::web::poem::web::Query;
3-
use tardis::web::poem_openapi;
42
use tardis::web::poem_openapi::payload::Json;
3+
use tardis::web::poem_openapi::{self, param::Query};
54
use tardis::web::web_resp::{TardisApiResult, TardisResp, Void};
65
use tardis::{log, tokio};
76

@@ -53,18 +52,16 @@ impl FlowCiInstApi {
5352

5453
/// Get list of instance id by rel_business_obj_id / 通过业务ID获取实例信息
5554
#[oai(path = "/find_detail_by_obj_ids", method = "get")]
56-
async fn find_detail_by_obj_ids(&self, rel_business_obj_ids: Query<String>, ctx: TardisContextExtractor) -> TardisApiResult<Vec<FlowInstDetailResp>> {
57-
let mut funs = flow_constants::get_tardis_inst();
58-
let rel_business_obj_ids: Vec<_> = rel_business_obj_ids.split(',').map(|id| id.to_string()).collect();
59-
funs.begin().await?;
55+
async fn find_detail_by_obj_ids(&self, obj_ids: Query<String>, ctx: TardisContextExtractor) -> TardisApiResult<Vec<FlowInstDetailResp>> {
56+
let funs = flow_constants::get_tardis_inst();
57+
let rel_business_obj_ids: Vec<_> = obj_ids.0.split(',').map(|id| id.to_string()).collect();
6058
let inst_ids = FlowInstServ::get_inst_ids_by_rel_business_obj_id(rel_business_obj_ids, &funs, &ctx.0).await?;
6159
let mut result = vec![];
6260
for inst_id in inst_ids {
63-
if let Ok(inst_detail) = FlowInstServ::get(&inst_id, &funs, &ctx.0).await{
61+
if let Ok(inst_detail) = FlowInstServ::get(&inst_id, &funs, &ctx.0).await {
6462
result.push(inst_detail);
6563
}
6664
}
67-
funs.commit().await?;
6865
TardisResp::ok(result)
6966
}
7067

middleware/flow/tests/test_flow_scenes_fsm.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ pub async fn test(flow_client: &mut TestHttpClient, _kv_client: &mut TestHttpCli
578578
let ticket_inst_rel_id = "mock-ticket-obj-id".to_string();
579579
let iter_inst_rel_id1 = "mock-iter-obj-id1".to_string();
580580
let iter_inst_rel_id2 = "mock-iter-obj-id2".to_string();
581+
let req_inst_rel_id2 = "mock-req-obj-id2".to_string();
581582
let req_inst_id1: String = flow_client
582583
.post(
583584
"/cc/inst",
@@ -594,7 +595,7 @@ pub async fn test(flow_client: &mut TestHttpClient, _kv_client: &mut TestHttpCli
594595
&FlowInstStartReq {
595596
tag: "REQ".to_string(),
596597
create_vars: None,
597-
rel_business_obj_id: TardisFuns::field.nanoid(),
598+
rel_business_obj_id: req_inst_rel_id2.clone(),
598599
},
599600
)
600601
.await;
@@ -780,7 +781,7 @@ pub async fn test(flow_client: &mut TestHttpClient, _kv_client: &mut TestHttpCli
780781
)
781782
.await;
782783
let _: Void = flow_client.get("/ci/inst/trigger_front_action").await;
783-
tokio::time::sleep(tokio::time::Duration::from_secs(10)).await;
784+
tokio::time::sleep(tokio::time::Duration::from_secs(3)).await;
784785
let state_and_next_transitions: Vec<FlowInstFindStateAndTransitionsResp> = flow_client
785786
.put(
786787
"/cc/inst/batch/state_transitions",
@@ -791,5 +792,8 @@ pub async fn test(flow_client: &mut TestHttpClient, _kv_client: &mut TestHttpCli
791792
)
792793
.await;
793794
assert_eq!(state_and_next_transitions[0].current_flow_state_name, "已完成");
795+
let flow_inst_list: Vec<FlowInstDetailResp> = flow_client.get(&format!("/ci/inst/find_detail_by_obj_ids?obj_ids={}", req_inst_rel_id2)).await;
796+
assert_eq!(flow_inst_list[0].id, req_inst_id2);
797+
794798
Ok(())
795799
}

0 commit comments

Comments
 (0)