From 65cae5e177e0d22bb1bc1200facf9e145cdcced8 Mon Sep 17 00:00:00 2001
From: Antinew <2357729423@qq.com>
Date: Thu, 16 May 2024 01:56:29 +0900
Subject: [PATCH] 1
---
.../InterfaceForward.Api.csproj | 7 +--
.../InterfaceForwardApiModule.cs | 52 ++++++++++-------
src/InterfaceForward.Api/Program.cs | 31 +++++++---
src/InterfaceForward.Api/appsettings.json | 33 +++++++++--
.../InterfaceRelayUnifyResultDto.cs | 2 +-
...erfaceForward.Application.Contracts.csproj | 4 --
.../Filters/DefaultUnifiedResultHandler.cs | 57 -------------------
.../Filters/DisableUnifiedResultAttribute.cs | 3 -
.../Filters/ForwardAuthorizeFilter.cs | 1 -
.../Filters/ForwardExceptionFilter.cs | 3 +-
.../Filters/GlobalExceptionFilter.cs | 1 -
.../Filters/IUnifiedResultHandler.cs | 11 ----
.../Filters/UnifiedResultFilter.cs | 26 ---------
.../ForwardCore/DefaultForwardFlow.cs | 1 -
.../GlobalUsings.cs | 2 +
.../InterfaceForward.Application.csproj | 8 +--
.../InterfaceForwardApplicationModule.cs | 16 +++++-
.../Services/App/AppsService.cs | 3 +-
.../Services/App/LogService.cs | 8 +--
.../Services/ApplicationService.cs | 2 +-
.../Interface/InterfaceReturnConfigService.cs | 1 -
.../ServiceProviderInterfaceService.cs | 4 +-
.../Interface/SystemInterfaceService.cs | 5 +-
.../Services/InterfaceForwardCommon.cs | 1 -
.../Services/InterfaceForwardService.cs | 3 +-
.../InterfaceMapPublishService.cs | 1 -
.../InterfaceMap/InterfaceMapService.cs | 1 -
.../Parameter/FixedParameterService.cs | 1 -
.../Services/Parameter/ParameterService.cs | 1 -
.../ServiceProviderAccountService.cs | 5 +-
.../ServiceProviderAuthService.cs | 1 -
.../ServiceProviderImportExportService.cs | 1 -
.../ServiceProvider/ServiceProviderService.cs | 3 +-
.../Dtos/UnifyPagedResultDto.cs | 19 -------
.../Dtos/UnifyResultDto.cs | 15 -----
.../Helpers/PublicExtensions.cs | 8 ---
.../InterfaceForward.Domain.Shared.csproj | 5 +-
.../InterfaceEntityTypeConfiguration.cs | 28 ---------
...erfaceMapDetailsEntityTypeConfiguration.cs | 18 ------
.../InterfaceMapEntityTypeConfiguration.cs | 28 ---------
.../InterfaceParamEntityTypeConfiguration.cs | 16 ------
.../InterfaceForward.Infrastructure.csproj | 17 ------
.../InterfaceForwardContext.cs | 21 -------
.../InterfaceForwardInfrastructureModule.cs | 9 ---
.../GlobalUsings.cs | 1 +
.../Services/IInterfaceRepository.cs | 4 +-
.../Interface/Services/InterfaceRepository.cs | 4 +-
.../InterfaceForward.Repositories.csproj | 4 +-
.../IServiceProviderAccountRepository.cs | 2 +-
.../Services/IServiceProviderRepository.cs | 2 +-
.../ServiceProviderAccountRepository.cs | 2 +-
.../Services/ServiceProviderRepository.cs | 2 +-
.../SugarQueryableExtensions.cs | 6 +-
src/InterfaceForward.sln | 30 ----------
54 files changed, 136 insertions(+), 404 deletions(-)
delete mode 100644 src/InterfaceForward.Application/Filters/DefaultUnifiedResultHandler.cs
delete mode 100644 src/InterfaceForward.Application/Filters/DisableUnifiedResultAttribute.cs
delete mode 100644 src/InterfaceForward.Application/Filters/IUnifiedResultHandler.cs
delete mode 100644 src/InterfaceForward.Application/Filters/UnifiedResultFilter.cs
delete mode 100644 src/InterfaceForward.Domain.Shared/Dtos/UnifyPagedResultDto.cs
delete mode 100644 src/InterfaceForward.Domain.Shared/Dtos/UnifyResultDto.cs
delete mode 100644 src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceEntityTypeConfiguration.cs
delete mode 100644 src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceMapDetailsEntityTypeConfiguration.cs
delete mode 100644 src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceMapEntityTypeConfiguration.cs
delete mode 100644 src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceParamEntityTypeConfiguration.cs
delete mode 100644 src/InterfaceForward.Infrastructure/InterfaceForward.Infrastructure.csproj
delete mode 100644 src/InterfaceForward.Infrastructure/InterfaceForwardContext.cs
delete mode 100644 src/InterfaceForward.Infrastructure/InterfaceForwardInfrastructureModule.cs
delete mode 100644 src/InterfaceForward.sln
diff --git a/src/InterfaceForward.Api/InterfaceForward.Api.csproj b/src/InterfaceForward.Api/InterfaceForward.Api.csproj
index 94935ce..86801b8 100644
--- a/src/InterfaceForward.Api/InterfaceForward.Api.csproj
+++ b/src/InterfaceForward.Api/InterfaceForward.Api.csproj
@@ -15,17 +15,12 @@
-
+
-
-
-
-
-
diff --git a/src/InterfaceForward.Api/InterfaceForwardApiModule.cs b/src/InterfaceForward.Api/InterfaceForwardApiModule.cs
index ebfc3b1..93b7252 100644
--- a/src/InterfaceForward.Api/InterfaceForwardApiModule.cs
+++ b/src/InterfaceForward.Api/InterfaceForwardApiModule.cs
@@ -1,33 +1,53 @@
using Fake.AspNetCore;
+using Fake.AspNetCore.Mvc;
+using Fake.AspNetCore.Mvc.Conventions;
using Fake.Authorization;
-using Fake.Helpers;
+using Fake.Autofac;
using Fake.Modularity;
using InterfaceForward.Application;
using InterfaceForward.Application.Filters;
-using InterfaceForward.Repositories;
+using Microsoft.AspNetCore.Mvc;
namespace InterfaceForward.Api;
-[DependsOn(typeof(FakeAspNetCoreModule))]
-[DependsOn(typeof(FakeAuthorizationModule))]
-[DependsOn(typeof(InterfaceForwardRepositoriesModule))]
+[DependsOn(typeof(FakeAutofacModule))]
+[DependsOn(typeof(FakeAspNetCoreMvcModule))]
[DependsOn(typeof(InterfaceForwardApplicationModule))]
public class InterfaceForwardApiModule : FakeModule
{
+ private const string DefaultCorsPolicyName = "default";
public override void ConfigureServices(ServiceConfigurationContext context)
{
var services = context.Services;
+ var configuration = context.Services.GetConfiguration();
// Add services to the container.
services.AddProblemDetails();
- services.AddControllers(options =>
+ services.Configure(options =>
{
options.Filters.AddService();
- options.Filters.AddService();
+ options.Filters.AddService();
});
- services.AddSwagger();
+ services.Configure(options =>
+ {
+ options.AddAssembly(typeof(InterfaceForwardApplicationModule).Assembly);
+ });
+
+ services.AddUnifiedResultFilter();
+ services.AddFakeSwaggerGen();
+
+ services.AddCors(options =>
+ {
+ options.AddPolicy(DefaultCorsPolicyName, builder =>
+ {
+ builder.WithOrigins(configuration.GetSection("App:CorsOrigins").Get() ?? [])
+ .AllowAnyHeader()
+ .AllowAnyMethod()
+ .AllowCredentials();
+ });
+ });
}
public override void ConfigureApplication(ApplicationConfigureContext context)
@@ -36,19 +56,13 @@ public class InterfaceForwardApiModule : FakeModule
// Add Aspire default endpoints.
app.MapDefaultEndpoints();
-
- app.MapGet("/", () => "Hello World!");
// Configure the HTTP request pipeline.
- if (app.Environment.IsDevelopment())
- {
- app.UseSwagger();
- app.UseSwaggerUI(options =>
- {
- options.SwaggerEndpoint("/swagger/v1/swagger.json", "v1");
- options.RoutePrefix = string.Empty;
- });
- }
+ app.UseFakeSwagger();
+
+ app.UseRouting();
+
+ app.UseCors(DefaultCorsPolicyName);
}
}
diff --git a/src/InterfaceForward.Api/Program.cs b/src/InterfaceForward.Api/Program.cs
index a7022db..edbdf93 100644
--- a/src/InterfaceForward.Api/Program.cs
+++ b/src/InterfaceForward.Api/Program.cs
@@ -1,12 +1,27 @@
using InterfaceForward.Api;
+using InterfaceForward.Api.Logs;
+using Serilog;
-var builder = WebApplication.CreateBuilder(args);
+try
+{
+ var builder = WebApplication.CreateSlimBuilder(args);
+ builder.UseSerilogDefault();
+ builder.WebHost.UseUrls(builder.Configuration.GetSection("App:Urls").Get() ?? []);
+ builder.Host.UseAutofac();
+ builder.Services.AddApplication();
-builder.Services.AddApplication();
+ // Add service defaults & Aspire components.
+ builder.AddServiceDefaults();
-// Add service defaults & Aspire components.
-builder.AddServiceDefaults();
-
-var app = builder.Build();
-app.InitializeApplication();
-app.Run();
\ No newline at end of file
+ var app = builder.Build();
+ app.InitializeApplication();
+ app.Run();
+}
+catch (Exception ex)
+{
+ Log.Fatal(ex, "G");
+}
+finally
+{
+ Log.CloseAndFlush();
+}
\ No newline at end of file
diff --git a/src/InterfaceForward.Api/appsettings.json b/src/InterfaceForward.Api/appsettings.json
index 10f68b8..91fe569 100644
--- a/src/InterfaceForward.Api/appsettings.json
+++ b/src/InterfaceForward.Api/appsettings.json
@@ -1,9 +1,30 @@
{
- "Logging": {
- "LogLevel": {
- "Default": "Information",
- "Microsoft.AspNetCore": "Warning"
- }
+ "Serilog": {
+ "MinimumLevel": {
+ "Default": "Debug",
+ "Override": {
+ "Microsoft.AspNetCore": "Debug"
+ }
+ },
+ "Enrich": [
+ "FromLogContext",
+ "WithMachineName",
+ "WithProcessId",
+ "WithThreadId"
+ ],
+ "WriteTo": [
+ {
+ "Name": "Console"
+ }
+ ]
},
- "AllowedHosts": "*"
+ "AllowedHosts": "*",
+ "App": {
+ "Urls": [
+ "http://*:8888"
+ ],
+ "CorsOrigins": [
+ "http://localhost:8888"
+ ]
+ }
}
diff --git a/src/InterfaceForward.Application.Contracts/ForwardCore/InterfaceRelayUnifyResultDto.cs b/src/InterfaceForward.Application.Contracts/ForwardCore/InterfaceRelayUnifyResultDto.cs
index e8f71bb..eb3fd9f 100644
--- a/src/InterfaceForward.Application.Contracts/ForwardCore/InterfaceRelayUnifyResultDto.cs
+++ b/src/InterfaceForward.Application.Contracts/ForwardCore/InterfaceRelayUnifyResultDto.cs
@@ -1,4 +1,4 @@
-using InterfaceForward.Domain.Shared.Dtos;
+using Fake.DomainDrivenDesign.Application.Dtos;
namespace InterfaceForward.Application.Contracts.ForwardCore;
diff --git a/src/InterfaceForward.Application.Contracts/InterfaceForward.Application.Contracts.csproj b/src/InterfaceForward.Application.Contracts/InterfaceForward.Application.Contracts.csproj
index 1b93815..9cd872b 100644
--- a/src/InterfaceForward.Application.Contracts/InterfaceForward.Application.Contracts.csproj
+++ b/src/InterfaceForward.Application.Contracts/InterfaceForward.Application.Contracts.csproj
@@ -9,8 +9,4 @@
-
-
-
-
diff --git a/src/InterfaceForward.Application/Filters/DefaultUnifiedResultHandler.cs b/src/InterfaceForward.Application/Filters/DefaultUnifiedResultHandler.cs
deleted file mode 100644
index b370989..0000000
--- a/src/InterfaceForward.Application/Filters/DefaultUnifiedResultHandler.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-using InterfaceForward.Domain.Shared.Dtos;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.Filters;
-
-namespace InterfaceForward.Application.Filters;
-
-public class DefaultUnifiedResultHandler : IUnifiedResultHandler
-{
- public void HandleActionResult(ResultExecutingContext context)
- {
- // void、Task会被包装成EmptyResult
- if (context.Result is EmptyResult)
- {
- var res = new UnifyResultDto();
- context.Result = new ObjectResult(res);
-
- return;
- }
-
- // string、int、list以及自定义的模型,都会被包装成为ObjectResult
- if (context.Result is ObjectResult objectResult)
- {
- var value = objectResult.Value;
-
- // 已unified的无须再包装
- if (value is UnifyResultDto) return;
-
- var res = new UnifyResultDto