first commit
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
namespace F9WebAiTest.Domain.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// DDD 聚合根基类:BusinessEntity + 领域事件。
|
||||
/// 聚合根是聚合的入口与唯一代表,外部只能通过聚合根访问聚合内部对象,通过仓储持久化。
|
||||
/// 参考 BBIT.F9.Domain.Entities.AggregateRoot
|
||||
/// </summary>
|
||||
public abstract class AggregateRoot : BusinessEntity, IAggregateRoot
|
||||
{
|
||||
private readonly List<IDomainEvent> _domainEvents = new();
|
||||
public IReadOnlyCollection<IDomainEvent> DomainEvents => _domainEvents.AsReadOnly();
|
||||
|
||||
protected void AddDomainEvent(IDomainEvent domainEvent) => _domainEvents.Add(domainEvent);
|
||||
|
||||
public void ClearDomainEvents() => _domainEvents.Clear();
|
||||
}
|
||||
|
||||
/// <summary>聚合根标记接口</summary>
|
||||
public interface IAggregateRoot
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user