Files
Migu2.0/MiGu.DB/Kernel/Entities/EntityBases.cs
T

47 lines
1.5 KiB
C#
Raw Normal View History

using MiGu.DB.Abstractions.Entities;
namespace MiGu.DB.Kernel.Entities;
public abstract class Entity<TKey> : IEntity<TKey>
{
public TKey Id { get; set; } = default!;
}
public abstract class AuditedEntity : Entity<Guid>, IAuditable
{
public DateTimeOffset CreatedAt { get; set; }
public DateTimeOffset UpdatedAt { get; set; }
public string CreatedBy { get; set; } = "";
public string UpdatedBy { get; set; } = "";
}
public abstract class SoftDeletableEntity : AuditedEntity, ISoftDeletable, IVersioned, ILockable
{
public bool IsDeleted { get; set; }
public DateTimeOffset? DeletedAt { get; set; }
public string DeletedBy { get; set; } = "";
public long Version { get; set; }
public bool IsLock { get; set; }
}
public abstract class AggregateRoot : SoftDeletableEntity, IRemarkable, IExtendable
{
public string Remark { get; set; } = "";
public string Extend { get; set; } = "{}";
}
public abstract class HistoryEntity : Entity<Guid>, IHistoryEntry
{
public Guid? RelationId { get; set; }
public string EventType { get; set; } = "";
public string BeforeJson { get; set; } = "{}";
public string AfterJson { get; set; } = "{}";
public Guid? ContainerId { get; set; }
public string Operator { get; set; } = "";
public DateTimeOffset OperatedAt { get; set; }
public string Source { get; set; } = "Manual";
public string Reason { get; set; } = "";
public string Remark { get; set; } = "";
public string Extend { get; set; } = "{}";
}