MdpInboundEntities.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. namespace Admin.NET.Plugin.AiDOP.Entity.DataPlatform;
  2. /// <summary>第三方推数入站授权。不走 CodeFirst,以 UpdateScripts 为唯一建表口径。</summary>
  3. /// <remarks>
  4. /// <para>下面的 <see cref="SugarIndexAttribute"/> 是<b>兜底</b>,不是建表口径的改变。</para>
  5. /// <para>起因:1.0.536 用 CREATE TABLE IF NOT EXISTS 建表,而本表曾被某实例的 CodeFirst
  6. /// 抢先建出(CodeFirst 在容器初始化阶段跑,早于 UseAutoVersionUpdate 中间件),
  7. /// 导致脚本整条 no-op、唯一键从未落地,直到 1.0.553 才补上。
  8. /// 声明本索引后,即便将来又出现 CodeFirst 抢建的时序,
  9. /// <c>(access_key, entity_code)</c> 的唯一性也不会再丢。</para>
  10. /// </remarks>
  11. [SugarTable("mdp_inbound_grant", "第三方推数入站授权")]
  12. [SugarIndex("uk_inbound_grant", nameof(AccessKey), OrderByType.Asc, nameof(EntityCode), OrderByType.Asc, true)]
  13. public class MdpInboundGrant
  14. {
  15. [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
  16. public long Id { get; set; }
  17. [SugarColumn(ColumnName = "tenant_id")]
  18. public long TenantId { get; set; }
  19. [SugarColumn(ColumnName = "access_key", Length = 64)]
  20. public string AccessKey { get; set; } = string.Empty;
  21. [SugarColumn(ColumnName = "entity_code", Length = 100)]
  22. public string EntityCode { get; set; } = string.Empty;
  23. [SugarColumn(ColumnName = "factory_id", IsNullable = true)]
  24. public long? FactoryId { get; set; }
  25. [SugarColumn(ColumnName = "source_code", Length = 50)]
  26. public string SourceCode { get; set; } = string.Empty;
  27. [SugarColumn(ColumnName = "rate_limit_per_min")]
  28. public int RateLimitPerMin { get; set; } = 60;
  29. [SugarColumn(ColumnName = "batch_row_limit")]
  30. public int BatchRowLimit { get; set; } = 500;
  31. [SugarColumn(ColumnName = "ip_allowlist", Length = 1000, IsNullable = true)]
  32. public string IpAllowlist { get; set; }
  33. [SugarColumn(ColumnName = "status")]
  34. public int Status { get; set; } = 1;
  35. [SugarColumn(ColumnName = "remark", Length = 500, IsNullable = true)]
  36. public string Remark { get; set; }
  37. [SugarColumn(ColumnName = "create_time")]
  38. public DateTime CreateTime { get; set; }
  39. [SugarColumn(ColumnName = "update_time")]
  40. public DateTime UpdateTime { get; set; }
  41. }
  42. /// <summary>入站请求幂等状态机 + 审计。不走 CodeFirst。</summary>
  43. [SugarTable("mdp_inbound_request", "第三方推数入站请求")]
  44. public class MdpInboundRequest
  45. {
  46. [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
  47. public long Id { get; set; }
  48. [SugarColumn(ColumnName = "tenant_id")]
  49. public long TenantId { get; set; }
  50. [SugarColumn(ColumnName = "access_key", Length = 64)]
  51. public string AccessKey { get; set; } = string.Empty;
  52. [SugarColumn(ColumnName = "entity_code", Length = 100)]
  53. public string EntityCode { get; set; } = string.Empty;
  54. [SugarColumn(ColumnName = "idempotency_key", Length = 128)]
  55. public string IdempotencyKey { get; set; } = string.Empty;
  56. [SugarColumn(ColumnName = "request_hash", Length = 64)]
  57. public string RequestHash { get; set; } = string.Empty;
  58. [SugarColumn(ColumnName = "sync_batch_id", Length = 64)]
  59. public string SyncBatchId { get; set; } = string.Empty;
  60. [SugarColumn(ColumnName = "snapshot_id", Length = 64, IsNullable = true)]
  61. public string SnapshotId { get; set; }
  62. [SugarColumn(ColumnName = "status", Length = 16)]
  63. public string Status { get; set; } = "RECEIVED";
  64. [SugarColumn(ColumnName = "http_status")]
  65. public int HttpStatus { get; set; }
  66. [SugarColumn(ColumnName = "result_code")]
  67. public int ResultCode { get; set; }
  68. [SugarColumn(ColumnName = "accepted")]
  69. public int Accepted { get; set; }
  70. [SugarColumn(ColumnName = "rejected")]
  71. public int Rejected { get; set; }
  72. [SugarColumn(ColumnName = "stale_rejected")]
  73. public int StaleRejected { get; set; }
  74. [SugarColumn(ColumnName = "equal_ts_override")]
  75. public int EqualTsOverride { get; set; }
  76. [SugarColumn(ColumnName = "receipt_json", ColumnDataType = "mediumtext", IsNullable = true)]
  77. public string ReceiptJson { get; set; }
  78. [SugarColumn(ColumnName = "error_msg", Length = 1000, IsNullable = true)]
  79. public string ErrorMsg { get; set; }
  80. [SugarColumn(ColumnName = "client_ip", Length = 64, IsNullable = true)]
  81. public string ClientIp { get; set; }
  82. [SugarColumn(ColumnName = "elapsed_ms")]
  83. public int ElapsedMs { get; set; }
  84. [SugarColumn(ColumnName = "create_time")]
  85. public DateTime CreateTime { get; set; }
  86. [SugarColumn(ColumnName = "update_time")]
  87. public DateTime UpdateTime { get; set; }
  88. }
  89. /// <summary>入站原始信封归档。不走 CodeFirst。</summary>
  90. [SugarTable("mdp_inbound_envelope", "入站原始信封归档")]
  91. public class MdpInboundEnvelope
  92. {
  93. [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
  94. public long Id { get; set; }
  95. [SugarColumn(ColumnName = "request_id")]
  96. public long RequestId { get; set; }
  97. [SugarColumn(ColumnName = "tenant_id")]
  98. public long TenantId { get; set; }
  99. [SugarColumn(ColumnName = "access_key", Length = 64)]
  100. public string AccessKey { get; set; } = string.Empty;
  101. [SugarColumn(ColumnName = "entity_code", Length = 100)]
  102. public string EntityCode { get; set; } = string.Empty;
  103. [SugarColumn(ColumnName = "path", Length = 300)]
  104. public string Path { get; set; } = string.Empty;
  105. [SugarColumn(ColumnName = "headers_json", ColumnDataType = "text", IsNullable = true)]
  106. public string HeadersJson { get; set; }
  107. [SugarColumn(ColumnName = "body", ColumnDataType = "mediumtext")]
  108. public string Body { get; set; } = string.Empty;
  109. [SugarColumn(ColumnName = "body_sha256", Length = 64)]
  110. public string BodySha256 { get; set; } = string.Empty;
  111. [SugarColumn(ColumnName = "create_time")]
  112. public DateTime CreateTime { get; set; }
  113. }
  114. /// <summary>入站全量快照批次。不走 CodeFirst。</summary>
  115. [SugarTable("mdp_inbound_snapshot", "入站全量快照批次")]
  116. public class MdpInboundSnapshot
  117. {
  118. [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
  119. public long Id { get; set; }
  120. [SugarColumn(ColumnName = "snapshot_id", Length = 64)]
  121. public string SnapshotId { get; set; } = string.Empty;
  122. [SugarColumn(ColumnName = "tenant_id")]
  123. public long TenantId { get; set; }
  124. [SugarColumn(ColumnName = "access_key", Length = 64)]
  125. public string AccessKey { get; set; } = string.Empty;
  126. [SugarColumn(ColumnName = "entity_code", Length = 100)]
  127. public string EntityCode { get; set; } = string.Empty;
  128. [SugarColumn(ColumnName = "status", Length = 16)]
  129. public string Status { get; set; } = "OPEN";
  130. [SugarColumn(ColumnName = "last_seq")]
  131. public int LastSeq { get; set; }
  132. [SugarColumn(ColumnName = "row_count")]
  133. public int RowCount { get; set; }
  134. [SugarColumn(ColumnName = "diff_missing", IsNullable = true)]
  135. public int? DiffMissing { get; set; }
  136. [SugarColumn(ColumnName = "diff_ratio", DecimalDigits = 4, IsNullable = true)]
  137. public decimal? DiffRatio { get; set; }
  138. [SugarColumn(ColumnName = "opened_at")]
  139. public DateTime OpenedAt { get; set; }
  140. [SugarColumn(ColumnName = "expire_at")]
  141. public DateTime ExpireAt { get; set; }
  142. [SugarColumn(ColumnName = "committed_at", IsNullable = true)]
  143. public DateTime? CommittedAt { get; set; }
  144. [SugarColumn(ColumnName = "create_time")]
  145. public DateTime CreateTime { get; set; }
  146. [SugarColumn(ColumnName = "update_time")]
  147. public DateTime UpdateTime { get; set; }
  148. }
  149. /// <summary>主数据镜像键冲突待裁决。不走 CodeFirst。</summary>
  150. [SugarTable("mdp_inbound_conflict", "主数据镜像键冲突待裁决")]
  151. public class MdpInboundConflict
  152. {
  153. [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
  154. public long Id { get; set; }
  155. [SugarColumn(ColumnName = "tenant_id")]
  156. public long TenantId { get; set; }
  157. [SugarColumn(ColumnName = "entity_code", Length = 100)]
  158. public string EntityCode { get; set; } = string.Empty;
  159. [SugarColumn(ColumnName = "biz_key", Length = 300)]
  160. public string BizKey { get; set; } = string.Empty;
  161. [SugarColumn(ColumnName = "source_system", Length = 50)]
  162. public string SourceSystem { get; set; } = string.Empty;
  163. [SugarColumn(ColumnName = "incoming_raw", ColumnDataType = "mediumtext")]
  164. public string IncomingRaw { get; set; } = string.Empty;
  165. [SugarColumn(ColumnName = "mirror_table", Length = 64)]
  166. public string MirrorTable { get; set; } = string.Empty;
  167. [SugarColumn(ColumnName = "conflict_type", Length = 40)]
  168. public string ConflictType { get; set; } = string.Empty;
  169. [SugarColumn(ColumnName = "status", Length = 16)]
  170. public string Status { get; set; } = "PENDING";
  171. [SugarColumn(ColumnName = "resolution", Length = 500, IsNullable = true)]
  172. public string Resolution { get; set; }
  173. [SugarColumn(ColumnName = "create_time")]
  174. public DateTime CreateTime { get; set; }
  175. [SugarColumn(ColumnName = "update_time")]
  176. public DateTime UpdateTime { get; set; }
  177. }
  178. /// <summary>入站对外契约字段两层映射。与 PULL 的 mdp_field_mapping 不是同一张表。</summary>
  179. [SugarTable("mdp_field_map", "入站对外契约字段两层映射")]
  180. public class MdpFieldMap
  181. {
  182. [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
  183. public long Id { get; set; }
  184. [SugarColumn(ColumnName = "tenant_id")]
  185. public long TenantId { get; set; }
  186. [SugarColumn(ColumnName = "entity_code", Length = 100)]
  187. public string EntityCode { get; set; } = string.Empty;
  188. [SugarColumn(ColumnName = "access_key", Length = 64)]
  189. public string AccessKey { get; set; } = "*";
  190. [SugarColumn(ColumnName = "contract_field", Length = 200)]
  191. public string ContractField { get; set; } = string.Empty;
  192. [SugarColumn(ColumnName = "raw_key", Length = 200)]
  193. public string RawKey { get; set; } = string.Empty;
  194. [SugarColumn(ColumnName = "is_required")]
  195. public int IsRequired { get; set; }
  196. [SugarColumn(ColumnName = "status")]
  197. public int Status { get; set; } = 1;
  198. [SugarColumn(ColumnName = "create_time")]
  199. public DateTime CreateTime { get; set; }
  200. [SugarColumn(ColumnName = "update_time")]
  201. public DateTime UpdateTime { get; set; }
  202. }