| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- using dodohold.core;
- using System.Text.Json.Serialization;
- using YunhuiKit;
- namespace molilian.core
- {
- [Table("tk_override_rules")]
- public class OverrideRuleDTO
- {
- [Key]
- public int id { get; set; }
- public string platform { get; set; } = string.Empty;
- public string original_text { get; set; } = string.Empty;
- public string rule { get; set; } = string.Empty;
- public string output_text { get; set; } = string.Empty;
- public string output_type { get; set; } = string.Empty;
- [JsonConverter(typeof(NumericBooleanConverter))]
- public bool status { get; set; }
- [IgnoreUpdate]
- [JsonConverter(typeof(NullableDateTimeConverter))]
- public DateTime create_time { get; set; }
- [JsonConverter(typeof(NullableDateTimeConverter))]
- public DateTime last_time { get; set; }
- /// <summary>
- /// 备注
- /// </summary>
- public string description { get; set; } = string.Empty;
- [JsonConverter(typeof(NumericBooleanConverter))]
- public bool use_risk_control { get; set; }
- /// <summary>
- /// 每日最高调用次数限制
- /// </summary>
- public int daily_calls_limit { get; set; } = 0;
- /// <summary>
- /// 每小时最高调用次数限制
- /// </summary>
- public int hourly_calls_limit { get; set; } = 0;
- [IgnoreInsert, IgnoreUpdate]
- public int current_daily_calls { get; set; } = 0;
- [IgnoreInsert, IgnoreUpdate]
- public int current_hourly_calls { get; set; } = 0;
- /// <summary>
- /// 是否验证参数:0不限制, 1入参special_text=1 时才匹配
- /// </summary>
- public int use_special_text { get; set; }
- public int sort { get; set; }
- /// <summary>
- /// 命中规则后覆写的响应结果 success:true成功,false失败
- /// </summary>
- [JsonConverter(typeof(NumericBooleanConverter))]
- public bool response_success { get; set; } = true;
- /// <summary>
- /// 命中规则后覆写的 message,为空时沿用默认值
- /// </summary>
- public string response_message { get; set; } = string.Empty;
- /// <summary>
- /// 命中规则后覆写的 reason(同时作为 sub_message 输出),为空时沿用默认值
- /// </summary>
- public string response_reason { get; set; } = string.Empty;
- public string ResolveMessage(string fallback) => string.IsNullOrEmpty(response_message) ? fallback : response_message;
- public string ResolveReason(string fallback) => string.IsNullOrEmpty(response_reason) ? fallback : response_reason;
- public OverrideRuleDTO Clone() => (OverrideRuleDTO)MemberwiseClone();
- }
- }
|