AdoS8NotificationRecipient.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. namespace Admin.NET.Plugin.AiDOP.Entity.S8;
  2. /// <summary>
  3. /// S8-NOTIFY-RECIPIENT-1:「某条规则的某个事件发生时,通知谁」。
  4. ///
  5. /// <para><b>身份是 (tenant_id, rule_code, event_code, recipient_type)</b>。
  6. /// <c>rule_code = '*'</c> 表示<b>租户级默认</b>,用于没有来源规则的异常(人工提报);
  7. /// 用显式哨兵而不是 NULL,是因为 NULL 在唯一索引里的比较语义会让人配出两条"默认"
  8. /// 而互不冲突。</para>
  9. ///
  10. /// <para><b>取代旧的 <c>ado_s8_notification_layer</c> 成为 CURRENT AUTHORITY。</b>
  11. /// 旧表按 <c>(scene_code, severity, level_code)</c> 组织,其中 level_code 的
  12. /// L1/L2/L3 三档在库里只有 L1 被真正用过,且「主管 / 总监」在系统中没有对应实体;
  13. /// 更关键的是它<b>不按规则</b>,无法回答「这条规则出事通知谁」。
  14. /// 旧表降级为 fallback:仅当本表对该 (租户, 规则, 事件) 没有任何配置时才使用,
  15. /// 且在页面上标注 LEGACY。优先级单一、可解释,不是两个平级 authority。</para>
  16. /// </summary>
  17. [SugarTable("ado_s8_notification_recipient", "S8 通知收件人配置")]
  18. [SugarIndex("uk_s8_notify_recipient", nameof(TenantId), OrderByType.Asc, nameof(RuleCode), OrderByType.Asc, nameof(EventCode), OrderByType.Asc, nameof(RecipientType), OrderByType.Asc, IsUnique = true)]
  19. public class AdoS8NotificationRecipient
  20. {
  21. [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true, ColumnDataType = "bigint")]
  22. public long Id { get; set; }
  23. /// <summary>租户。<b>唯一安全边界</b>;工厂不参与。</summary>
  24. [SugarColumn(ColumnName = "tenant_id", ColumnDataType = "bigint")]
  25. public long TenantId { get; set; }
  26. /// <summary>规则编码;<c>'*'</c> = 租户级默认(无来源规则的异常走这一条)。</summary>
  27. [SugarColumn(ColumnName = "rule_code", Length = 128)]
  28. public string RuleCode { get; set; } = string.Empty;
  29. /// <summary>事件码,取值须在 <c>S8NotificationCatalog.Events</c> 内。</summary>
  30. [SugarColumn(ColumnName = "event_code", Length = 64)]
  31. public string EventCode { get; set; } = string.Empty;
  32. /// <summary>收件人类型,取值须在 <c>S8NotificationCatalog.RecipientTypes</c> 内。</summary>
  33. [SugarColumn(ColumnName = "recipient_type", Length = 32)]
  34. public string RecipientType { get; set; } = string.Empty;
  35. /// <summary>
  36. /// 仅 <c>SPECIFIC_USER</c> 使用:逗号分隔的 <c>SysUser.Id</c>。
  37. /// 其余类型为空 —— 它们的人选在派发那一刻由上下文解析,不预存。
  38. /// </summary>
  39. [SugarColumn(ColumnName = "recipient_user_ids", Length = 2000, IsNullable = true)]
  40. public string? RecipientUserIds { get; set; }
  41. [SugarColumn(ColumnName = "created_at")]
  42. public DateTime CreatedAt { get; set; } = DateTime.Now;
  43. [SugarColumn(ColumnName = "created_by", Length = 64, IsNullable = true)]
  44. public string? CreatedBy { get; set; }
  45. }