[Editing]Basic Approval Flow and Chain Of Responsibility

I was thinking about implementing such a small flow feature apart from that BPMN which is too complex since they have so many restrictions by that many people, so consider a bit doing such a small thing.

Chain of responsibility is a pattern to tackle such code complexity, by introducing handlers and successors.

The approval flow, simply thinking about it, should be a sequence of Roles, and some checkpoints, success condition is based on strategy restriction, so, the flow might look like, 2023-5-2-8:51

to concrete the abstraction into code, I have drafted several models, very often, webui sends taskId and result to backend via webapi

1. controller, api, that accepts(taskId, result)

2. tables: chain(id, name), tasks(id,chainId,type), taskType(job, judgement)

class construction: Chain(composition of tasks, build the chain by reading tasks in database)

from the first task which is a handler, check the result, then setNext successor,

the main thing is the conversion from db task is in fact a handler in domain, taskRecords which is for maybe one task records multiple records, then need to multiply the chain and task to many instances, the API only makes sure the tasks move forward by one step, and tasks are executed separately at different timing, but each task execution is persisted in database, the result keeps being passed through all tasks, each task has a completed status, every task is a trigger for next task, judgement task keeps going auto triggered till next anti-judgement task is reached to, 2023-5-3-16:48

There are too ways for a chain to move forward,  either a task can address its next task, and after processing, do it itself, the key is when the relation to the next is set, most often this relation is already set when setting up the chain, so, here, after processing, just find its own next task from the whole chain and trigger next task's execution, they will finally move the termination of the chain when all manual tasks are done by hands,

留下你的评论