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