- 新增 MiGu.DB 项目,迁移所有领域实体与枚举,统一模型约定 - 实现 Entity/Repository/UoW/Provider/Exception 等接口与实现 - 支持数据修补机制,完善 Sqlite 初始迁移与数据库管理 - Server 侧移除 EF Core 相关,依赖 MiGu.DB,PlatformPersistence 适配 - 业务服务注入 UoW/Repository,状态字段统一用 enum 及辅助类 - 统一异常处理,Controller 映射 HTTP 状态码 - 配置项与文档补充数据库启动、SchemaMode、迁移说明 - 新增 GlobalUsings.Db.cs、WmsStatusAliases.cs 简化类型引用 - 新增 HttpActorContextMiddleware 支持操作者上下文一致性 - 新增 MiGuDbContextModelSnapshot 追踪数据库结构 - 优化代码结构,解耦领域与持久层,提升扩展性与安全性
47 lines
1.5 KiB
C#
47 lines
1.5 KiB
C#
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; } = "{}";
|
|
}
|