Documentation
¶
Index ¶
- Constants
- func EdgeToMap(edge Edge) map[string]interface{}
- func GetJsCode(wfFlowData LogicFlow, edgeMap map[string][]string, ...) (string, error)
- func ToNodeProperty[T any](node Node) (T, error)
- type Assignee
- type AutomationNodeHandler
- type AutomationProperty
- type ChatGroupMode
- type ChatGroupNodeHandler
- type ChatGroupProperty
- type ConditionHandler
- type ConditionProperty
- type Context
- func (ctx *Context) AddOutputNode(n ...model.Node)
- func (ctx *Context) GetNodeInfo(nodeID string) Node
- func (ctx *Context) GetOrGenerateProxyForGateway(conditionGatewayID, targetID string) string
- func (ctx *Context) GetOrGenerateProxyID(srcID, targetID string) string
- func (ctx *Context) GetPrevNodeIDs(nodeID string) []string
- func (ctx *Context) GetTargetEdges(nodeID string) []Edge
- type Converter
- type CreateChatGroup
- type DefaultConverter
- type Edge
- type EdgeProperty
- type EndNodeHandler
- type EndProperty
- type ExecMethod
- type Field
- type FieldType
- type INodeHandler
- type InclusionHandler
- type LogicFlow
- type Node
- type Option
- type OutputMode
- type ParallelHandler
- type Rule
- type SelectiveHandler
- type StartNodeHandler
- type StartProperty
- type UserNodeHandler
- type UserProperty
- type Workflow
Constants ¶
const ( NodeTypeStart = "start" NodeTypeEnd = "end" NodeTypeUser = "user" NodeTypeCondition = "condition" NodeTypeParallel = "parallel" NodeTypeInclusion = "inclusion" NodeTypeSelective = "selective" NodeTypeAuto = "automation" NodeTypeChat = "chat" )
节点类型标识,对应前端 LogicFlow DSL 中的 type 字段
const ( DefaultNameStart = "Start" DefaultNameEnd = "End" DefaultNameUser = "审批节点" DefaultNameParallel = "并行网关" DefaultNameInclusion = "包容网关" DefaultNameSelective = "条件并行网关" )
节点默认名称
const ( UserStarter = "$starter" // 工单发起人 AutomationApproval = "automation" // 自动化节点占位用户 ChatGroupApproval = "chat_group" // 群通知节点占位用户 SysAutoUser = "sys_auto" // 系统代理节点自动审批用户 )
系统内置用户标识
const ( // EventStart 开始节点触发事件 EventStart = "EventStart" // EventNotify 通用通知事件(节点开始时通知审批人) EventNotify = "EventNotify" // EventCarbonCopy 抄送事件 EventCarbonCopy = "EventCarbonCopy" // EventAutomation 自动化节点执行事件 EventAutomation = "EventAutomation" // EventChatGroup 群通知节点事件 EventChatGroup = "EventChatGroup" // EventSelectiveGatewaySplit 条件并行网关分裂事件 EventSelectiveGatewaySplit = "EventSelectiveGatewaySplit" // EventRevoke 撤销事件 EventRevoke = "EventRevoke" // EventTaskParallelNodePass 并行网关:分支通过事件 EventTaskParallelNodePass = "EventTaskParallelNodePass" // EventTaskInclusionNodePass 包容网关:分支通过事件 EventTaskInclusionNodePass = "EventTaskInclusionNodePass" // EventConcurrentRejectCleanup 并发拒绝时清理其他分支的事件(condition -> parallel/inclusion/selective) EventConcurrentRejectCleanup = "EventConcurrentRejectCleanup" // EventInclusionPassCleanup 包容网关通过时清理未完成分支的事件 EventInclusionPassCleanup = "EventInclusionPassCleanup" // EventGatewayConditionReject 网关条件拒绝事件(gateway -> condition 场景下的拒绝) EventGatewayConditionReject = "EventGatewayConditionReject" // EventUserNodeRejectProxyCleanup 用户节点拒绝时清理代理节点的事件 EventUserNodeRejectProxyCleanup = "EventUserNodeRejectProxyCleanup" )
工作流引擎事件名称
const SysProxyNodeName = "系统代理流转"
SysProxyNodeName 系统代理节点名称
Variables ¶
This section is empty.
Functions ¶
func GetJsCode ¶ added in v1.11.0
func GetJsCode(wfFlowData LogicFlow, edgeMap map[string][]string, nodeStatusMap map[string]int) (string, error)
GetJsCode 供飞书或前端使用的通用 JSON 代码生成函数 仅根据 Workflow 对象和状态映射生成 window.__DATA__ 代码
func ToNodeProperty ¶ added in v1.7.0
ToNodeProperty node节点字段解析
Types ¶
type Assignee ¶ added in v1.11.0
type Assignee struct {
Rule Rule `json:"rule"` // 匹配策略
Values []string `json:"values"` // 规则的目标值列表(使用 string 兼容更多实体标识)
}
Assignee 审批人员分配规则配置
type AutomationNodeHandler ¶ added in v1.11.0
type AutomationNodeHandler struct{}
func (*AutomationNodeHandler) Type ¶ added in v1.11.0
func (h *AutomationNodeHandler) Type() string
type AutomationProperty ¶
type AutomationProperty struct {
Name string `json:"name"`
CodebookUid string `json:"codebook_uid"` // 代码库UID
Tag string `json:"tag"` // runner tags
IsNotify bool `json:"is_notify"` // 是否开始消息通知
Unit uint8 `json:"unit"` // 定时执行:单位
Quantity int64 `json:"quantity"` // 定时执行:数量
ExecMethod string `json:"exec_method"` // 执行方式, template 模版获取,hand 手动指定
TemplateId int64 `json:"template_id"` // 模版ID
TemplateField string `json:"template_field"` // 模版字段
IsTiming bool `json:"is_timing"` // 是否开始定时执行
NotifyMethod []int64 `json:"notify_method"` // 消息通知模式
}
type ChatGroupMode ¶ added in v1.11.0
type ChatGroupMode string
const ( ChatGroupUseExisting ChatGroupMode = "existing" ChatGroupCreate ChatGroupMode = "create" )
type ChatGroupNodeHandler ¶ added in v1.11.0
type ChatGroupNodeHandler struct{}
func (*ChatGroupNodeHandler) Type ¶ added in v1.11.0
func (h *ChatGroupNodeHandler) Type() string
type ChatGroupProperty ¶ added in v1.11.0
type ChatGroupProperty struct {
Name string `json:"name"` // 节点名称
Title string `json:"title"` // 消息卡片标题
Mode ChatGroupMode `json:"mode"` // existing / create
ChatGroupIDs []int64 `json:"chat_group_ids,omitempty"` // existing 模式, 自动匹配所属 team 内部的所有人
Create *CreateChatGroup `json:"create,omitempty"` // create 模式,新建一个群组,全局不绑定任何 Team,或者默认 Team
Assignees []Assignee `json:"assignees"` // 成员规则
OutputMode []OutputMode `json:"is_auto"` // 支持的返回数据
}
ChatGroupProperty 群通知节点属性 该节点为纯广播型,发送完成后自动推进流程,无需等待任何操作
type ConditionHandler ¶ added in v1.11.0
type ConditionHandler struct{}
func (*ConditionHandler) Type ¶ added in v1.11.0
func (h *ConditionHandler) Type() string
type ConditionProperty ¶
type ConditionProperty struct {
Name string `json:"name"`
}
type Context ¶ added in v1.11.0
type Context struct {
Workflow Workflow
NodesMap map[string]Node // ID -> DSL Node
EdgesMap map[string][]Edge // SourceNodeId -> []Edge
PrevNodesMap map[string][]string // TargetNodeId -> []SourceNodeId
OutputNodes []model.Node // 转换生成的最终节点集
ProxyNodes map[string]struct{} // 已创建的代理节点 ID 集合,防止重复
}
Context 转换过程的上下文
func (*Context) AddOutputNode ¶ added in v1.11.0
AddOutputNode 添加生成后的 Engine 节点
func (*Context) GetNodeInfo ¶ added in v1.11.0
GetNodeInfo 获取原始节点信息
func (*Context) GetOrGenerateProxyForGateway ¶ added in v1.11.0
GetOrGenerateProxyForGateway 当源节点是条件网关连接到并行/包容/条件并行网关时,获取或生成代理节点 ID 用于处理条件网关到其他网关的连接
func (*Context) GetOrGenerateProxyID ¶ added in v1.11.0
GetOrGenerateProxyID 获取或生成代理节点 ID 当目标节点是网关类型时,创建并返回代理节点 ID 否则返回目标节点 ID
func (*Context) GetPrevNodeIDs ¶ added in v1.11.0
GetPrevNodeIDs 获取目标节点的上级节点 ID
func (*Context) GetTargetEdges ¶ added in v1.11.0
GetTargetEdges 获取指定节点的出边
type Converter ¶ added in v1.11.0
type Converter interface {
// Convert 将工作流 DSL 转换为流程引擎模型
Convert(workflow Workflow) (*model.Process, error)
}
Converter 工作流转换器接口
func NewLogicFlowToEngineConvert ¶
func NewLogicFlowToEngineConvert() Converter
type CreateChatGroup ¶ added in v1.11.0
type DefaultConverter ¶ added in v1.11.0
type DefaultConverter struct {
// contains filtered or unexported fields
}
DefaultConverter 默认转换器实现
func NewDefaultConverter ¶ added in v1.11.0
func NewDefaultConverter() *DefaultConverter
func NewDefaultConverterWithHandlers ¶ added in v1.11.0
func NewDefaultConverterWithHandlers() *DefaultConverter
NewDefaultConverterWithHandlers 创建已注册所有标准处理器的转换器
func (*DefaultConverter) Convert ¶ added in v1.11.0
func (c *DefaultConverter) Convert(wf Workflow) (*model.Process, error)
Convert 执行转换流程 (Pipeline)
func (*DefaultConverter) Register ¶ added in v1.11.0
func (c *DefaultConverter) Register(handler INodeHandler)
Register 注册节点处理器
type Edge ¶
type Edge struct {
Type string `json:"type"`
SourceNodeId string `json:"sourceNodeId"`
TargetNodeId string `json:"targetNodeId"`
Properties interface{} `json:"properties"`
ID string `json:"id"`
StartPoint map[string]interface{} `json:"startPoint"`
EndPoint map[string]interface{} `json:"endPoint"`
PointsList []map[string]interface{} `json:"pointsList"`
Text map[string]interface{} `json:"text"`
}
Edge 定义线字段
type EdgeProperty ¶
type EdgeProperty struct {
Name string `json:"name"`
Expression string `json:"expression"` // 表达式
IsPass bool `json:"is_pass"` // 连线是否通过、为了绘制流程图走向使用
}
func ToEdgeProperty ¶ added in v1.7.0
func ToEdgeProperty(edges Edge) (EdgeProperty, error)
ToEdgeProperty edge连线字段解析
type EndNodeHandler ¶ added in v1.11.0
type EndNodeHandler struct{}
EndNodeHandler 处理结束节点
func (*EndNodeHandler) Type ¶ added in v1.11.0
func (h *EndNodeHandler) Type() string
type EndProperty ¶
type EndProperty struct {
Name string `json:"name"`
}
type ExecMethod ¶ added in v1.9.0
type ExecMethod string
const ( // EXEC_TEMPLATE 根据模版 EXEC_TEMPLATE ExecMethod = "template" // HAND 手动方式 HAND ExecMethod = "hand" )
func (ExecMethod) ToString ¶ added in v1.9.0
func (s ExecMethod) ToString() string
type Field ¶ added in v1.10.0
type Field struct {
Name string `json:"name"` // 表单字段显示名
Key string `json:"key"` // 表单字段键名(对应 Order Data Key)
Type FieldType `json:"type"` // 字段类型:input, textarea, date, number...
Required bool `json:"required"` // 是否必填
Options []Option `json:"options"` // 选项列表(用于 select 等)
Props map[string]string `json:"props"` // 额外组件属性(如 placeholder)
Merge bool `json:"merge"` // 如果 Merge 则在后续审批节点进行推送展示
Validate string `json:"validate"` // 数据校验
Hidden bool `json:"hidden"` // 字段需要,但是不展示,由系统补充
Value string `json:"value"` // 数据值
ReadOnly bool `json:"readonly"` // 只读字段,比如提示用户时候使用
}
type FieldType ¶ added in v1.10.0
type FieldType string
const ( // FieldInput 单行文本 FieldInput FieldType = "input" // FieldTextarea 多行文本 FieldTextarea FieldType = "textarea" // FieldNumber 数字 FieldNumber FieldType = "number" // FieldDate 日期 FieldDate FieldType = "date" // FieldSelect 下拉选择 FieldSelect FieldType = "select" // FieldMultiSelect 多项选择 FieldMultiSelect FieldType = "multi_select" // FieldTips 提示选项 FieldTips FieldType = "tips" )
type INodeHandler ¶ added in v1.11.0
INodeHandler 节点解析器接口
type InclusionHandler ¶ added in v1.11.0
type InclusionHandler struct{}
func (*InclusionHandler) Type ¶ added in v1.11.0
func (h *InclusionHandler) Type() string
type Node ¶
type Node struct {
Type string `json:"type"`
Properties interface{} `json:"properties"`
ID string `json:"id"`
}
func ParseNodes ¶ added in v1.10.0
type OutputMode ¶ added in v1.11.0
type OutputMode string
const ( OutputTicketData OutputMode = "ticket_data" // 工单提交信息 OutputAutoTask OutputMode = "auto_task" // 自动化任务返回结果 OutputUserInput OutputMode = "user_input" // 用户节点提交信息 )
type ParallelHandler ¶ added in v1.11.0
type ParallelHandler struct{}
func (*ParallelHandler) Type ¶ added in v1.11.0
func (h *ParallelHandler) Type() string
type Rule ¶ added in v1.8.0
type Rule string
const ( // APPOINT 指定内部人员 APPOINT Rule = "appoint" // FOUNDER 工单创建人 FOUNDER Rule = "founder" // TEMPLATE 根据模版字段提取用户 TEMPLATE Rule = "template" // LEADER 部门领导 LEADER Rule = "leaders" // MAIN_LEADER 分管领导 MAIN_LEADER Rule = "main_leader" // ON_CALL 值班排班人员 ON_CALL Rule = "on_call" // TEAM 团队人员 TEAM Rule = "team" )
type SelectiveHandler ¶ added in v1.11.0
type SelectiveHandler struct{}
func (*SelectiveHandler) Type ¶ added in v1.11.0
func (h *SelectiveHandler) Type() string
type StartNodeHandler ¶ added in v1.11.0
type StartNodeHandler struct{}
StartNodeHandler 处理开始节点
func (*StartNodeHandler) Type ¶ added in v1.11.0
func (h *StartNodeHandler) Type() string
type StartProperty ¶
type UserNodeHandler ¶ added in v1.11.0
type UserNodeHandler struct{}
UserNodeHandler 处理用户/审批节点
func (*UserNodeHandler) Type ¶ added in v1.11.0
func (h *UserNodeHandler) Type() string
type UserProperty ¶
type UserProperty struct {
Name string `json:"name"` // 节点名称
Approved []string `json:"approved"` // 审批人、抄送人
Rule Rule `json:"rule"` // 匹配策略 (兼容历史数据)
Type Rule `json:"type"` // 匹配策略 (兼容历史数据
TemplateField string `json:"template_field"` // 模版字段
Assignees []Assignee `json:"assignees"` // 新模式字段,支持配置多条分配规则
IsCosigned bool `json:"is_cosigned"` // 是否会签
IsCC bool `json:"is_cc"` // 是否抄送
Fields []Field `json:"fields"` // 表单字段配置
}
func (*UserProperty) NormalizeAssignees ¶ added in v1.11.0
func (u *UserProperty) NormalizeAssignees() []Assignee
NormalizeAssignees 统一格式化获取人员分配规则,屏蔽新老版本数据差异