持久层重构为独立 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:
2026-07-27 14:26:04 +08:00
parent bdcd88608c
commit 51c3fc1994
57 changed files with 6663 additions and 1396 deletions
+20 -3
View File
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using MiGu.DB.Abstractions.Exceptions;
using MiGu.Server.Wms;
namespace MiGu.Server.Controllers;
@@ -276,15 +277,31 @@ public sealed class WmsExceptionFilter : IExceptionFilter
{
public void OnException(ExceptionContext context)
{
if (context.Exception is not InvalidOperationException ex) return;
context.Result = new BadRequestObjectResult(new { message = ex.Message });
switch (context.Exception)
{
case ConcurrencyConflictException ex:
context.Result = new ObjectResult(new { message = ex.Message }) { StatusCode = StatusCodes.Status409Conflict };
break;
case EntityLockedException ex:
context.Result = new ObjectResult(new { message = ex.Message }) { StatusCode = StatusCodes.Status409Conflict };
break;
case EntityNotFoundException ex:
context.Result = new NotFoundObjectResult(new { message = ex.Message });
break;
case InvalidOperationException ex:
context.Result = new BadRequestObjectResult(new { message = ex.Message });
break;
default:
return;
}
context.ExceptionHandled = true;
}
}
public sealed class TransportRequestQuery
{
public string TriggerType { get; set; } = WmsTransportTriggerTypes.MaterialCall;
public string TriggerType { get; set; } = nameof(WmsTransportTriggerType.MaterialCall);
public Guid? RuleId { get; set; }
public string? RequestSiteId { get; set; }
public Guid? MaterialId { get; set; }