Skip to content

Commit 64497a8

Browse files
authored
flow:Improve code comments (#732)
1 parent 6e01d3c commit 64497a8

File tree

12 files changed

+502
-142
lines changed

12 files changed

+502
-142
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ run_script = { version = "0.10" }
6060
testcontainers-modules = { version = "0.3", features = ["redis"] }
6161
strum = { version = "0.26", features = ["derive"] }
6262
# tardis
63-
tardis = { version = "0.1.0-rc.15" }
63+
# tardis = { version = "0.1.0-rc.15" }
6464
# tardis = { path = "../tardis/tardis" }
65-
# tardis = { git = "https://github.com/ideal-world/tardis.git", rev = "694ff92" }
65+
tardis = { git = "https://github.com/ideal-world/tardis.git", rev = "9c18c2a" }
6666
#spacegate
6767

6868
# spacegate-kernel = { git = "https://github.com/ideal-world/spacegate.git", rev = "f37a81a", features = [

backend/middlewares/flow/src/api/cc/flow_cc_model_api.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use tardis::web::web_resp::{TardisApiResult, TardisPage, TardisResp, Void};
1212

1313
use crate::dto::flow_model_dto::{
1414
FlowModelAddCustomModelReq, FlowModelAddCustomModelResp, FlowModelAddReq, FlowModelAggResp, FlowModelBindStateReq, FlowModelFilterReq, FlowModelFindRelStateResp,
15-
FlowModelModifyReq, FlowModelSortStatesReq, FlowModelSummaryResp, FlowModelUnbindStateReq, FlowTemplateModelResp,
15+
FlowModelModifyReq, FlowModelSortStatesReq, FlowModelSummaryResp, FlowModelUnbindStateReq,
1616
};
1717
use crate::dto::flow_state_dto::FlowStateRelModelModifyReq;
1818
use crate::dto::flow_transition_dto::{FlowTransitionModifyReq, FlowTransitionSortStatesReq};
@@ -101,9 +101,9 @@ impl FlowCcModelApi {
101101
TardisResp::ok(result)
102102
}
103103

104-
/// Find the specified models, or add it if it doesn't exist.
104+
/// Find the specified models, or create it if it doesn't exist.
105105
///
106-
/// 查找指定model,如果不存在则新增
106+
/// 查找指定model,如果不存在则创建。创建规则遵循add_custom_model接口逻辑。
107107
///
108108
/// # Parameters
109109
/// - `tag_ids` - list of tag_id
@@ -117,10 +117,10 @@ impl FlowCcModelApi {
117117
is_shared: Query<Option<bool>>,
118118
ctx: TardisContextExtractor,
119119
_request: &Request,
120-
) -> TardisApiResult<HashMap<String, FlowTemplateModelResp>> {
120+
) -> TardisApiResult<HashMap<String, FlowModelSummaryResp>> {
121121
let mut funs = flow_constants::get_tardis_inst();
122122
funs.begin().await?;
123-
let tag_ids: Vec<_> = tag_ids.split(',').collect();
123+
let tag_ids= tag_ids.split(',').map(|tag_id| tag_id.to_string()).collect_vec();
124124
let result = FlowModelServ::find_or_add_models(tag_ids, temp_id.0, is_shared.unwrap_or(false), &funs, &ctx.0).await?;
125125
funs.commit().await?;
126126
TardisResp::ok(result)
@@ -255,6 +255,7 @@ impl FlowCcModelApi {
255255
/// copy parent model to current own_paths
256256
///
257257
/// 复制父级模型到当前 own_paths
258+
/// 实际创建规则:按照 tags 创建模型,若传入proj_template_id,则优先寻找对应的父级模型,否则则获取默认模板模型生成对应的自定义模型。
258259
#[oai(path = "/add_custom_model", method = "post")]
259260
async fn add_custom_model(&self, req: Json<FlowModelAddCustomModelReq>, ctx: TardisContextExtractor, _request: &Request) -> TardisApiResult<Vec<FlowModelAddCustomModelResp>> {
260261
let mut funs = flow_constants::get_tardis_inst();

backend/middlewares/flow/src/domain/flow_transition.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use tardis::db::sea_orm::prelude::Json;
44
use tardis::db::sea_orm::*;
55
use tardis::{chrono, TardisCreateEntity, TardisEmptyBehavior, TardisEmptyRelation};
66

7-
use crate::dto::flow_transition_dto::{FlowTransitionActionChangeInfo, FlowTransitionDoubleCheckInfo, FlowTransitionFrontActionInfo};
7+
use crate::dto::flow_transition_dto::{FlowTransitionPostActionInfo, FlowTransitionDoubleCheckInfo, FlowTransitionFrontActionInfo};
88
use crate::dto::flow_var_dto::FlowVarInfo;
99

1010
/// Transfer / 流转
@@ -91,7 +91,7 @@ pub struct Model {
9191

9292
#[sea_orm(column_type = "Json")]
9393
#[tardis_entity(custom_type = "Json")]
94-
pub action_by_post_changes: Vec<FlowTransitionActionChangeInfo>,
94+
pub action_by_post_changes: Vec<FlowTransitionPostActionInfo>,
9595

9696
#[sea_orm(column_type = "Json")]
9797
#[tardis_entity(custom_type = "Json")]

backend/middlewares/flow/src/dto/flow_external_dto.rs

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,18 @@ use tardis::web::poem_openapi::{
77

88
use super::{flow_state_dto::FlowSysStateKind, flow_transition_dto::FlowTransitionActionByVarChangeInfoChangedKind};
99

10+
/// External data exchange requests
11+
///
12+
/// 对外数据交换请求
1013
#[derive(Serialize, Deserialize, Debug, Default, poem_openapi::Object)]
1114
pub struct FlowExternalReq {
12-
/// Type of request initiated, ex: query field, modification field, status change notification...
15+
/// Associated [enum](FlowExternalKind)
1316
///
14-
/// 发起请求的类型,例:查询字段,修改字段,状态变更通知..
17+
/// 关联的[枚举](FlowExternalKind)
1518
pub kind: FlowExternalKind,
16-
/// When kind is ModifyField, the field is modified in a specific way, for example: validate the content, post action, precondition trigger ...
19+
/// Associated [enum](FlowExternalCallbackOp)
1720
///
18-
/// 当 kind 为 ModifyField 时,字段被修改的具体操作方式,例:验证内容,后置动作,前置条件触发..
21+
/// 关联的[枚举](FlowExternalCallbackOp)
1922
pub callback_op: Option<FlowExternalCallbackOp>,
2023
/// The tag corresponding to the current business
2124
///
@@ -25,25 +28,25 @@ pub struct FlowExternalReq {
2528
///
2629
/// 当前业务ID
2730
pub curr_bus_obj_id: String,
28-
/// Workflow Instance ID
31+
/// Associated [flow_instance](super::flow_inst_dto::FlowInstDetailResp) id
2932
///
30-
/// 工作流实例ID
33+
/// 关联的[工作流实例](super::flow_inst_dto::FlowInstDetailResp) id
3134
pub inst_id: String,
3235
/// Modified State ID
3336
///
3437
/// 修改后的状态ID
3538
pub target_state: Option<String>,
36-
/// Modified state type
39+
/// Associated [enum](super::flow_state_dto::FlowSysStateKind)
3740
///
38-
/// 修改后的状态类型
41+
/// 关联的[枚举](super::flow_state_dto::FlowSysStateKind)
3942
pub target_sys_state: Option<FlowSysStateKind>,
4043
/// Status ID before modification
4144
///
4245
/// 修改前的状态ID
4346
pub original_state: Option<String>,
44-
/// Type of state before modification
47+
/// Associated [enum](super::flow_state_dto::FlowSysStateKind)
4548
///
46-
/// 修改前的状态类型
49+
/// 关联的[枚举](super::flow_state_dto::FlowSysStateKind)
4750
pub original_sys_state: Option<FlowSysStateKind>,
4851
/// Name of the action actually triggered (business side logging operation)
4952
///
@@ -64,31 +67,53 @@ pub struct FlowExternalReq {
6467
pub params: Vec<FlowExternalParams>,
6568
}
6669

70+
/// Type of request initiated, ex: query field, modification field, status change notification...
71+
///
72+
/// 发起请求的类型,例:查询字段,修改字段,状态变更通知..
6773
#[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize, poem_openapi::Enum)]
6874
pub enum FlowExternalKind {
6975
#[default]
76+
/// 获取关联业务对象
7077
FetchRelObj,
78+
/// 修改字段
7179
ModifyField,
80+
/// 状态变更通知
7281
NotifyChanges,
82+
/// 查询字段值
7383
QueryField,
7484
}
7585

86+
/// When kind is ModifyField, the field is modified in a specific way, for example: validate the content, post action, precondition trigger ...
87+
///
88+
/// 当 kind 为 ModifyField 时,字段被修改的具体操作方式,例:验证内容,后置动作,前置条件触发..
7689
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize, poem_openapi::Enum)]
7790
pub enum FlowExternalCallbackOp {
7891
#[default]
7992
Default,
93+
/// 后置动作
8094
PostAction,
95+
/// 验证内容
8196
VerifyContent,
97+
/// 条件触发
8298
ConditionalTrigger,
8399
}
84100

101+
/// 扩展字段
102+
///
103+
/// Extended params
85104
#[derive(Debug, Deserialize, Serialize, poem_openapi::Object, Clone)]
86105
pub struct FlowExternalParams {
106+
/// 关联的 Tag
87107
pub rel_tag: Option<String>,
108+
/// 关联类型 TagRelKind
88109
pub rel_kind: Option<String>,
110+
/// 字段ID
89111
pub var_id: Option<String>,
112+
/// 字段名
90113
pub var_name: Option<String>,
114+
/// 修改成的值
91115
pub value: Option<Value>,
116+
/// 修改方式
92117
pub changed_kind: Option<FlowTransitionActionByVarChangeInfoChangedKind>,
93118
}
94119

@@ -104,14 +129,19 @@ where
104129

105130
#[derive(Default, Serialize, Deserialize, Debug, poem_openapi::Object)]
106131
pub struct FlowExternalFetchRelObjResp {
132+
/// 当前Tag
107133
pub curr_tag: String,
134+
/// 当前业务ID
108135
pub curr_bus_obj_id: String,
136+
/// 关联业务对象
109137
pub rel_bus_objs: Vec<RelBusObjResp>,
110138
}
111139

112140
#[derive(Default, Serialize, Deserialize, Debug, poem_openapi::Object)]
113141
pub struct RelBusObjResp {
142+
/// 关联对象的Tag
114143
pub rel_tag: String,
144+
/// 关联业务对象ID
115145
pub rel_bus_obj_ids: Vec<String>,
116146
}
117147

0 commit comments

Comments
 (0)