增加领域事件定义,增加MassTransit 发布事件
continuous-integration/drone/push Build is failing

This commit is contained in:
hang
2024-08-19 23:32:53 +08:00
parent 021b32587a
commit 00827e9975
6 changed files with 137 additions and 12 deletions
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IRaCIS.Core.Domain.BaseModel
{
/// <summary>
/// 领域实体事件基类
/// </summary>
public abstract class DomainEvent
{
}
public class FailedDomainEvent
{
public Guid Id { get; set; }
public string EventType { get; set; }
public string EventData { get; set; }
public DateTime FailedAt { get; set; }
}
}
+41 -5
View File
@@ -1,21 +1,57 @@
using System;
using IRaCIS.Core.Domain.BaseModel;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Security.Cryptography;
namespace IRaCIS.Core.Domain.Models
{
public interface IAggregateRoot;
public interface IEntity<TKey>
{
abstract TKey Id { get; set; }
}
public abstract class Entity : IEntity<Guid>
{
[Key]
[Required]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public Guid Id { get; set; }
#region
private readonly List<DomainEvent> _domainEvents = [];
[NotMapped]
public IReadOnlyCollection<DomainEvent> DomainEvents => _domainEvents.AsReadOnly();
public void AddDomainEvent(DomainEvent domainEvent)
{
_domainEvents.Add(domainEvent);
}
public void RemoveDomainEvent(DomainEvent domainEvent)
{
_domainEvents.Remove(domainEvent);
}
public void ClearDomainEvents()
{
_domainEvents.Clear();
}
#endregion
}
public interface IEntity<TKey>
{
abstract TKey Id { get; set; }
}
#region