OverrideRuleDTO.cs 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using dodohold.core;
  2. using System.Text.Json.Serialization;
  3. using YunhuiKit;
  4. namespace molilian.core
  5. {
  6. [Table("tk_override_rules")]
  7. public class OverrideRuleDTO
  8. {
  9. [Key]
  10. public int id { get; set; }
  11. public string platform { get; set; } = string.Empty;
  12. public string original_text { get; set; } = string.Empty;
  13. public string rule { get; set; } = string.Empty;
  14. public string output_text { get; set; } = string.Empty;
  15. public string output_type { get; set; } = string.Empty;
  16. [JsonConverter(typeof(NumericBooleanConverter))]
  17. public bool status { get; set; }
  18. [IgnoreUpdate]
  19. [JsonConverter(typeof(NullableDateTimeConverter))]
  20. public DateTime create_time { get; set; }
  21. [JsonConverter(typeof(NullableDateTimeConverter))]
  22. public DateTime last_time { get; set; }
  23. /// <summary>
  24. /// 备注
  25. /// </summary>
  26. public string description { get; set; } = string.Empty;
  27. [JsonConverter(typeof(NumericBooleanConverter))]
  28. public bool use_risk_control { get; set; }
  29. /// <summary>
  30. /// 每日最高调用次数限制
  31. /// </summary>
  32. public int daily_calls_limit { get; set; } = 0;
  33. /// <summary>
  34. /// 每小时最高调用次数限制
  35. /// </summary>
  36. public int hourly_calls_limit { get; set; } = 0;
  37. /// <summary>当日触发次数,包含超限后未重写的请求。</summary>
  38. [IgnoreInsert, IgnoreUpdate]
  39. public int current_daily_calls { get; set; } = 0;
  40. /// <summary>当前小时触发次数,包含超限后未重写的请求。</summary>
  41. [IgnoreInsert, IgnoreUpdate]
  42. public int current_hourly_calls { get; set; } = 0;
  43. /// <summary>当日实际重写次数,与覆写响应中的 success 值无关。</summary>
  44. [IgnoreInsert, IgnoreUpdate]
  45. public int current_daily_rewrites { get; set; } = 0;
  46. /// <summary>当前小时实际重写次数,与覆写响应中的 success 值无关。</summary>
  47. [IgnoreInsert, IgnoreUpdate]
  48. public int current_hourly_rewrites { get; set; } = 0;
  49. /// <summary>
  50. /// 是否验证参数:0不限制, 1入参special_text=1 时才匹配
  51. /// </summary>
  52. public int use_special_text { get; set; }
  53. public int sort { get; set; }
  54. /// <summary>
  55. /// 命中规则后覆写的响应结果 success:true成功,false失败
  56. /// </summary>
  57. [JsonConverter(typeof(NumericBooleanConverter))]
  58. public bool response_success { get; set; } = true;
  59. /// <summary>
  60. /// 命中规则后覆写的 message,为空时沿用默认值
  61. /// </summary>
  62. public string response_message { get; set; } = string.Empty;
  63. /// <summary>
  64. /// 命中规则后覆写的 reason(同时作为 sub_message 输出),为空时沿用默认值
  65. /// </summary>
  66. public string response_reason { get; set; } = string.Empty;
  67. public string ResolveMessage(string fallback) => string.IsNullOrEmpty(response_message) ? fallback : response_message;
  68. public string ResolveReason(string fallback) => string.IsNullOrEmpty(response_reason) ? fallback : response_reason;
  69. public OverrideRuleDTO Clone() => (OverrideRuleDTO)MemberwiseClone();
  70. }
  71. }