持久层重构为独立 MiGu.DB 工程并优化集成
- 新增 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 追踪数据库结构 - 优化代码结构,解耦领域与持久层,提升扩展性与安全性
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
using System.Globalization;
|
||||
|
||||
namespace MiGu.Server.SimpleFields;
|
||||
|
||||
public static class SimpleFieldDateTime
|
||||
{
|
||||
public const string StorageFormat = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
public static DateTimeOffset Now => DateTimeOffset.Now;
|
||||
|
||||
public static string ToStorage(DateTimeOffset value) =>
|
||||
value.LocalDateTime.ToString(StorageFormat, CultureInfo.InvariantCulture);
|
||||
|
||||
public static DateTimeOffset FromStorage(string value)
|
||||
{
|
||||
if (DateTime.TryParseExact(value, StorageFormat, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out var local))
|
||||
return new DateTimeOffset(local);
|
||||
|
||||
return DateTimeOffset.Parse(value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
@@ -1,72 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace MiGu.Server.SimpleFields;
|
||||
|
||||
public sealed class SimpleField
|
||||
{
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
/// <summary>车型唯一标识:assemblyName.shortName,如 StandardScene.QrLidar.Forklift。</summary>
|
||||
[MaxLength(64)]
|
||||
public string CarType { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 字段类型唯一标识:assemblyName.shortName,如 StandardScene.QrLidar.Forklift。
|
||||
/// </summary>
|
||||
[MaxLength(64)]
|
||||
public string FieldType { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 字段唯一标识:key,如 Forklift.PositionX。
|
||||
/// </summary>
|
||||
[MaxLength(128)]
|
||||
public string Key { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 字段值,如 10.0。
|
||||
/// </summary>
|
||||
public string Value { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 数据类型,如 System.String。
|
||||
/// </summary>
|
||||
[MaxLength(128)]
|
||||
public string DataType { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 中文名称,如 位置 X。
|
||||
/// </summary>
|
||||
[MaxLength(256)]
|
||||
public string? Chinese { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 英文名称,如 Position X。
|
||||
/// </summary>
|
||||
[MaxLength(256)]
|
||||
public string? English { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 其他语言名称,如 位置 X。
|
||||
/// </summary>
|
||||
[MaxLength(512)]
|
||||
public string Other { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 是否内置默认字段,如 true。
|
||||
/// </summary>
|
||||
public bool IsDefault { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间,如 2021-01-01 12:00:00。
|
||||
/// </summary>
|
||||
public DateTimeOffset CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间,如 2021-01-01 12:00:00。
|
||||
/// </summary>
|
||||
public DateTimeOffset UpdateTime { get; set; }
|
||||
}
|
||||
|
||||
public sealed record SimpleFieldRequest(
|
||||
Guid? Id,
|
||||
string CarType,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using MiGu.Server.Persistence;
|
||||
using MiGu.DB.Domains.SimpleFields;
|
||||
|
||||
namespace MiGu.Server.SimpleFields;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user