diff --git a/ds-wms-service/DS.WMS.FinanceApi/Program.cs b/ds-wms-service/DS.WMS.FinanceApi/Program.cs index 3a913c16..1db6f8df 100644 --- a/ds-wms-service/DS.WMS.FinanceApi/Program.cs +++ b/ds-wms-service/DS.WMS.FinanceApi/Program.cs @@ -1,5 +1,5 @@ -using Ds.WMS.WebCore; -using DS.Module.Swagger; +using Ds.WMS.WebCore.appextend; +using Ds.WMS.WebCore.appstartup; var builder = WebApplication.CreateBuilder(args).UseMyConfiguration(); @@ -15,22 +15,7 @@ builder.Services.AddControllers(options => builder.UseDynamicStartups(); var app = builder.Build(); +// 中间件 +app.UseMyMiddlewares(); -app.UseMiddleware(); -app.UseMiddleware(); -// 启用中间件服务生成 Swagger 作为 JSON 终结点 -app.UseSwagger(); - -// 启用中间件服务对 swagger-ui,指定 Swagger JSON 终结点 -app.UseSwaggerDocumentation(); - -app.UseHttpsRedirection(); - -app.UseRouting(); -app.UseEndpoints(endpoints => -{ - endpoints.MapControllers(); -}); -// 顺序放在最后即可 -app.UseDynamicStartups(); app.Run(); \ No newline at end of file diff --git a/ds-wms-service/Ds.Module.AppMiddlewareLibrary/ApplicationBuilderExtensions.cs b/ds-wms-service/Ds.Module.AppMiddlewareLibrary/ApplicationBuilderExtensions.cs new file mode 100644 index 00000000..5ef6c1ec --- /dev/null +++ b/ds-wms-service/Ds.Module.AppMiddlewareLibrary/ApplicationBuilderExtensions.cs @@ -0,0 +1,43 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +#region << 鐗 鏈 娉 閲 >> + +/* +* 鐗堟潈鎵鏈 锛坈锛2024 淇濈暀鎵鏈夋潈 +* CLR鐗堟湰 4.0.30319.42000 +* +* +* +* +* +* +*/ + +#endregion << 鐗 鏈 娉 閲 >> + +namespace Ds.Module.AppMiddlewareLibrary +{ + public static class ApplicationBuilderExtensions + { + public static IApplicationBuilder UseMyMiddlewares(this IApplicationBuilder app) + { + app.UseMiddleware(); + app.UseMiddleware(); + app.UseSwagger(); + app.UseSwaggerDocumentation(); + app.UseHttpsRedirection(); + app.UseRouting(); + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + app.UseDynamicStartups(); + + return app; + } + } +} \ No newline at end of file diff --git a/ds-wms-service/Ds.Module.AppMiddlewareLibrary/Ds.Module.AppMiddlewareLibrary.csproj b/ds-wms-service/Ds.Module.AppMiddlewareLibrary/Ds.Module.AppMiddlewareLibrary.csproj new file mode 100644 index 00000000..fa71b7ae --- /dev/null +++ b/ds-wms-service/Ds.Module.AppMiddlewareLibrary/Ds.Module.AppMiddlewareLibrary.csproj @@ -0,0 +1,9 @@ +锘 + + + net8.0 + enable + enable + + + diff --git a/ds-wms-service/Ds.WMS.WebCore/appextend/ApplicationBuilderExtensions.cs b/ds-wms-service/Ds.WMS.WebCore/appextend/ApplicationBuilderExtensions.cs new file mode 100644 index 00000000..bf6309e6 --- /dev/null +++ b/ds-wms-service/Ds.WMS.WebCore/appextend/ApplicationBuilderExtensions.cs @@ -0,0 +1,48 @@ +锘縰sing Ds.WMS.WebCore.appfilter; +using Ds.WMS.WebCore.applog; +using Ds.WMS.WebCore.appstartup; +using DS.Module.Swagger; +using Microsoft.AspNetCore.Builder; + +#region << 鐗 鏈 娉 閲 >> + +/* +* 鐗堟潈鎵鏈 锛坈锛2024 淇濈暀鎵鏈夋潈 +* CLR鐗堟湰 4.0.30319.42000 +* +* +* +* +* +* +*/ + +#endregion << 鐗 鏈 娉 閲 >> + +namespace Ds.WMS.WebCore.appextend +{ + public static class ApplicationBuilderExtensions + { + /// + ///涓轰簡璁╀富Progarm.cs鏂囦欢鏇村姞绠娲侊紝鎴戜滑灏嗕竴浜涗腑闂翠欢鐨勯厤缃斁鍒拌繖閲 + /// + /// + /// + public static WebApplication UseMyMiddlewares(this WebApplication app) + { + app.UseMiddleware(); + app.UseMiddleware(); + app.UseSwagger(); + app.UseSwaggerDocumentation(); + app.UseHttpsRedirection(); + app.UseRouting(); + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + app.UseDynamicStartups(); + + return app; + } + } +} \ No newline at end of file diff --git a/ds-wms-service/Ds.WMS.WebCore/ActionResultHelper.cs b/ds-wms-service/Ds.WMS.WebCore/appfilter/ActionResultHelper.cs similarity index 97% rename from ds-wms-service/Ds.WMS.WebCore/ActionResultHelper.cs rename to ds-wms-service/Ds.WMS.WebCore/appfilter/ActionResultHelper.cs index 725fd195..d6058dcd 100644 --- a/ds-wms-service/Ds.WMS.WebCore/ActionResultHelper.cs +++ b/ds-wms-service/Ds.WMS.WebCore/appfilter/ActionResultHelper.cs @@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; -namespace Ds.WMS.WebCore +namespace Ds.WMS.WebCore.appfilter { public static class ActionResultHelper { diff --git a/ds-wms-service/Ds.WMS.WebCore/CustomObjectResult.cs b/ds-wms-service/Ds.WMS.WebCore/appfilter/CustomObjectResult.cs similarity index 88% rename from ds-wms-service/Ds.WMS.WebCore/CustomObjectResult.cs rename to ds-wms-service/Ds.WMS.WebCore/appfilter/CustomObjectResult.cs index 62382a3a..67e7282c 100644 --- a/ds-wms-service/Ds.WMS.WebCore/CustomObjectResult.cs +++ b/ds-wms-service/Ds.WMS.WebCore/appfilter/CustomObjectResult.cs @@ -1,6 +1,6 @@ 锘縰sing Microsoft.AspNetCore.Mvc; -namespace Ds.WMS.WebCore +namespace Ds.WMS.WebCore.appfilter { public class CustomObjectResult : ObjectResult { diff --git a/ds-wms-service/Ds.WMS.WebCore/DsAppActionFilter.cs b/ds-wms-service/Ds.WMS.WebCore/appfilter/DsAppActionFilter.cs similarity index 98% rename from ds-wms-service/Ds.WMS.WebCore/DsAppActionFilter.cs rename to ds-wms-service/Ds.WMS.WebCore/appfilter/DsAppActionFilter.cs index 50d9e15f..cd070927 100644 --- a/ds-wms-service/Ds.WMS.WebCore/DsAppActionFilter.cs +++ b/ds-wms-service/Ds.WMS.WebCore/appfilter/DsAppActionFilter.cs @@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.DependencyInjection; -namespace Ds.WMS.WebCore +namespace Ds.WMS.WebCore.appfilter { public class DsAppActionFilter : ActionFilterAttribute { diff --git a/ds-wms-service/Ds.WMS.WebCore/RequestLoggingMiddleware.cs b/ds-wms-service/Ds.WMS.WebCore/appfilter/RequestLoggingMiddleware.cs similarity index 86% rename from ds-wms-service/Ds.WMS.WebCore/RequestLoggingMiddleware.cs rename to ds-wms-service/Ds.WMS.WebCore/appfilter/RequestLoggingMiddleware.cs index 419c0fde..288ceb7d 100644 --- a/ds-wms-service/Ds.WMS.WebCore/RequestLoggingMiddleware.cs +++ b/ds-wms-service/Ds.WMS.WebCore/appfilter/RequestLoggingMiddleware.cs @@ -1,9 +1,9 @@ 锘縰sing Microsoft.AspNetCore.Http; -namespace Ds.WMS.WebCore +namespace Ds.WMS.WebCore.appfilter { /// - /// 璇锋眰涓棿浠 鐢ㄤ簬璁板綍璇锋眰淇℃伅 + /// 璇锋眰涓棿浠 鐢ㄤ簬璁板綍璇锋眰淇℃伅 /// public class RequestLoggingMiddleware { @@ -23,4 +23,4 @@ namespace Ds.WMS.WebCore await _next(context); } } -} +} \ No newline at end of file diff --git a/ds-wms-service/Ds.WMS.WebCore/GlobalExceptionHandler.cs b/ds-wms-service/Ds.WMS.WebCore/applog/GlobalExceptionHandler.cs similarity index 98% rename from ds-wms-service/Ds.WMS.WebCore/GlobalExceptionHandler.cs rename to ds-wms-service/Ds.WMS.WebCore/applog/GlobalExceptionHandler.cs index 06dbbb18..196ccfe6 100644 --- a/ds-wms-service/Ds.WMS.WebCore/GlobalExceptionHandler.cs +++ b/ds-wms-service/Ds.WMS.WebCore/applog/GlobalExceptionHandler.cs @@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Http; using Newtonsoft.Json; using System.Net; -namespace Ds.WMS.WebCore +namespace Ds.WMS.WebCore.applog { public class GlobalExceptionHandler { diff --git a/ds-wms-service/Ds.WMS.WebCore/WebApplicationBuilderExtensions.cs b/ds-wms-service/Ds.WMS.WebCore/appstartup/WebApplicationBuilderExtensions.cs similarity index 98% rename from ds-wms-service/Ds.WMS.WebCore/WebApplicationBuilderExtensions.cs rename to ds-wms-service/Ds.WMS.WebCore/appstartup/WebApplicationBuilderExtensions.cs index 2bc4bd4b..562510fd 100644 --- a/ds-wms-service/Ds.WMS.WebCore/WebApplicationBuilderExtensions.cs +++ b/ds-wms-service/Ds.WMS.WebCore/appstartup/WebApplicationBuilderExtensions.cs @@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; using System.Reflection; -namespace Ds.WMS.WebCore +namespace Ds.WMS.WebCore.appstartup { /// /// diff --git a/ds-wms-service/Ds.WMS.WebCore/WebApplicationFactoryExtensions.cs b/ds-wms-service/Ds.WMS.WebCore/appstartup/WebApplicationFactoryExtensions.cs similarity index 96% rename from ds-wms-service/Ds.WMS.WebCore/WebApplicationFactoryExtensions.cs rename to ds-wms-service/Ds.WMS.WebCore/appstartup/WebApplicationFactoryExtensions.cs index 2c1685fd..c5923a2f 100644 --- a/ds-wms-service/Ds.WMS.WebCore/WebApplicationFactoryExtensions.cs +++ b/ds-wms-service/Ds.WMS.WebCore/appstartup/WebApplicationFactoryExtensions.cs @@ -1,12 +1,10 @@ 锘縰sing Microsoft.AspNetCore.Builder; using Microsoft.Extensions.Configuration; -namespace Ds.WMS.WebCore +namespace Ds.WMS.WebCore.appstartup { public static class WebApplicationFactoryExtensions { - - public static WebApplicationBuilder UseMyConfiguration(this WebApplicationBuilder builder) { // 鑾峰彇搴旂敤绋嬪簭鐨勫伐浣滅洰褰 @@ -27,6 +25,4 @@ namespace Ds.WMS.WebCore return builder; } } - - -} +} \ No newline at end of file diff --git a/ds-wms-service/ds-wms-service.sln b/ds-wms-service/ds-wms-service.sln index 3569a7b1..030caac3 100644 --- a/ds-wms-service/ds-wms-service.sln +++ b/ds-wms-service/ds-wms-service.sln @@ -59,7 +59,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ds.WMS.Finance.MediatR", "D EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ds.WMS.WebCore", "Ds.WMS.WebCore\Ds.WMS.WebCore.csproj", "{9FB4A2AF-2414-4258-8B16-287EA3EB098D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ds.WMS.MogonDb", "Ds.WMS.MogonDb\Ds.WMS.MogonDb.csproj", "{47702656-3E62-4477-B72C-ADA39034B5A7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ds.WMS.MogonDb", "Ds.WMS.MogonDb\Ds.WMS.MogonDb.csproj", "{47702656-3E62-4477-B72C-ADA39034B5A7}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution