Skip to content

Commit

Permalink
flow: merge state by same name (#759)
Browse files Browse the repository at this point in the history
* flow: merge state by same name

* update
  • Loading branch information
ZzIsGod1019 authored Jun 27, 2024
1 parent 8a2cea3 commit 984c4b6
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 23 deletions.
10 changes: 10 additions & 0 deletions backend/middlewares/flow/src/api/cc/flow_cc_inst_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub struct FlowCcInstApi;
#[poem_openapi::OpenApi(prefix_path = "/cc/inst")]
impl FlowCcInstApi {
/// Start Instance(Return Instance ID)
///
/// 启动实例(返回实例ID)
#[oai(path = "/", method = "post")]
async fn start(&self, add_req: Json<FlowInstStartReq>, ctx: TardisContextExtractor, _request: &Request) -> TardisApiResult<String> {
Expand All @@ -34,6 +35,7 @@ impl FlowCcInstApi {
}

/// Abort Instance
///
/// 终止实例
#[oai(path = "/:flow_inst_id", method = "put")]
async fn abort(&self, flow_inst_id: Path<String>, abort_req: Json<FlowInstAbortReq>, ctx: TardisContextExtractor, _request: &Request) -> TardisApiResult<Void> {
Expand All @@ -46,6 +48,7 @@ impl FlowCcInstApi {
}

/// Get Instance By Instance Id
///
/// 获取实例信息
#[oai(path = "/:flow_inst_id", method = "get")]
async fn get(&self, flow_inst_id: Path<String>, ctx: TardisContextExtractor, _request: &Request) -> TardisApiResult<FlowInstDetailResp> {
Expand All @@ -56,6 +59,7 @@ impl FlowCcInstApi {
}

/// Find Instances
///
/// 获取实例列表
#[oai(path = "/", method = "get")]
async fn paginate(
Expand All @@ -77,6 +81,7 @@ impl FlowCcInstApi {
}

/// Find Next Transitions
///
/// 获取下一个流转状态列表
#[oai(path = "/:flow_inst_id/transition/next", method = "put")]
async fn find_next_transitions(
Expand All @@ -93,6 +98,7 @@ impl FlowCcInstApi {
}

/// Find the state and transfer information of the specified model in batch
///
/// 批量获取指定模型的状态及流转信息
#[oai(path = "/batch/state_transitions", method = "put")]
async fn find_state_and_next_transitions(
Expand All @@ -108,6 +114,7 @@ impl FlowCcInstApi {
}

/// Transfer State By Transaction Id
///
/// 通过动作ID流转状态
#[oai(path = "/:flow_inst_id/transition/transfer", method = "put")]
async fn transfer(
Expand All @@ -126,6 +133,7 @@ impl FlowCcInstApi {
}

/// Batch transfer State By Transaction Id
///
/// 批量流转
#[oai(path = "/batch/:flow_inst_ids/transition/transfer", method = "put")]
async fn batch_transfer(
Expand Down Expand Up @@ -153,6 +161,7 @@ impl FlowCcInstApi {
}

/// Modify Assigned [Deprecated]
///
/// 同步执行人信息 [已废弃]
#[oai(path = "/:flow_inst_id/transition/modify_assigned", method = "post")]
async fn modify_assigned(
Expand All @@ -169,6 +178,7 @@ impl FlowCcInstApi {
}

/// Modify list of variables
///
/// 同步当前变量列表
#[oai(path = "/:flow_inst_id/modify_current_vars", method = "patch")]
async fn modify_current_vars(
Expand Down
22 changes: 17 additions & 5 deletions backend/middlewares/flow/src/api/cc/flow_cc_state_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ pub struct FlowCcStateApi;
/// Flow state process API
#[poem_openapi::OpenApi(prefix_path = "/cc/state")]
impl FlowCcStateApi {
/// Add State / 添加状态
/// Add State
///
/// 添加状态
#[oai(path = "/", method = "post")]
async fn add(&self, mut add_req: Json<FlowStateAddReq>, ctx: TardisContextExtractor, _request: &Request) -> TardisApiResult<String> {
let mut funs = flow_constants::get_tardis_inst();
Expand All @@ -32,7 +34,9 @@ impl FlowCcStateApi {
TardisResp::ok(result)
}

/// Modify State By State Id / 修改状态
/// Modify State By State Id
///
/// 修改状态
#[oai(path = "/:id", method = "patch")]
async fn modify(&self, id: Path<String>, mut modify_req: Json<FlowStateModifyReq>, ctx: TardisContextExtractor, _request: &Request) -> TardisApiResult<Void> {
let mut funs = flow_constants::get_tardis_inst();
Expand All @@ -43,7 +47,9 @@ impl FlowCcStateApi {
TardisResp::ok(Void {})
}

/// Get State By State Id / 获取状态
/// Get State By State Id
///
/// 获取状态
#[oai(path = "/:id", method = "get")]
async fn get(&self, id: Path<String>, ctx: TardisContextExtractor, _request: &Request) -> TardisApiResult<FlowStateDetailResp> {
let funs = flow_constants::get_tardis_inst();
Expand All @@ -64,7 +70,9 @@ impl FlowCcStateApi {
TardisResp::ok(result)
}

/// Find States / 获取状态列表
/// Find States
///
/// 获取状态列表
#[oai(path = "/", method = "get")]
#[allow(clippy::too_many_arguments)]
async fn paginate(
Expand Down Expand Up @@ -144,6 +152,8 @@ impl FlowCcStateApi {
}

/// Find Names By id set
///
/// 通过id查找名称集合
#[oai(path = "/names", method = "get")]
async fn find_names(
&self,
Expand All @@ -166,7 +176,9 @@ impl FlowCcStateApi {
TardisResp::ok(resp)
}

/// Count Group By State / 按状态分组统计
/// Count Group By State
///
/// 按状态分组统计
#[oai(path = "/count_group_by_state", method = "post")]
async fn count_group_by_state(
&self,
Expand Down
48 changes: 36 additions & 12 deletions backend/middlewares/flow/src/api/ci/flow_ci_inst_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ pub struct FlowCiInstApi;
/// Flow Config process API
#[poem_openapi::OpenApi(prefix_path = "/ci/inst")]
impl FlowCiInstApi {
/// Start Instance / 启动实例
/// Start Instance
///
/// 启动实例
#[oai(path = "/", method = "post")]
async fn start(&self, add_req: Json<FlowInstStartReq>, mut ctx: TardisContextExtractor, request: &Request) -> TardisApiResult<String> {
let mut funs = flow_constants::get_tardis_inst();
Expand All @@ -36,7 +38,9 @@ impl FlowCiInstApi {
TardisResp::ok(result)
}

/// Get Instance By Instance Id / 获取实例信息
/// Get Instance By Instance Id
///
/// 获取实例信息
#[oai(path = "/:flow_inst_id", method = "get")]
async fn get(&self, flow_inst_id: Path<String>, mut ctx: TardisContextExtractor, request: &Request) -> TardisApiResult<FlowInstDetailResp> {
let funs = flow_constants::get_tardis_inst();
Expand All @@ -46,7 +50,9 @@ impl FlowCiInstApi {
TardisResp::ok(result)
}

/// Find the state and transfer information of the specified model in batch / 批量获取指定模型的状态及流转信息
/// Find the state and transfer information of the specified model in batch
///
/// 批量获取指定模型的状态及流转信息
#[oai(path = "/batch/state_transitions", method = "put")]
async fn find_state_and_next_transitions(
&self,
Expand All @@ -61,7 +67,9 @@ impl FlowCiInstApi {
TardisResp::ok(result)
}

/// Abort Instance / 中止实例
/// Abort Instance
///
/// 中止实例
#[oai(path = "/:flow_inst_id", method = "put")]
async fn abort(&self, flow_inst_id: Path<String>, abort_req: Json<FlowInstAbortReq>, mut ctx: TardisContextExtractor, request: &Request) -> TardisApiResult<Void> {
let mut funs = flow_constants::get_tardis_inst();
Expand All @@ -73,7 +81,9 @@ impl FlowCiInstApi {
TardisResp::ok(Void {})
}

/// Transfer State By State Id / 流转
/// Transfer State By State Id
///
/// 流转
#[oai(path = "/:flow_inst_id/transition/transfer", method = "put")]
async fn transfer(
&self,
Expand All @@ -91,7 +101,9 @@ impl FlowCiInstApi {
TardisResp::ok(result)
}

/// Batch transfer State By State Id / 批量流转
/// Batch transfer State By State Id
///
/// 批量流转
#[oai(path = "/batch/:flow_inst_ids/transition/transfer", method = "put")]
async fn batch_transfer(
&self,
Expand Down Expand Up @@ -119,7 +131,9 @@ impl FlowCiInstApi {
TardisResp::ok(result)
}

/// Modify Assigned / 同步执行人信息
/// Modify Assigned
///
/// 同步执行人信息
#[oai(path = "/:flow_inst_id/transition/modify_assigned", method = "post")]
async fn modify_assigned(
&self,
Expand All @@ -136,7 +150,9 @@ impl FlowCiInstApi {
TardisResp::ok(Void {})
}

/// Modify list of variables / 同步当前变量列表
/// Modify list of variables
///
/// 同步当前变量列表
#[oai(path = "/:flow_inst_id/modify_current_vars", method = "patch")]
async fn modify_current_vars(
&self,
Expand All @@ -152,7 +168,9 @@ impl FlowCiInstApi {
TardisResp::ok(Void {})
}

/// Bind Single Instance / 绑定单个实例
/// Bind Single Instance
///
/// 绑定单个实例
#[oai(path = "/bind", method = "post")]
async fn bind(&self, add_req: Json<FlowInstBindReq>, mut ctx: TardisContextExtractor, request: &Request) -> TardisApiResult<String> {
let mut funs = flow_constants::get_tardis_inst();
Expand Down Expand Up @@ -180,7 +198,9 @@ impl FlowCiInstApi {
TardisResp::ok(result)
}

/// Batch Bind Instance / 批量绑定实例 (初始化)
/// Batch Bind Instance
///
/// 批量绑定实例 (初始化)
#[oai(path = "/batch_bind", method = "post")]
async fn batch_bind(&self, add_req: Json<FlowInstBatchBindReq>, mut ctx: TardisContextExtractor, request: &Request) -> TardisApiResult<Vec<FlowInstBatchBindResp>> {
let mut funs = flow_constants::get_tardis_inst();
Expand All @@ -192,7 +212,9 @@ impl FlowCiInstApi {
TardisResp::ok(result)
}

/// Get list of instance id by rel_business_obj_id / 通过业务ID获取实例信息
/// Get list of instance id by rel_business_obj_id
///
/// 通过业务ID获取实例信息
#[oai(path = "/find_detail_by_obj_ids", method = "get")]
async fn find_detail_by_obj_ids(&self, obj_ids: Query<String>, mut ctx: TardisContextExtractor, request: &Request) -> TardisApiResult<Vec<FlowInstDetailResp>> {
let funs = flow_constants::get_tardis_inst();
Expand All @@ -209,7 +231,9 @@ impl FlowCiInstApi {
TardisResp::ok(result)
}

/// trigger instance front action / 触发前置动作
/// trigger instance front action
///
/// 触发前置动作
#[oai(path = "/trigger_front_action", method = "get")]
async fn trigger_front_action(&self) -> TardisApiResult<Void> {
let funs = flow_constants::get_tardis_inst();
Expand Down
8 changes: 6 additions & 2 deletions backend/middlewares/flow/src/api/ci/flow_ci_state_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ pub struct FlowCiStateApi;
/// Flow Config process API
#[poem_openapi::OpenApi(prefix_path = "/ci/state")]
impl FlowCiStateApi {
/// Find States / 获取状态列表
/// Find States
///
/// 获取状态列表
#[oai(path = "/", method = "get")]
#[allow(clippy::too_many_arguments)]
async fn paginate(
Expand Down Expand Up @@ -83,7 +85,9 @@ impl FlowCiStateApi {
TardisResp::ok(result)
}

/// Count Group By State / 按状态分组统计
/// Count Group By State
///
/// 按状态分组统计
#[oai(path = "/count_group_by_state", method = "post")]
async fn count_group_by_state(
&self,
Expand Down
2 changes: 1 addition & 1 deletion backend/middlewares/flow/src/dto/flow_state_dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub struct FlowStateAddReq {
pub disabled: Option<bool>,
}

#[derive(Serialize, Deserialize, Debug, poem_openapi::Object)]
#[derive(Serialize, Deserialize, Debug, poem_openapi::Object, Default)]
pub struct FlowStateModifyReq {
#[oai(validator(min_length = "2", max_length = "200"))]
pub name: Option<TrimString>,
Expand Down
Loading

0 comments on commit 984c4b6

Please sign in to comment.