@@ -1,23 +1,18 @@
|
||||
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
|
||||
namespace IRaCIS.Core.Domain.BaseModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 领域实体事件基类
|
||||
/// </summary>
|
||||
public abstract class DomainEvent
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class FailedDomainEvent
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string EventType { get; set; } = string.Empty;
|
||||
public string EventData { get; set; } = string.Empty;
|
||||
public DateTime FailedAt { get; set; }
|
||||
public class FailedDomainEvent
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string EventType { get; set; } = string.Empty;
|
||||
public string EventData { get; set; } = string.Empty;
|
||||
public DateTime FailedAt { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,126 +1,123 @@
|
||||
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>
|
||||
namespace IRaCIS.Core.Domain.Models
|
||||
{
|
||||
abstract TKey Id { get; set; }
|
||||
|
||||
}
|
||||
|
||||
//针对dicom
|
||||
public interface IEntitySeqId
|
||||
{
|
||||
public Guid SeqId { get; set; }
|
||||
}
|
||||
|
||||
public abstract class Entity : IEntity<Guid>
|
||||
{
|
||||
[Key]
|
||||
[Required]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
|
||||
#region 领域事件 仅仅允许通过提供的方法进行操作
|
||||
[JsonIgnore]
|
||||
private readonly List<DomainEvent> _domainEvents = [];
|
||||
|
||||
[JsonIgnore]
|
||||
[NotMapped]
|
||||
public IReadOnlyCollection<DomainEvent> DomainEvents => _domainEvents.AsReadOnly();
|
||||
|
||||
|
||||
public void AddDomainEvent(DomainEvent domainEvent)
|
||||
public interface IAggregateRoot;
|
||||
public interface IEntity<TKey>
|
||||
{
|
||||
_domainEvents.Add(domainEvent);
|
||||
abstract TKey Id { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public void RemoveDomainEvent(DomainEvent domainEvent)
|
||||
//针对dicom
|
||||
public interface IEntitySeqId
|
||||
{
|
||||
_domainEvents.Remove(domainEvent);
|
||||
public Guid SeqId { get; set; }
|
||||
}
|
||||
|
||||
public void ClearDomainEvents()
|
||||
public abstract class Entity : IEntity<Guid>
|
||||
{
|
||||
_domainEvents.Clear();
|
||||
[Key]
|
||||
[Required]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
|
||||
#region 领域事件 仅仅允许通过提供的方法进行操作
|
||||
[JsonIgnore]
|
||||
private readonly List<DomainEvent> _domainEvents = [];
|
||||
|
||||
[JsonIgnore]
|
||||
[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
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#region 减少实体属性,增加基类
|
||||
|
||||
public abstract class BaseAddAuditEntity : Entity, IAuditAdd
|
||||
{
|
||||
|
||||
public Guid CreateUserId { get; set; }
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
[ForeignKey("CreateUserId")]
|
||||
[JsonIgnore]
|
||||
public virtual User CreateUser { get; set; }
|
||||
}
|
||||
|
||||
public abstract class BaseAddDeleteAuditEntity : Entity, IAuditAdd, ISoftDelete
|
||||
{
|
||||
|
||||
public Guid CreateUserId { get; set; }
|
||||
public DateTime CreateTime { get; set; }
|
||||
public Guid? DeleteUserId { get; set; }
|
||||
public bool IsDeleted { get; set; }
|
||||
public DateTime? DeletedTime { get; set; }
|
||||
|
||||
[ForeignKey("CreateUserId")]
|
||||
[JsonIgnore]
|
||||
public User CreateUser { get; set; }
|
||||
}
|
||||
|
||||
public abstract class BaseFullAuditEntity : Entity, IAuditUpdate, IAuditAdd
|
||||
{
|
||||
public Guid CreateUserId { get; set; }
|
||||
public DateTime CreateTime { get; set; }
|
||||
public Guid UpdateUserId { get; set; }
|
||||
public DateTime UpdateTime { get; set; }
|
||||
|
||||
[ForeignKey("CreateUserId")]
|
||||
[JsonIgnore]
|
||||
public User CreateUser { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public abstract class BaseFullDeleteAuditEntity : Entity, IAuditUpdate, IAuditAdd, ISoftDelete
|
||||
{
|
||||
public Guid? DeleteUserId { get; set; }
|
||||
public bool IsDeleted { get; set; }
|
||||
public DateTime? DeletedTime { get; set; }
|
||||
public Guid CreateUserId { get; set; }
|
||||
public DateTime CreateTime { get; set; }
|
||||
public Guid UpdateUserId { get; set; }
|
||||
public DateTime UpdateTime { get; set; }
|
||||
|
||||
[ForeignKey("CreateUserId")]
|
||||
[JsonIgnore]
|
||||
public User CreateUser { get; set; }
|
||||
}
|
||||
|
||||
public abstract class BaseAuditUpdateEntity : Entity, IAuditUpdate
|
||||
{
|
||||
public Guid UpdateUserId { get; set; }
|
||||
public DateTime UpdateTime { get; set; }
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#region 减少实体属性,增加基类
|
||||
|
||||
public abstract class BaseAddAuditEntity : Entity, IAuditAdd
|
||||
{
|
||||
|
||||
public Guid CreateUserId { get; set; }
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
[ForeignKey("CreateUserId")]
|
||||
[JsonIgnore]
|
||||
public virtual User CreateUser { get; set; }
|
||||
}
|
||||
|
||||
public abstract class BaseAddDeleteAuditEntity : Entity, IAuditAdd, ISoftDelete
|
||||
{
|
||||
|
||||
public Guid CreateUserId { get; set; }
|
||||
public DateTime CreateTime { get; set; }
|
||||
public Guid? DeleteUserId { get; set; }
|
||||
public bool IsDeleted { get; set; }
|
||||
public DateTime? DeletedTime { get; set; }
|
||||
|
||||
[ForeignKey("CreateUserId")]
|
||||
[JsonIgnore]
|
||||
public User CreateUser { get; set; }
|
||||
}
|
||||
|
||||
public abstract class BaseFullAuditEntity : Entity, IAuditUpdate, IAuditAdd
|
||||
{
|
||||
public Guid CreateUserId { get; set; }
|
||||
public DateTime CreateTime { get; set; }
|
||||
public Guid UpdateUserId { get; set; }
|
||||
public DateTime UpdateTime { get; set; }
|
||||
|
||||
[ForeignKey("CreateUserId")]
|
||||
[JsonIgnore]
|
||||
public User CreateUser { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public abstract class BaseFullDeleteAuditEntity : Entity, IAuditUpdate, IAuditAdd, ISoftDelete
|
||||
{
|
||||
public Guid? DeleteUserId { get; set; }
|
||||
public bool IsDeleted { get; set; }
|
||||
public DateTime? DeletedTime { get; set; }
|
||||
public Guid CreateUserId { get; set; }
|
||||
public DateTime CreateTime { get; set; }
|
||||
public Guid UpdateUserId { get; set; }
|
||||
public DateTime UpdateTime { get; set; }
|
||||
|
||||
[ForeignKey("CreateUserId")]
|
||||
[JsonIgnore]
|
||||
public User CreateUser { get; set; }
|
||||
}
|
||||
|
||||
public abstract class BaseAuditUpdateEntity : Entity, IAuditUpdate
|
||||
{
|
||||
public Guid UpdateUserId { get; set; }
|
||||
public DateTime UpdateTime { get; set; }
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1,23 +1,25 @@
|
||||
using System;
|
||||
|
||||
namespace IRaCIS.Core.Domain.Models;
|
||||
|
||||
public interface IAuditAdd<TKey> where TKey : struct
|
||||
namespace IRaCIS.Core.Domain.Models
|
||||
{
|
||||
public TKey CreateUserId { get; set; }
|
||||
public interface IAuditAdd<TKey> where TKey : struct
|
||||
{
|
||||
public TKey CreateUserId { get; set; }
|
||||
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public interface IAuditAdd : IAuditAdd<Guid>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public interface IAuditAddWithUserName : IAuditAdd<Guid>
|
||||
{
|
||||
public string CreateUser { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public interface IAuditAdd : IAuditAdd<Guid>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public interface IAuditAddWithUserName : IAuditAdd<Guid>
|
||||
{
|
||||
public string CreateUser { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
using System;
|
||||
|
||||
namespace IRaCIS.Core.Domain.Models;
|
||||
|
||||
public interface IAuditUpdate<TKey> where TKey : struct
|
||||
namespace IRaCIS.Core.Domain.Models
|
||||
{
|
||||
public TKey UpdateUserId { get; set; }
|
||||
public DateTime UpdateTime { get; set; }
|
||||
}
|
||||
public interface IAuditUpdate<TKey> where TKey : struct
|
||||
{
|
||||
public TKey UpdateUserId { get; set; }
|
||||
public DateTime UpdateTime { get; set; }
|
||||
}
|
||||
|
||||
public interface IAuditUpdate : IAuditUpdate<Guid>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public interface IAuditUpdate : IAuditUpdate<Guid>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
using System;
|
||||
|
||||
namespace IRaCIS.Core.Domain.Models;
|
||||
|
||||
public interface ISoftDelete<TKey> where TKey : struct
|
||||
namespace IRaCIS.Core.Domain.Models
|
||||
{
|
||||
public TKey? DeleteUserId { get; set; }
|
||||
public bool IsDeleted { get; set; }
|
||||
public interface ISoftDelete<TKey> where TKey : struct
|
||||
{
|
||||
public TKey? DeleteUserId { get; set; }
|
||||
public bool IsDeleted { get; set; }
|
||||
|
||||
public DateTime? DeletedTime { get; set; }
|
||||
}
|
||||
public DateTime? DeletedTime { get; set; }
|
||||
}
|
||||
|
||||
public interface ISoftDelete : ISoftDelete<Guid>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public interface ISoftDelete : ISoftDelete<Guid>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user