ApprovalFlowItem.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. // Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
  2. //
  3. // 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
  4. //
  5. // 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
  6. using System.Text.Json.Serialization;
  7. namespace Admin.NET.Plugin.ApprovalFlow.Service;
  8. public class ApprovalFlowItem
  9. {
  10. [JsonPropertyName("nodes")]
  11. public List<ApprovalFlowNodeItem> Nodes { get; set; }
  12. [JsonPropertyName("edges")]
  13. public List<ApprovalFlowEdgeItem> Edges { get; set; }
  14. }
  15. public class ApprovalFlowNodeItem
  16. {
  17. [JsonPropertyName("id")]
  18. public string Id { get; set; }
  19. [JsonPropertyName("type")]
  20. public string Type { get; set; }
  21. [JsonPropertyName("x")]
  22. public float X { get; set; }
  23. [JsonPropertyName("y")]
  24. public float Y { get; set; }
  25. [JsonPropertyName("properties")]
  26. public FlowProperties Properties { get; set; }
  27. [JsonPropertyName("text")]
  28. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
  29. public FlowTextItem Text { get; set; }
  30. }
  31. public class ApprovalFlowEdgeItem
  32. {
  33. [JsonPropertyName("id")]
  34. public string Id { get; set; }
  35. [JsonPropertyName("type")]
  36. public string Type { get; set; }
  37. [JsonPropertyName("sourceNodeId")]
  38. public string SourceNodeId { get; set; }
  39. [JsonPropertyName("targetNodeId")]
  40. public string TargetNodeId { get; set; }
  41. [JsonPropertyName("startPoint")]
  42. public FlowEdgePointItem StartPoint { get; set; }
  43. [JsonPropertyName("endPoint")]
  44. public FlowEdgePointItem EndPoint { get; set; }
  45. [JsonPropertyName("properties")]
  46. public FlowProperties Properties { get; set; }
  47. [JsonPropertyName("text")]
  48. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
  49. public FlowTextItem Text { get; set; }
  50. [JsonPropertyName("pointsList")]
  51. public List<FlowEdgePointItem> PointsList { get; set; }
  52. }
  53. /// <summary>
  54. /// 节点属性(存储在 FlowJson 中每个 node/edge 的 properties)
  55. /// 向后兼容:所有字段可空,旧数据反序列化不会报错
  56. /// </summary>
  57. public class FlowProperties
  58. {
  59. // ── 用户任务节点属性 ──
  60. [JsonPropertyName("nodeName")]
  61. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
  62. public string? NodeName { get; set; }
  63. /// <summary>
  64. /// 审批人类型:SpecificUser / Role / Department / Initiator
  65. /// </summary>
  66. [JsonPropertyName("approverType")]
  67. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
  68. public string? ApproverType { get; set; }
  69. /// <summary>
  70. /// 审批人/角色/部门 Id,逗号分隔
  71. /// </summary>
  72. [JsonPropertyName("approverIds")]
  73. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
  74. public string? ApproverIds { get; set; }
  75. /// <summary>
  76. /// 审批人/角色/部门名称,逗号分隔(冗余,便于前端展示)
  77. /// </summary>
  78. [JsonPropertyName("approverNames")]
  79. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
  80. public string? ApproverNames { get; set; }
  81. /// <summary>
  82. /// 多人审批模式:Any(或签) / All(会签)
  83. /// </summary>
  84. [JsonPropertyName("multiApproveMode")]
  85. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
  86. public string? MultiApproveMode { get; set; }
  87. [JsonPropertyName("timeoutHours")]
  88. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
  89. public int? TimeoutHours { get; set; }
  90. /// <summary>
  91. /// 超时动作:AutoApprove / AutoReject / Notify
  92. /// </summary>
  93. [JsonPropertyName("timeoutAction")]
  94. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
  95. public string? TimeoutAction { get; set; }
  96. // ── 网关节点属性 ──
  97. [JsonPropertyName("conditions")]
  98. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
  99. public List<GatewayCondition>? Conditions { get; set; }
  100. }
  101. /// <summary>
  102. /// 排他网关条件分支
  103. /// </summary>
  104. public class GatewayCondition
  105. {
  106. [JsonPropertyName("targetNodeId")]
  107. public string TargetNodeId { get; set; } = "";
  108. [JsonPropertyName("expression")]
  109. public string Expression { get; set; } = "";
  110. [JsonPropertyName("label")]
  111. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
  112. public string? Label { get; set; }
  113. [JsonPropertyName("isDefault")]
  114. public bool IsDefault { get; set; }
  115. }
  116. public class FlowTextItem
  117. {
  118. [JsonPropertyName("x")]
  119. public float X { get; set; }
  120. [JsonPropertyName("y")]
  121. public float Y { get; set; }
  122. [JsonPropertyName("value")]
  123. public string Value { get; set; }
  124. }
  125. public class FlowEdgePointItem
  126. {
  127. [JsonPropertyName("x")]
  128. public float X { get; set; }
  129. [JsonPropertyName("y")]
  130. public float Y { get; set; }
  131. }