Skip to content

Commit 5bb5793

Browse files
authored
Merge pull request #532 from ZzIsGod1019/zz-flow-2.3
flow:update && fmt
2 parents 50825ab + f3e0bd8 commit 5bb5793

File tree

13 files changed

+117
-73
lines changed

13 files changed

+117
-73
lines changed

middleware/flow/src/domain/flow_transition.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ pub struct Model {
9595
/// TODO FlowTransitionDoubleCheckInfo
9696
pub double_check: Json,
9797

98+
pub is_notify: bool,
99+
98100
pub rel_flow_model_id: String,
99101

100102
pub sort: i64,

middleware/flow/src/dto/flow_external_dto.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use tardis::web::poem_openapi::{
55
types::{ParseFromJSON, ToJSON},
66
};
77

8-
use super::flow_state_dto::FlowSysStateKind;
8+
use super::{flow_state_dto::FlowSysStateKind, flow_transition_dto::FlowTransitionActionByVarChangeInfoChangedKind};
99

1010
#[derive(Serialize, Deserialize, Debug, Default, poem_openapi::Object)]
1111
pub struct FlowExternalReq {
@@ -38,6 +38,7 @@ pub struct FlowExternalParams {
3838
pub var_id: Option<String>,
3939
pub var_name: Option<String>,
4040
pub value: Option<Value>,
41+
pub changed_kind: Option<FlowTransitionActionByVarChangeInfoChangedKind>,
4142
}
4243

4344
#[derive(Default, Serialize, Deserialize, Debug, poem_openapi::Object)]

middleware/flow/src/dto/flow_transition_dto.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub struct FlowTransitionAddReq {
2929

3030
pub double_check: Option<FlowTransitionDoubleCheckInfo>,
3131
pub vars_collect: Option<Vec<FlowVarInfo>>,
32+
pub is_notify: Option<bool>,
3233

3334
pub action_by_pre_callback: Option<String>,
3435
pub action_by_post_callback: Option<String>,
@@ -62,6 +63,7 @@ pub struct FlowTransitionModifyReq {
6263

6364
pub vars_collect: Option<Vec<FlowVarInfo>>,
6465
pub double_check: Option<FlowTransitionDoubleCheckInfo>,
66+
pub is_notify: Option<bool>,
6567

6668
pub action_by_pre_callback: Option<String>,
6769
pub action_by_post_callback: Option<String>,
@@ -97,6 +99,7 @@ pub struct FlowTransitionDetailResp {
9799

98100
pub vars_collect: Value,
99101
pub double_check: Value,
102+
pub is_notify: bool,
100103

101104
pub action_by_pre_callback: String,
102105
pub action_by_post_callback: String,
@@ -175,6 +178,7 @@ impl From<FlowTransitionDetailResp> for FlowTransitionAddReq {
175178
action_by_post_changes: Some(action_by_post_changes),
176179
action_by_front_changes: Some(action_by_front_changes),
177180
double_check,
181+
is_notify: Some(value.is_notify),
178182
sort: Some(value.sort),
179183
}
180184
}
@@ -347,6 +351,7 @@ pub struct FlowTransitionInitInfo {
347351

348352
pub vars_collect: Option<Vec<FlowVarInfo>>,
349353
pub double_check: Option<FlowTransitionDoubleCheckInfo>,
354+
pub is_notify: bool,
350355

351356
pub action_by_pre_callback: Option<String>,
352357
pub action_by_post_callback: Option<String>,

middleware/flow/src/serv/flow_external_serv.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ use crate::{
1313
FlowExternalFetchRelObjResp, FlowExternalKind, FlowExternalModifyFieldResp, FlowExternalNotifyChangesResp, FlowExternalParams, FlowExternalQueryFieldResp,
1414
FlowExternalReq, FlowExternalResp,
1515
},
16-
flow_state_dto::FlowSysStateKind, flow_transition_dto::TagRelKind,
16+
flow_state_dto::FlowSysStateKind,
17+
flow_transition_dto::TagRelKind,
1718
},
1819
flow_config::FlowConfig,
1920
flow_constants,
@@ -45,6 +46,7 @@ impl FlowExternalServ {
4546
var_id: None,
4647
var_name: None,
4748
value: None,
49+
changed_kind: None,
4850
})
4951
.collect_vec(),
5052
..Default::default()

middleware/flow/src/serv/flow_inst_serv.rs

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ impl FlowInstServ {
398398
transitions: inst.transitions.map(|transitions| TardisFuns::json.json_to_obj(transitions).unwrap()),
399399
current_state_id: inst.current_state_id,
400400
current_state_name: inst.current_state_name,
401-
current_state_color:inst.current_state_color,
401+
current_state_color: inst.current_state_color,
402402
current_assigned: inst.current_assigned,
403403
current_vars: inst.current_vars.map(|current_vars| TardisFuns::json.json_to_obj(current_vars).unwrap()),
404404
rel_business_obj_id: inst.rel_business_obj_id,
@@ -712,6 +712,7 @@ impl FlowInstServ {
712712
var_name: Some(var_name.clone()),
713713
var_id: None,
714714
value: Some(value.clone()),
715+
changed_kind: None,
715716
});
716717
}
717718
if !params.is_empty() {
@@ -842,19 +843,19 @@ impl FlowInstServ {
842843
if let Some(mut change_info) = post_change.var_change_info {
843844
if change_info.changed_kind.is_some() && change_info.changed_kind.clone().unwrap() == FlowTransitionActionByVarChangeInfoChangedKind::AutoGetOperateTime {
844845
change_info.changed_val = Some(json!(Utc::now().to_rfc3339_opts(SecondsFormat::Millis, true)));
845-
}
846-
if change_info.changed_kind.is_some() && change_info.changed_kind.clone().unwrap() == FlowTransitionActionByVarChangeInfoChangedKind::SelectField {
847-
let field_key = change_info.changed_val.clone().unwrap_or_default().as_str().unwrap_or_default().to_string();
848-
if let Some(current_val) = current_inst.current_vars.clone().unwrap_or_default().get(field_key.as_str()) {
849-
change_info.changed_val = Some(current_val.clone());
850-
} else {
851-
change_info.changed_val = None;
852-
}
846+
change_info.changed_kind = Some(FlowTransitionActionByVarChangeInfoChangedKind::ChangeContent);
853847
}
854848
let rel_tag = change_info.obj_tag.unwrap_or_default();
855849
if !rel_tag.is_empty() {
856-
let mut resp =
857-
FlowExternalServ::do_fetch_rel_obj(&current_model.tag, &current_inst.id, &current_inst.rel_business_obj_id, vec![(rel_tag.clone(), change_info.obj_tag_rel_kind.clone())], ctx, funs).await?;
850+
let mut resp = FlowExternalServ::do_fetch_rel_obj(
851+
&current_model.tag,
852+
&current_inst.id,
853+
&current_inst.rel_business_obj_id,
854+
vec![(rel_tag.clone(), change_info.obj_tag_rel_kind.clone())],
855+
ctx,
856+
funs,
857+
)
858+
.await?;
858859
if !resp.rel_bus_objs.is_empty() {
859860
for rel_bus_obj_id in resp.rel_bus_objs.pop().unwrap().rel_bus_obj_ids {
860861
let inst_id = Self::get_inst_ids_by_rel_business_obj_id(vec![rel_bus_obj_id.clone()], funs, ctx).await?.pop().unwrap_or_default();
@@ -872,6 +873,7 @@ impl FlowInstServ {
872873
var_id: None,
873874
var_name: Some(change_info.var_name.clone()),
874875
value: change_info.changed_val.clone(),
876+
changed_kind: change_info.changed_kind.clone(),
875877
}],
876878
ctx,
877879
funs,
@@ -895,6 +897,7 @@ impl FlowInstServ {
895897
var_id: None,
896898
var_name: Some(change_info.var_name.clone()),
897899
value: change_info.changed_val.clone(),
900+
changed_kind: change_info.changed_kind,
898901
}],
899902
ctx,
900903
funs,
@@ -906,8 +909,15 @@ impl FlowInstServ {
906909
}
907910
FlowTransitionActionChangeKind::State => {
908911
if let Some(change_info) = post_change.state_change_info {
909-
let mut resp =
910-
FlowExternalServ::do_fetch_rel_obj(&current_model.tag, &current_inst.id, &current_inst.rel_business_obj_id, vec![(change_info.obj_tag.clone(), change_info.obj_tag_rel_kind.clone())], ctx, funs).await?;
912+
let mut resp = FlowExternalServ::do_fetch_rel_obj(
913+
&current_model.tag,
914+
&current_inst.id,
915+
&current_inst.rel_business_obj_id,
916+
vec![(change_info.obj_tag.clone(), change_info.obj_tag_rel_kind.clone())],
917+
ctx,
918+
funs,
919+
)
920+
.await?;
911921
if !resp.rel_bus_objs.is_empty() {
912922
let inst_ids = Self::find_inst_ids_by_rel_obj_ids(resp.rel_bus_objs.pop().unwrap().rel_bus_obj_ids, &change_info, funs, ctx).await?;
913923
Self::do_modify_state_by_post_action(inst_ids, &change_info, updated_instance_list, funs, ctx).await?;

middleware/flow/src/serv/flow_model_serv.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ impl FlowModelServ {
342342
action_by_post_changes: Some(transition.action_by_post_changes),
343343
action_by_front_changes: Some(transition.action_by_front_changes),
344344
double_check: transition.double_check,
345+
is_notify: Some(true),
345346
sort: transition.sort,
346347
});
347348
}
@@ -383,6 +384,7 @@ impl FlowModelServ {
383384

384385
vars_collect: Set(req.vars_collect.as_ref().map(|vars| TardisFuns::json.obj_to_json(vars).unwrap()).unwrap_or(json!([]))),
385386
double_check: Set(TardisFuns::json.obj_to_json(&req.double_check).unwrap_or(json!(FlowTransitionDoubleCheckInfo::default()))),
387+
is_notify: Set(req.is_notify.unwrap_or(true)),
386388

387389
action_by_pre_callback: Set(req.action_by_pre_callback.as_ref().unwrap_or(&"".to_string()).to_string()),
388390
action_by_post_callback: Set(req.action_by_post_callback.as_ref().unwrap_or(&"".to_string()).to_string()),
@@ -511,6 +513,9 @@ impl FlowModelServ {
511513
if let Some(double_check) = &req.double_check {
512514
flow_transition.double_check = Set(TardisFuns::json.obj_to_json(double_check)?);
513515
}
516+
if let Some(is_notify) = &req.is_notify {
517+
flow_transition.is_notify = Set(*is_notify);
518+
}
514519
if let Some(sort) = &req.sort {
515520
flow_transition.sort = Set(*sort);
516521
}
@@ -577,6 +582,7 @@ impl FlowModelServ {
577582
(flow_transition::Entity, flow_transition::Column::ActionByPostChanges),
578583
(flow_transition::Entity, flow_transition::Column::ActionByFrontChanges),
579584
(flow_transition::Entity, flow_transition::Column::DoubleCheck),
585+
(flow_transition::Entity, flow_transition::Column::IsNotify),
580586
(flow_transition::Entity, flow_transition::Column::RelFlowModelId),
581587
(flow_transition::Entity, flow_transition::Column::Sort),
582588
])
@@ -1148,6 +1154,7 @@ impl FlowModelServ {
11481154
guard_by_other_conds: None,
11491155
vars_collect: None,
11501156
double_check: None,
1157+
is_notify: None,
11511158
action_by_pre_callback: None,
11521159
action_by_post_callback: None,
11531160
action_by_post_changes: None,

middleware/flow/tests/test_flow_scenes_fsm.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ pub async fn test(flow_client: &mut TestHttpClient) -> TardisResult<()> {
244244
is_open: true,
245245
content: Some("再次确认该操作生效".to_string()),
246246
}),
247+
is_notify: None,
247248
action_by_front_changes: None,
248249
sort: None,
249250
},
@@ -294,6 +295,7 @@ pub async fn test(flow_client: &mut TestHttpClient) -> TardisResult<()> {
294295
},
295296
]),
296297
double_check: None,
298+
is_notify: None,
297299
sort: None,
298300
},
299301
FlowTransitionModifyReq {
@@ -316,6 +318,7 @@ pub async fn test(flow_client: &mut TestHttpClient) -> TardisResult<()> {
316318
action_by_post_changes: None,
317319
action_by_front_changes: None,
318320
double_check: None,
321+
is_notify: None,
319322
sort: None,
320323
},
321324
]),
@@ -378,6 +381,7 @@ pub async fn test(flow_client: &mut TestHttpClient) -> TardisResult<()> {
378381
changed_kind: None,
379382
}]),
380383
double_check: None,
384+
is_notify: None,
381385
sort: None,
382386
}]),
383387
..Default::default()
@@ -422,6 +426,7 @@ pub async fn test(flow_client: &mut TestHttpClient) -> TardisResult<()> {
422426
changed_kind: None,
423427
}]),
424428
double_check: None,
429+
is_notify: None,
425430
sort: None,
426431
}]),
427432
..Default::default()

