127 lines
3.1 KiB
C#
127 lines
3.1 KiB
C#
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; }
|
|
|
|
}
|
|
|
|
//针对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 领域事件 仅仅允许通过提供的方法进行操作
|
|
|
|
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; }
|
|
}
|
|
|
|
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; }
|
|
}
|
|
|
|
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; }
|
|
}
|
|
|
|
|
|
|
|
public abstract class BaseAddAuditEntityWithUserName : Entity, IAuditAddWithUserName
|
|
{
|
|
public string CreateUser { get; set; } = string.Empty;
|
|
|
|
public Guid CreateUserId { get; set; }
|
|
public DateTime CreateTime { get; set; }
|
|
}
|
|
|
|
public abstract class BaseAuditUpdateEntity : Entity, IAuditUpdate
|
|
{
|
|
public Guid UpdateUserId { get; set; }
|
|
public DateTime UpdateTime { get; set; }
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
}
|