Documentation ¶
Index ¶
- Variables
- func CreateFlow(data []byte) (string, error)
- func DeleteFlow(recordID string) error
- func FromExpContext(ctx context.Context) (expression.ExpContext, bool)
- func FromFlagContext(ctx context.Context) (string, bool)
- func GetFlow(recordID string) (*schema.Flow, error)
- func GetFlowFormByFlowID(flowID string) (*schema.Form, error)
- func GetNodeInstance(nodeInstanceID string) (*schema.NodeInstance, error)
- func GetTodoByID(nodeInstanceID string) (*schema.FlowTodoResult, error)
- func Init(opts ...db.Option)
- func LoadFile(name string) error
- func NewExpContext(ctx context.Context, exp expression.ExpContext) context.Context
- func NewFlagContext(ctx context.Context, flag string) context.Context
- func QueryAllFlowPage(params schema.FlowQueryParam, pageIndex, pageSize uint) (int64, []*schema.FlowQueryResult, error)
- func QueryDone(typeCode, flowCode, userID string, lastTime int64, count int) ([]*schema.FlowDoneResult, error)
- func QueryDoneByPage(typeCode, flowCode, userID string, status, pageIndex, pageSize int) (int64, []*schema.FlowDoneResult, error)
- func QueryDoneFlowIDs(flowCode, userID string) ([]string, error)
- func QueryFlowHistory(flowInstanceID string) ([]*schema.FlowHistoryResult, error)
- func QueryGroupFlowPage(params schema.FlowQueryParam, pageIndex, pageSize uint) (int64, []*schema.FlowQueryResult, error)
- func QueryLastNodeInstance(flowInstanceID string) (*schema.NodeInstance, error)
- func QueryNodeCandidates(nodeInstanceID string) ([]string, error)
- func QueryTodoFlows(flowCode, userID string) ([]*schema.FlowTodoResult, error)
- func QueryTodoFlowsPaginate(flowCode, userID string, page int, pageSize int) (int, []*schema.FlowTodoResult, error)
- func SetExecer(execer Execer)
- func SetParser(parser Parser)
- func StartServer(opts ...ServerOption) http.Handler
- func StopFlow(nodeInstanceID string, allowStop func(*schema.FlowInstance) bool) error
- func StopFlowInstance(flowInstanceID string, allowStop func(*schema.FlowInstance) bool) error
- type API
- type AutoCallbackHandler
- type EndHandle
- type Engine
- func (e *Engine) CreateFlow(data []byte) (string, error)
- func (e *Engine) DeleteFlow(recordID string) error
- func (e *Engine) FlowBll() *bll.Flow
- func (e *Engine) GetExecer() Execer
- func (e *Engine) GetFlow(recordID string) (*schema.Flow, error)
- func (e *Engine) GetFlowFormByFlowID(flowID string) (*schema.Form, error)
- func (e *Engine) GetNodeInstance(nodeInstanceID string) (*schema.NodeInstance, error)
- func (e *Engine) GetTodoByID(nodeInstanceID string) (*schema.FlowTodoResult, error)
- func (e *Engine) HandleFlow(ctx context.Context, nodeInstanceID, userID string, inputData []byte) (*HandleResult, error)
- func (e *Engine) Init(parser Parser, execer Execer, sqlDB *sql.DB, trace bool) (*Engine, error)
- func (e *Engine) LaunchFlow(ctx context.Context, flowID, userID string, inputData []byte) (*HandleResult, error)
- func (e *Engine) LoadFile(name string) error
- func (e *Engine) QueryAllFlowPage(params schema.FlowQueryParam, pageIndex, pageSize uint) (int64, []*schema.FlowQueryResult, error)
- func (e *Engine) QueryDone(typeCode, flowCode, userID string, lastTime int64, count int) ([]*schema.FlowDoneResult, error)
- func (e *Engine) QueryDoneByPage(typeCode, flowCode, userID string, status, pageIndex, pageSize int) (int64, []*schema.FlowDoneResult, error)
- func (e *Engine) QueryDoneFlowIDs(flowCode, userID string) ([]string, error)
- func (e *Engine) QueryFlowHistory(flowInstanceID string) ([]*schema.FlowHistoryResult, error)
- func (e *Engine) QueryLastNodeInstance(flowInstanceID string) (*schema.NodeInstance, error)
- func (e *Engine) QueryNodeCandidates(nodeInstanceID string) ([]string, error)
- func (e *Engine) QueryTodoFlows(flowCode, userID string) ([]*schema.FlowTodoResult, error)
- func (e *Engine) QueryTodoFlowsPaginate(flowCode, userID string, page int, pageSize int) (int, []*schema.FlowTodoResult, error)
- func (e *Engine) SetAutoCallback(callback AutoCallbackHandler)
- func (e *Engine) SetExecer(execer Execer)
- func (e *Engine) SetGetDBContext(fn func(flag string) context.Context)
- func (e *Engine) SetLogger(logger Logger)
- func (e *Engine) SetParser(parser Parser)
- func (e *Engine) StartFlow(ctx context.Context, flowCode, userID string, inputData []byte) (*HandleResult, error)
- func (e *Engine) StartTiming(interval time.Duration)
- func (e *Engine) StopFlow(nodeInstanceID string, allowStop func(*schema.FlowInstance) bool) error
- func (e *Engine) StopFlowInstance(flowInstanceID string, allowStop func(*schema.FlowInstance) bool) error
- func (e *Engine) StopTiming()
- type Execer
- type FieldOption
- type FieldProperty
- type FieldValidation
- type FormFieldResult
- type HandleResult
- func HandleFlow(nodeInstanceID, userID string, input interface{}) (*HandleResult, error)
- func HandleFlowWithContext(ctx context.Context, nodeInstanceID, userID string, input interface{}) (*HandleResult, error)
- func LaunchFlow(flowID, userID string, inputData []byte) (*HandleResult, error)
- func StartFlow(flowCode, userID string, input interface{}) (*HandleResult, error)
- func StartFlowWithContext(ctx context.Context, flowCode, userID string, input interface{}) (*HandleResult, error)
- type Logger
- type NextNode
- type NextNodeHandle
- type NodeFormResult
- type NodeResult
- type NodeRouter
- type NodeRouterOption
- type NodeType
- type ParseResult
- type Parser
- type PropertyResult
- type Renderer
- type RouterResult
- type Server
- type ServerOption
Constants ¶
This section is empty.
Variables ¶
var (
ErrNotFound = errors.New("未找到流程相关的信息")
)
定义错误
Functions ¶
func CreateFlow ¶ added in v1.0.5
func DeleteFlow ¶ added in v1.0.5
func FromExpContext ¶
func FromExpContext(ctx context.Context) (expression.ExpContext, bool)
FromExpContext 获取表达式的上下文
func FromFlagContext ¶
FromFlagContext 获取flag的上下文
func GetFlowFormByFlowID ¶ added in v1.0.9
func GetNodeInstance ¶
func GetNodeInstance(nodeInstanceID string) (*schema.NodeInstance, error)
GetNodeInstance 获取节点实例
func GetTodoByID ¶ added in v1.0.5
func GetTodoByID(nodeInstanceID string) (*schema.FlowTodoResult, error)
func NewExpContext ¶
func NewExpContext(ctx context.Context, exp expression.ExpContext) context.Context
NewExpContext 创建表达式的上下文值
func NewFlagContext ¶
NewFlagContext 创建flag的上下文值
func QueryAllFlowPage ¶ added in v1.0.5
func QueryAllFlowPage(params schema.FlowQueryParam, pageIndex, pageSize uint) (int64, []*schema.FlowQueryResult, error)
func QueryDoneByPage ¶ added in v1.0.9
func QueryDoneFlowIDs ¶
QueryDoneFlowIDs 查询已办理的流程实例ID列表
func QueryFlowHistory ¶
func QueryFlowHistory(flowInstanceID string) ([]*schema.FlowHistoryResult, error)
QueryFlowHistory 查询流程历史数据 flowInstanceID 流程实例内码
func QueryGroupFlowPage ¶ added in v1.0.8
func QueryGroupFlowPage(params schema.FlowQueryParam, pageIndex, pageSize uint) (int64, []*schema.FlowQueryResult, error)
func QueryLastNodeInstance ¶
func QueryLastNodeInstance(flowInstanceID string) (*schema.NodeInstance, error)
func QueryNodeCandidates ¶
QueryNodeCandidates 查询节点实例的候选人ID列表
func QueryTodoFlows ¶
func QueryTodoFlows(flowCode, userID string) ([]*schema.FlowTodoResult, error)
QueryTodoFlows 查询流程待办数据 flowCode 流程编号 userID 待办人
func QueryTodoFlowsPaginate ¶
func QueryTodoFlowsPaginate(flowCode, userID string, page int, pageSize int) (int, []*schema.FlowTodoResult, error)
QueryTodoFlowsPaginate 分页查询流程待办数据 flowCode 流程编号 userID 待办人
func StopFlow ¶
func StopFlow(nodeInstanceID string, allowStop func(*schema.FlowInstance) bool) error
StopFlow 停止流程
func StopFlowInstance ¶
func StopFlowInstance(flowInstanceID string, allowStop func(*schema.FlowInstance) bool) error
StopFlowInstance 停止流程实例
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API 提供API管理
func (*API) QueryFlowPage ¶
QueryFlowPage 查询流程分页数据
type AutoCallbackHandler ¶
type AutoCallbackHandler func(action, flag, userID string, input []byte, result *HandleResult) error
AutoCallbackHandler 自动执行节点回调处理
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine 流程引擎
func (*Engine) CreateFlow ¶
CreateFlow 创建流程数据
func (*Engine) DeleteFlow ¶ added in v1.0.5
func (*Engine) GetFlowFormByFlowID ¶ added in v1.0.9
func (*Engine) GetNodeInstance ¶
func (e *Engine) GetNodeInstance(nodeInstanceID string) (*schema.NodeInstance, error)
GetNodeInstance 获取节点实例
func (*Engine) GetTodoByID ¶ added in v1.0.5
func (e *Engine) GetTodoByID(nodeInstanceID string) (*schema.FlowTodoResult, error)
func (*Engine) HandleFlow ¶
func (e *Engine) HandleFlow(ctx context.Context, nodeInstanceID, userID string, inputData []byte) (*HandleResult, error)
HandleFlow 处理流程节点 nodeInstanceID 节点实例内码 userID 处理人 inputData 输入数据
func (*Engine) LaunchFlow ¶
func (e *Engine) LaunchFlow(ctx context.Context, flowID, userID string, inputData []byte) (*HandleResult, error)
LaunchFlow 发起流程(基于流程ID)
func (*Engine) QueryAllFlowPage ¶ added in v1.0.5
func (e *Engine) QueryAllFlowPage(params schema.FlowQueryParam, pageIndex, pageSize uint) (int64, []*schema.FlowQueryResult, error)
func (*Engine) QueryDoneByPage ¶ added in v1.0.9
func (*Engine) QueryDoneFlowIDs ¶
QueryDoneFlowIDs 查询已办理的流程实例ID列表
func (*Engine) QueryFlowHistory ¶
func (e *Engine) QueryFlowHistory(flowInstanceID string) ([]*schema.FlowHistoryResult, error)
QueryFlowHistory 查询流程历史数据 flowInstanceID 流程实例内码
func (*Engine) QueryLastNodeInstance ¶
func (e *Engine) QueryLastNodeInstance(flowInstanceID string) (*schema.NodeInstance, error)
func (*Engine) QueryNodeCandidates ¶
QueryNodeCandidates 查询节点实例的候选人ID列表
func (*Engine) QueryTodoFlows ¶
func (e *Engine) QueryTodoFlows(flowCode, userID string) ([]*schema.FlowTodoResult, error)
QueryTodoFlows 查询流程待办数据 flowCode 流程编号 userID 待办人
func (*Engine) QueryTodoFlowsPaginate ¶
func (e *Engine) QueryTodoFlowsPaginate(flowCode, userID string, page int, pageSize int) (int, []*schema.FlowTodoResult, error)
QueryTodoFlowsPaginate 分页查询流程待办数据 flowCode 流程编号 userID 待办人
func (*Engine) SetAutoCallback ¶
func (e *Engine) SetAutoCallback(callback AutoCallbackHandler)
SetAutoCallback 设定自动节点回调函数
func (*Engine) SetGetDBContext ¶
SetGetDBContext 设定获取DB上下文
func (*Engine) StartFlow ¶
func (e *Engine) StartFlow(ctx context.Context, flowCode, userID string, inputData []byte) (*HandleResult, error)
StartFlow 启动流程 flowCode 流程编号 userID 发起人 inputData 输入数据
func (*Engine) StopFlowInstance ¶
func (e *Engine) StopFlowInstance(flowInstanceID string, allowStop func(*schema.FlowInstance) bool) error
StopFlowInstance 停止流程实例
type Execer ¶
type Execer interface { // 执行表达式返回布尔类型的值 ExecReturnBool(ctx context.Context, exp, params []byte) (bool, error) ExecReturnMap(ctx context.Context, exp, params []byte) (map[string]interface{}, error) // 执行表达式返回字符串切片类型的值 ExecReturnStringSlice(ctx context.Context, exp, params []byte) ([]string, error) }
Execer 表达式执行器
type FieldOption ¶
FieldOption 枚举选项
type FieldProperty ¶
FieldProperty 字段属性
type FieldValidation ¶
FieldValidation 字段验证
type FormFieldResult ¶
type FormFieldResult struct { ID string // 字段ID Type string // 字段类型 Label string // 字段标签 DefaultValue string // 默认值 Values []*FieldOption // 枚举类型 Validations []*FieldValidation // 字段验证 Properties []*FieldProperty // 字段属性 }
FormFieldResult 表单字段
type HandleResult ¶
type HandleResult struct { IsEnd bool `json:"is_end"` // 是否结束 NextNodes []*NextNode `json:"next_nodes"` // 下一处理节点 FlowInstance *schema.FlowInstance `json:"flow_instance"` // 流程实例 }
HandleResult 处理结果
func HandleFlow ¶
func HandleFlow(nodeInstanceID, userID string, input interface{}) (*HandleResult, error)
HandleFlow 处理流程节点 nodeInstanceID 节点实例内码 userID 处理人 input 输入数据
func HandleFlowWithContext ¶
func HandleFlowWithContext(ctx context.Context, nodeInstanceID, userID string, input interface{}) (*HandleResult, error)
HandleFlowWithContext 处理流程节点 nodeInstanceID 节点实例内码 userID 处理人 input 输入数据
func LaunchFlow ¶ added in v1.0.8
func LaunchFlow(flowID, userID string, inputData []byte) (*HandleResult, error)
func StartFlow ¶
func StartFlow(flowCode, userID string, input interface{}) (*HandleResult, error)
StartFlow 启动流程 flowCode 流程编号 userID 发起人 input 输入数据
func StartFlowWithContext ¶
func StartFlowWithContext(ctx context.Context, flowCode, userID string, input interface{}) (*HandleResult, error)
StartFlowWithContext 启动流程 flowCode 流程编号 nodeCode 开始节点编号 userID 发起人 input 输入数据
func (*HandleResult) String ¶
func (r *HandleResult) String() string
type NextNode ¶
type NextNode struct { Node *schema.Node // 节点信息 CandidateIDs []string // 节点候选人 NodeInstance *schema.NodeInstance // 节点实例 }
NextNode 下一节点
type NextNodeHandle ¶
type NextNodeHandle func(*schema.Node, *schema.NodeInstance, []*schema.NodeCandidate)
NextNodeHandle 定义下一节点处理函数
type NodeFormResult ¶
type NodeFormResult struct { ID string // 表单ID Fields []*FormFieldResult // 表单字段 }
NodeFormResult 节点表单
type NodeResult ¶
type NodeResult struct { NodeID string // 节点ID NodeName string // 节点名称 NodeType NodeType // 节点类型 Content string // 节点执行脚本内容 Routers []*RouterResult // 节点路由 Properties []*PropertyResult // 节点属性 CandidateExpressions []string // 候选人表达式 FormResult *NodeFormResult // 节点表单 }
NodeResult 节点数据
type NodeRouter ¶
type NodeRouter struct {
// contains filtered or unexported fields
}
NodeRouter 节点路由
func (*NodeRouter) GetFlowInstance ¶
func (n *NodeRouter) GetFlowInstance() *schema.FlowInstance
GetFlowInstance 获取流程实例
func (*NodeRouter) Init ¶
func (n *NodeRouter) Init(ctx context.Context, engine *Engine, nodeInstanceID string, inputData []byte, options ...NodeRouterOption) (*NodeRouter, error)
Init 初始化节点路由
type NodeRouterOption ¶
type NodeRouterOption func(*nodeRouterOptions)
NodeRouterOption 节点路由配置
func AutoStartOption ¶
func AutoStartOption(autoStart bool) NodeRouterOption
AutoStartOption 自动开始流程配置
func OnNextNodeOption ¶
func OnNextNodeOption(fn NextNodeHandle) NodeRouterOption
OnNextNodeOption 注册下一节点处理事件配置
type NodeType ¶
type NodeType string
NodeType 节点类型
const ( // StartEvent 开始事件 StartEvent NodeType = "startEvent" // EndEvent 结束事件 EndEvent NodeType = "endEvent" // TerminateEvent 终止事件 TerminateEvent NodeType = "terminateEvent" // UserTask 人工任务 UserTask NodeType = "userTask" ScriptTask NodeType = "scriptTask" // ExclusiveGateway 排他网关 ExclusiveGateway NodeType = "exclusiveGateway" // ParallelGateway 并行网关 ParallelGateway NodeType = "parallelGateway" // Unknown 未知类型 Unknown NodeType = "Unknown" )
func GetNodeTypeByName ¶
GetNodeTypeByName 转换节点类型
type ParseResult ¶
type ParseResult struct { FlowID string // 流程ID FlowName string // 流程名称 FlowMemo string // 流程笔记 FlowVersion int64 // 流程版本号 FlowStatus int // 流程状态(1:可用 2:不可用) IsAutoStart bool // 是否自动启动 Nodes []*NodeResult // 节点数据 }
ParseResult 流程数据
type Parser ¶
type Parser interface { // 解析流程定义数据 Parse(ctx context.Context, data []byte) (*ParseResult, error) }
Parser 流程数据解析器
type PropertyResult ¶
PropertyResult 节点属性
type Renderer ¶
type Renderer interface {
Render(context.Context, *NodeFormResult) ([]byte, error)
}
Renderer 表单渲染器
type RouterResult ¶
type RouterResult struct { TargetNodeID string // 目标节点ID Explain string // 说明 Expression string // 条件表达式 }
RouterResult 节点路由数据
type ServerOption ¶
type ServerOption func(*serverOptions)
ServerOption 流程服务配置
func ServerMiddlewareOption ¶
func ServerMiddlewareOption(middlewares ...gear.Middleware) ServerOption
ServerMiddlewareOption 中间件
func ServerPrefixOption ¶
func ServerPrefixOption(prefix string) ServerOption
ServerPrefixOption 访问前缀
func ServerStaticRootOption ¶
func ServerStaticRootOption(staticRoot string) ServerOption
ServerStaticRootOption 静态文件目录