- Implement RedisCounterService for rate limiting - Implement RuleLoader with timer refresh - Implement RiskEvaluator for local rule evaluation - Implement SamplingService for CAP events - Implement CapEventPublisher for async event publishing - Implement FailoverStrategy for Redis failure handling - Add configuration classes and DI extensions - Add unit tests (9 tests) - Add NuGet publishing script
40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using Fengling.RiskControl.Domain.Aggregates.RiskRules;
|
|
|
|
namespace Fengling.RiskControl.Evaluation;
|
|
|
|
public class RiskEvaluationRequest
|
|
{
|
|
public string MemberId { get; set; } = string.Empty;
|
|
public string EventType { get; set; } = string.Empty;
|
|
public int? Amount { get; set; }
|
|
public string? DeviceFingerprint { get; set; }
|
|
public string? IpAddress { get; set; }
|
|
public Dictionary<string, object> Metadata { get; set; } = new();
|
|
}
|
|
|
|
public class RiskEvaluationResult
|
|
{
|
|
public int TotalScore { get; set; }
|
|
public RiskLevel RiskLevel { get; set; }
|
|
public RiskRuleAction RecommendedAction { get; set; }
|
|
public bool Blocked { get; set; }
|
|
public string Message { get; set; } = string.Empty;
|
|
public List<RiskFactorResult> Factors { get; set; } = new();
|
|
public DateTime EvaluatedAt { get; set; } = DateTime.UtcNow;
|
|
}
|
|
|
|
public class RiskFactorResult
|
|
{
|
|
public string RuleName { get; set; } = string.Empty;
|
|
public string RuleType { get; set; } = string.Empty;
|
|
public int Points { get; set; }
|
|
public string? Detail { get; set; }
|
|
}
|
|
|
|
public enum RiskLevel
|
|
{
|
|
Low = 0,
|
|
Medium = 1,
|
|
High = 2
|
|
}
|