添加项目文件。
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
using MassTransit;
|
||||
using MediatR;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace IM.DomainCommons
|
||||
{
|
||||
public class BaseEntity : IEntity, IDomainEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// 这里使用连续guid,防止数据库性能问题
|
||||
/// </summary>
|
||||
public Guid Id { get; private set; } = NewId.NextGuid();
|
||||
|
||||
[NotMapped]
|
||||
public List<INotification> domainEvents = [];
|
||||
|
||||
public void AddDomainEvent(INotification eventItem)
|
||||
{
|
||||
domainEvents.Add(eventItem);
|
||||
}
|
||||
|
||||
public void AddDomainEventIfAbsent(INotification eventItem)
|
||||
{
|
||||
if (!domainEvents.Contains(eventItem))
|
||||
{
|
||||
domainEvents.Add(eventItem);
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearDomainEvents()
|
||||
{
|
||||
domainEvents.Clear();
|
||||
}
|
||||
|
||||
public IEnumerable<INotification> GetDomainEvents()
|
||||
{
|
||||
return domainEvents;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user