spi/spi-kv/src/serv/kv_item_serv.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
use tardis::{TardisFuns, TardisFunsInst};
21
use tardis::basic::dto::TardisContext;
32
use tardis::basic::result::TardisResult;
43
use tardis::serde_json::json;
54
use tardis::web::web_resp::TardisPage;
5+
use tardis::{TardisFuns, TardisFunsInst};
66

77
use bios_basic::spi::spi_constants;
88
use bios_basic::spi::spi_funs::SpiBsInstExtractor;
99
use bios_basic::spi_dispatch_service;
1010

11-
use crate::{kv_constants, kv_initializer};
1211
use crate::dto::kv_item_dto::{
1312
KvItemAddOrModifyReq, KvItemDetailResp, KvItemMatchReq, KvItemSummaryResp, KvNameAddOrModifyReq, KvNameFindResp, KvTagAddOrModifyReq, KvTagFindResp,
1413
};
14+
use crate::{kv_constants, kv_initializer};
1515

1616
use super::pg;
1717

@@ -83,20 +83,11 @@ pub async fn add_or_modify_tag(add_or_modify_req: &mut KvTagAddOrModifyReq, funs
8383
}
8484

8585
pub async fn find_tags(keys: Vec<String>, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<Vec<KvTagFindResp>> {
86-
let keys= keys.iter().map(|r|format!("{}{}", kv_constants::KEY_PREFIX_BY_TAG, r)).collect::<Vec<_>>();
86+
let keys = keys.iter().map(|r| format!("{}{}", kv_constants::KEY_PREFIX_BY_TAG, r)).collect::<Vec<_>>();
8787
let inst = funs.init(ctx, true, kv_initializer::init_fun).await?;
8888
match inst.kind_code() {
8989
#[cfg(feature = "spi-pg")]
90-
spi_constants::SPI_PG_KIND_CODE => {
91-
pg::kv_pg_item_serv::find_items(
92-
keys,
93-
None,
94-
funs,
95-
ctx,
96-
&inst,
97-
)
98-
.await
99-
}
90+
spi_constants::SPI_PG_KIND_CODE => pg::kv_pg_item_serv::find_items(keys, None, funs, ctx, &inst).await,
10091
kind_code => Err(funs.bs_not_implemented(kind_code)),
10192
}
10293
.and_then(|items| {

spi/spi-plugin/src/serv/plugin_api_serv.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl RbumItemCrudOperation<plugin_api::ActiveModel, PluginApiAddOrModifyReq, Plu
9494

9595
async fn package_ext_modify(id: &str, modify_req: &PluginApiAddOrModifyReq, _: &TardisFunsInst, _: &TardisContext) -> TardisResult<Option<plugin_api::ActiveModel>> {
9696
let plugin_api = plugin_api::ActiveModel {
97-
id:Set(id.to_string()),
97+
id: Set(id.to_string()),
9898
callback: Set(modify_req.callback.clone()),
9999
content_type: Set(modify_req.content_type.clone()),
100100
timeout: Set(modify_req.timeout),
@@ -155,14 +155,21 @@ impl PluginApiServ {
155155
}
156156

157157
pub async fn delete_by_kind(kind_id: &str, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<()> {
158-
let api_ids = Self::find_id_items(&PluginApiFilterReq {
159-
basic: RbumBasicFilterReq {
160-
with_sub_own_paths: true,
161-
rbum_kind_id: Some(kind_id.to_string()),
158+
let api_ids = Self::find_id_items(
159+
&PluginApiFilterReq {
160+
basic: RbumBasicFilterReq {
161+
with_sub_own_paths: true,
162+
rbum_kind_id: Some(kind_id.to_string()),
163+
..Default::default()
164+
},
162165
..Default::default()
163166
},
164-
..Default::default()
165-
},None,None,funs,ctx).await?;
167+
None,
168+
None,
169+
funs,
170+
ctx,
171+
)
172+
.await?;
166173
for api_id in api_ids {
167174
Self::delete_item(&api_id, funs, ctx).await?;
168175
}

0 commit comments

Comments
 (0)