60 lines
1.8 KiB
C#
60 lines
1.8 KiB
C#
using NetCorePal.Extensions.Domain;
|
|
|
|
namespace Fengling.RiskControl.Domain.Aggregates.RiskAlerts;
|
|
|
|
public class RiskAlert : Entity<long>, IAggregateRoot
|
|
{
|
|
public long MemberId { get; private set; }
|
|
public string AlertType { get; private set; } = string.Empty;
|
|
public string Description { get; private set; } = string.Empty;
|
|
public RiskAlertPriority Priority { get; private set; }
|
|
public RiskAlertStatus Status { get; private set; } = RiskAlertStatus.Pending;
|
|
public string? ResolutionNotes { get; private set; }
|
|
public long? AssignedTo { get; private set; }
|
|
public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;
|
|
public DateTime? ResolvedAt { get; private set; }
|
|
|
|
private RiskAlert() { }
|
|
|
|
public static RiskAlert Create(long memberId, string alertType, string description,
|
|
RiskAlertPriority priority = RiskAlertPriority.Medium)
|
|
{
|
|
return new RiskAlert
|
|
{
|
|
MemberId = memberId,
|
|
AlertType = alertType,
|
|
Description = description,
|
|
Priority = priority,
|
|
Status = RiskAlertStatus.Pending
|
|
};
|
|
}
|
|
|
|
public void Resolve(string notes)
|
|
{
|
|
Status = RiskAlertStatus.Resolved;
|
|
ResolutionNotes = notes;
|
|
ResolvedAt = DateTime.UtcNow;
|
|
}
|
|
|
|
public void Dismiss(string notes)
|
|
{
|
|
Status = RiskAlertStatus.Dismissed;
|
|
ResolutionNotes = notes;
|
|
ResolvedAt = DateTime.UtcNow;
|
|
}
|
|
|
|
public void Escalate()
|
|
{
|
|
Priority = Priority == RiskAlertPriority.Critical
|
|
? RiskAlertPriority.Critical
|
|
: Priority + 1;
|
|
Status = RiskAlertStatus.Investigating;
|
|
}
|
|
|
|
public void AssignTo(long adminId)
|
|
{
|
|
AssignedTo = adminId;
|
|
Status = RiskAlertStatus.Investigating;
|
|
}
|
|
}
|