整理数据库实体备注
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-09-20 18:20:37 +08:00
parent d3e3ed79ba
commit 40c8a51a31
174 changed files with 5006 additions and 6652 deletions
+13 -15
View File
@@ -1,18 +1,16 @@
namespace IRaCIS.Core.Domain.BaseModel
using System.ComponentModel;
namespace IRaCIS.Core.Domain.BaseModel;
[Description("领域实体事件基类")]
public abstract class DomainEvent
{
/// <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; }
}
+100 -102
View File
@@ -1,107 +1,105 @@
using IRaCIS.Core.Domain.BaseModel;
namespace IRaCIS.Core.Domain.Models
namespace IRaCIS.Core.Domain.Models;
public interface IAggregateRoot;
public interface IEntity<TKey>
{
public interface IAggregateRoot;
public interface IEntity<TKey>
{
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)
{
_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
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)
{
_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
+13 -15
View File
@@ -1,19 +1,17 @@
namespace IRaCIS.Core.Domain.Models
namespace IRaCIS.Core.Domain.Models;
public interface IAuditAdd<TKey> where TKey : struct
{
public interface IAuditAdd<TKey> where TKey : struct
{
public TKey CreateUserId { get; set; }
public TKey CreateUserId { get; set; }
public DateTime CreateTime { get; set; }
public DateTime CreateTime { get; set; }
}
public interface IAuditAdd : IAuditAdd<Guid>
{
}
public interface IAuditAddWithUserName : IAuditAdd<Guid>
{
public string CreateUser { get; set; }
}
}
public interface IAuditAdd : IAuditAdd<Guid>
{
}
public interface IAuditAddWithUserName : IAuditAdd<Guid>
{
public string CreateUser { get; set; }
}
+9 -11
View File
@@ -1,13 +1,11 @@
namespace IRaCIS.Core.Domain.Models
namespace IRaCIS.Core.Domain.Models;
public interface IAuditUpdate<TKey> where TKey : struct
{
public interface IAuditUpdate<TKey> where TKey : struct
{
public TKey UpdateUserId { get; set; }
public DateTime UpdateTime { get; set; }
}
public interface IAuditUpdate : IAuditUpdate<Guid>
{
}
public TKey UpdateUserId { get; set; }
public DateTime UpdateTime { get; set; }
}
public interface IAuditUpdate : IAuditUpdate<Guid>
{
}
+10 -12
View File
@@ -1,15 +1,13 @@
namespace IRaCIS.Core.Domain.Models
namespace IRaCIS.Core.Domain.Models;
public interface ISoftDelete<TKey> where TKey : struct
{
public TKey? DeleteUserId { get; set; }
public bool IsDeleted { get; set; }
public DateTime? DeletedTime { get; set; }
}
public interface ISoftDelete : ISoftDelete<Guid>
{
public interface ISoftDelete<TKey> where TKey : struct
{
public TKey? DeleteUserId { get; set; }
public bool IsDeleted { get; set; }
public DateTime? DeletedTime { get; set; }
}
public interface ISoftDelete : ISoftDelete<Guid>
{
}
}