30 lines
1.4 KiB
C#
30 lines
1.4 KiB
C#
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
using Workflow.Domain.Enums;
|
|
|
|
namespace Workflow.Domain.Engine;
|
|
|
|
/// <summary>
|
|
/// 钉钉式审批流的强类型树模型。前端树编辑器与后端存储/编译共用此结构。
|
|
/// <para>
|
|
/// 结构约定:
|
|
/// <list type="bullet">
|
|
/// <item>Root 固定为 <see cref="TreeNodeTypeEnum.Initiator"/>(发起人节点)。</item>
|
|
/// <item>顺序链:每个节点的 <see cref="TreeNode.Child"/> 指向下一个节点,形成链式(发起人→审批→抄送…)。</item>
|
|
/// <item>条件分支 / 并行分支容器:节点的 <see cref="TreeNode.Branches"/> 存放分支集合;每条分支内部又是独立的顺序链(<see cref="TreeBranch.Child"/>)。</item>
|
|
/// <item>分支在末端会自动收口回主链(编译器负责生成汇合边)。</item>
|
|
/// </list>
|
|
/// 与 <see cref="WorkflowGraph"/>(运行态图)解耦:<see cref="Workflow.Application.Engine.TreeToGraphCompiler"/>
|
|
/// 负责把本树编译成引擎可运行的图。
|
|
/// </para>
|
|
/// </summary>
|
|
public sealed class WorkflowTree
|
|
{
|
|
/// <summary>树的根节点(发起人)。前端编辑态始终非空;空树用 <see cref="Empty"/> 表达。</summary>
|
|
[JsonPropertyName("root")]
|
|
public TreeNode? Root { get; set; }
|
|
|
|
/// <summary>空树工厂:用于缺省/容错。</summary>
|
|
public static WorkflowTree Empty() => new();
|
|
}
|