OverrideRuleDTO.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. [IgnoreInsert, IgnoreUpdate]
  38. public int current_daily_calls { get; set; } = 0;
  39. [IgnoreInsert, IgnoreUpdate]
  40. public int current_hourly_calls { get; set; } = 0;
  41. /// <summary>
  42. /// 是否验证参数:0不限制, 1入参special_text=1 时才匹配
  43. /// </summary>
  44. public int use_special_text { get; set; }
  45. public int sort { get; set; }
  46. /// <summary>
  47. /// 命中规则后覆写的响应结果 success:true成功,false失败
  48. /// </summary>
  49. [JsonConverter(typeof(NumericBooleanConverter))]
  50. public bool response_success { get; set; } = true;
  51. /// <summary>
  52. /// 命中规则后覆写的 message,为空时沿用默认值
  53. /// </summary>
  54. public string response_message { get; set; } = string.Empty;
  55. /// <summary>
  56. /// 命中规则后覆写的 reason(同时作为 sub_message 输出),为空时沿用默认值
  57. /// </summary>
  58. public string response_reason { get; set; } = string.Empty;
  59. public string ResolveMessage(string fallback) => string.IsNullOrEmpty(response_message) ? fallback : response_message;
  60. public string ResolveReason(string fallback) => string.IsNullOrEmpty(response_reason) ? fallback : response_reason;
  61. public OverrideRuleDTO Clone() => (OverrideRuleDTO)MemberwiseClone();
  62. }
  63. }