51 lines
1.8 KiB
C#
51 lines
1.8 KiB
C#
using System;
|
|
|
|
namespace YLErp.Modules.RiskEngine
|
|
{
|
|
/// <summary>
|
|
/// 风控规则定义。
|
|
/// 只描述“规则是什么”,不包含状态、策略、触发时点、适用范围等应用配置。
|
|
/// 这些执行维度由 RiskRuleApplication 承载。
|
|
/// </summary>
|
|
public class RiskRule
|
|
{
|
|
// === 基础信息 ===
|
|
public long Id { get; set; }
|
|
public string RuleName { get; set; }
|
|
public string RuleText { get; set; }
|
|
|
|
/// <summary>
|
|
/// 【核心】条件JSON(结构化模式的条件列表存储),如
|
|
/// {"conditions":[{"variableId":1,"operator":">","value":100000000}]}
|
|
/// 由 RuleCompiler 解析并编译为 CompiledScript
|
|
/// </summary>
|
|
public string ConditionJson { get; set; }
|
|
|
|
/// <summary>
|
|
/// 【核心】规则表达式(自由文本模式,类C#表达式)
|
|
/// 由 RuleCompiler 编译为 CompiledScript
|
|
/// </summary>
|
|
public string RuleExpr { get; set; }
|
|
|
|
// === 生命周期 ===
|
|
public int Version { get; set; }
|
|
public bool IsDeleted { get; set; }
|
|
|
|
// === 审计字段 ===
|
|
public int OptId { get; set; }
|
|
public string OptName { get; set; }
|
|
public DateTime OptDate { get; set; }
|
|
public int UpdateOptId { get; set; }
|
|
public string UpdateOptName { get; set; }
|
|
public DateTime UpdateDate { get; set; }
|
|
|
|
// === 运行时内存字段(不持久化到数据库)===
|
|
/// <summary>
|
|
/// 【核心】预编译的可执行委托
|
|
/// 在规则创建/加载时由 RuleCompiler.Compile(this) 生成
|
|
/// 判风控时直接调用:rule.CompiledScript(context) → bool
|
|
/// </summary>
|
|
public Func<RiskContext, bool> CompiledScript { get; set; }
|
|
}
|
|
}
|