From ba53652de62b80a3bbec6958924372348626d876 Mon Sep 17 00:00:00 2001
From: xiaolipro <2357729423@qq.com>
Date: Fri, 22 Mar 2024 18:12:29 +0800
Subject: [PATCH] 1
---
InterfaceForward.sln.DotSettings.user | 2 +
common.props | 1 +
.../InterfaceForwardApiContractModule.cs | 9 +++
.../Controllers/InterfaceController.cs | 4 +-
.../Filters/CustomerResultAttribute.cs | 8 +++
.../Filters/DefaultUnifiedResultHandler.cs | 56 +++++++++++++++++++
.../Filters/GlobalExceptionFilter.cs | 36 ++++++++++++
.../Filters/IUnifiedResultHandler.cs | 11 ++++
.../Filters/ResultFactory.cs | 19 +++++++
src/InterfaceForward.Api/Filters/Results.cs | 42 ++++++++++++++
.../Filters/UnifiedResultFilter.cs | 26 +++++++++
.../InterfaceForward.Api.csproj | 6 +-
.../InterfaceForwardApiModule.cs | 34 +++++++++++
src/InterfaceForward.Api/Program.cs | 2 +-
.../InterfaceMapEntity.cs | 4 +-
.../InterfaceForward.Domain.csproj | 2 +-
.../InterfaceForward.Infrastructure.csproj | 2 +-
.../InterfaceForward.ServiceDefaults.csproj | 12 ++--
.../GlobalUsings.cs | 1 +
.../InterfaceForward.Domain.Tests.csproj | 29 ++++++++++
.../InterfaceForwardDomainTestModule.cs | 10 ++++
21 files changed, 299 insertions(+), 17 deletions(-)
create mode 100644 InterfaceForward.sln.DotSettings.user
create mode 100644 src/InterfaceForward.Api.Contract/InterfaceForwardApiContractModule.cs
create mode 100644 src/InterfaceForward.Api/Filters/CustomerResultAttribute.cs
create mode 100644 src/InterfaceForward.Api/Filters/DefaultUnifiedResultHandler.cs
create mode 100644 src/InterfaceForward.Api/Filters/GlobalExceptionFilter.cs
create mode 100644 src/InterfaceForward.Api/Filters/IUnifiedResultHandler.cs
create mode 100644 src/InterfaceForward.Api/Filters/ResultFactory.cs
create mode 100644 src/InterfaceForward.Api/Filters/Results.cs
create mode 100644 src/InterfaceForward.Api/Filters/UnifiedResultFilter.cs
create mode 100644 tests/InterfaceForward.Domain.Tests/GlobalUsings.cs
create mode 100644 tests/InterfaceForward.Domain.Tests/InterfaceForward.Domain.Tests.csproj
create mode 100644 tests/InterfaceForward.Domain.Tests/InterfaceForwardDomainTestModule.cs
diff --git a/InterfaceForward.sln.DotSettings.user b/InterfaceForward.sln.DotSettings.user
new file mode 100644
index 0000000..ea7af24
--- /dev/null
+++ b/InterfaceForward.sln.DotSettings.user
@@ -0,0 +1,2 @@
+
+ True
\ No newline at end of file
diff --git a/common.props b/common.props
index 9ad7e59..6dfdd8f 100644
--- a/common.props
+++ b/common.props
@@ -2,6 +2,7 @@
latest
enable
+ enable
diff --git a/src/InterfaceForward.Api.Contract/InterfaceForwardApiContractModule.cs b/src/InterfaceForward.Api.Contract/InterfaceForwardApiContractModule.cs
new file mode 100644
index 0000000..2fdf836
--- /dev/null
+++ b/src/InterfaceForward.Api.Contract/InterfaceForwardApiContractModule.cs
@@ -0,0 +1,9 @@
+using Fake.Modularity;
+using InterfaceForward.Domain;
+
+namespace InterfaceForward.Api.Contract;
+
+[DependsOn(typeof(InterfaceForwardDomainModule))]
+public class InterfaceForwardApiContractModule:FakeModule
+{
+}
\ No newline at end of file
diff --git a/src/InterfaceForward.Api/Controllers/InterfaceController.cs b/src/InterfaceForward.Api/Controllers/InterfaceController.cs
index 90b7372..68f0be9 100644
--- a/src/InterfaceForward.Api/Controllers/InterfaceController.cs
+++ b/src/InterfaceForward.Api/Controllers/InterfaceController.cs
@@ -14,8 +14,8 @@ public class InterfaceController: ControllerBase
///
///
[HttpPost("/SystemInterfacePaginatedList")]
- public async Task> SystemInterfacePaginatedListAsync(SystemInterfacePaginatedInputObjectValue input)
+ public async Task SystemInterfacePaginatedListAsync()
{
- return await _interfaceRepository.GetSystemInterfacePaginatedListAsync(input);
+ return;
}
}
\ No newline at end of file
diff --git a/src/InterfaceForward.Api/Filters/CustomerResultAttribute.cs b/src/InterfaceForward.Api/Filters/CustomerResultAttribute.cs
new file mode 100644
index 0000000..5854bff
--- /dev/null
+++ b/src/InterfaceForward.Api/Filters/CustomerResultAttribute.cs
@@ -0,0 +1,8 @@
+using System;
+
+namespace InterfaceForward.Api.Filters;
+
+public class CustomerResultAttribute : Attribute
+{
+
+}
\ No newline at end of file
diff --git a/src/InterfaceForward.Api/Filters/DefaultUnifiedResultHandler.cs b/src/InterfaceForward.Api/Filters/DefaultUnifiedResultHandler.cs
new file mode 100644
index 0000000..c7d422b
--- /dev/null
+++ b/src/InterfaceForward.Api/Filters/DefaultUnifiedResultHandler.cs
@@ -0,0 +1,56 @@
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Filters;
+
+namespace InterfaceForward.Api.Filters;
+
+public class DefaultUnifiedResultHandler : IUnifiedResultHandler
+{
+ public void HandleActionResult(ResultExecutingContext context)
+ {
+ // void、Task会被包装成EmptyResult
+ if (context.Result is EmptyResult)
+ {
+ var res = ResultFactory.CreateSimpleResult();
+ context.Result = new ObjectResult(res);
+
+ return;
+ }
+
+ // string、int、list以及自定义的模型,都会被包装成为ObjectResult
+ if (context.Result is ObjectResult objectResult)
+ {
+ var value = objectResult.Value;
+
+ // 已unified的无须再包装
+ if (value is SimpleResult) return;
+
+ var res = ResultFactory.CreateDataResult