From be9eb7615da2c4e9819447346dfe835082e62da8 Mon Sep 17 00:00:00 2001 From: wangjunzzz <> Date: Fri, 26 Dec 2025 10:58:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8D=87=E7=BA=A7abp10?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aspnet-core/Directory.Build.targets | 2 + aspnet-core/Lion.AbpPro.sln | 21 ++-- .../AspNetCore/AbpProAspNetCoreConsts.cs | 12 ++- .../AspNetCore/AbpProAspNetCoreModule.cs | 2 + .../Options/AbpProAntiForgeryOptions.cs | 9 ++ .../AspNetCore/Options/AbpProCookieOptions.cs | 9 ++ .../ServiceCollectionExtensions.cs | 16 +++- .../Swagger/CachingSwaggerProvider.cs | 52 +++++----- .../Swagger/EnumSchemaFilter.cs | 42 ++++---- .../Swagger/HiddenAbpDefaultApiFilter.cs | 96 +++++++++---------- .../AbpProFreeSqlModule.cs | 12 +-- .../FreeSqlBasicRepository.cs | 0 .../GlobalUsings.cs | 0 .../Lion.AbpPro.FreeSqlRepository.csproj | 2 +- .../DatabaseLanguageProvider.cs | 5 +- .../Lion.AbpPro.HttpApi.Host.csproj | 2 +- .../appsettings.Development.json | 67 +++++++++++++ .../appsettings.Production.json | 61 +++--------- .../Lion.AbpPro.HttpApi.Host/appsettings.json | 65 ------------- .../Lion.AbpPro.Application.Contracts.csproj | 7 +- .../AbpProApplicationModule.cs | 3 +- .../Lion.AbpPro.Application/GlobalUsings.cs | 1 - .../Lion.AbpPro.Application.csproj | 1 - .../AbpProDbMigratorModule.cs | 3 +- .../Lion.AbpPro.DbMigrator.csproj | 2 - .../Lion.AbpPro.DbMigrator/appsettings.json | 2 +- .../Users/IUserFreeSqlBasicRepository.cs | 7 -- .../Lion.AbpPro.EntityFrameworkCore.csproj | 3 +- .../UserFreeSqlBasicRepository.cs | 17 ---- .../AbpProFreeSqlRepositoryTestBase.cs | 10 -- .../AbpProFreeSqlRepositoryTestModule.cs | 63 ------------ .../GlobalUsings.cs | 18 ---- ...Lion.AbpPro.FreeSqlRepository.Tests.csproj | 23 ----- .../Users/UserFreeSqlBasicRepository_Tests.cs | 21 ---- 34 files changed, 240 insertions(+), 416 deletions(-) create mode 100644 aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Lion/AbpPro/AspNetCore/Options/AbpProAntiForgeryOptions.cs create mode 100644 aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Lion/AbpPro/AspNetCore/Options/AbpProCookieOptions.cs rename aspnet-core/{services => frameworks}/src/Lion.AbpPro.FreeSqlRepository/AbpProFreeSqlModule.cs (55%) rename aspnet-core/{services => frameworks}/src/Lion.AbpPro.FreeSqlRepository/FreeSqlBasicRepository.cs (100%) rename aspnet-core/{services => frameworks}/src/Lion.AbpPro.FreeSqlRepository/GlobalUsings.cs (100%) rename aspnet-core/{services => frameworks}/src/Lion.AbpPro.FreeSqlRepository/Lion.AbpPro.FreeSqlRepository.csproj (84%) create mode 100644 aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.Development.json delete mode 100644 aspnet-core/services/src/Lion.AbpPro.Domain/Users/IUserFreeSqlBasicRepository.cs delete mode 100644 aspnet-core/services/src/Lion.AbpPro.FreeSqlRepository/UserFreeSqlBasicRepository.cs delete mode 100644 aspnet-core/services/test/Lion.AbpPro.FreeSqlRepository.Tests/AbpProFreeSqlRepositoryTestBase.cs delete mode 100644 aspnet-core/services/test/Lion.AbpPro.FreeSqlRepository.Tests/AbpProFreeSqlRepositoryTestModule.cs delete mode 100644 aspnet-core/services/test/Lion.AbpPro.FreeSqlRepository.Tests/GlobalUsings.cs delete mode 100644 aspnet-core/services/test/Lion.AbpPro.FreeSqlRepository.Tests/Lion.AbpPro.FreeSqlRepository.Tests.csproj delete mode 100644 aspnet-core/services/test/Lion.AbpPro.FreeSqlRepository.Tests/Users/UserFreeSqlBasicRepository_Tests.cs diff --git a/aspnet-core/Directory.Build.targets b/aspnet-core/Directory.Build.targets index 4f3bbd24..fb6f557c 100644 --- a/aspnet-core/Directory.Build.targets +++ b/aspnet-core/Directory.Build.targets @@ -31,6 +31,7 @@ + @@ -50,6 +51,7 @@ + diff --git a/aspnet-core/Lion.AbpPro.sln b/aspnet-core/Lion.AbpPro.sln index 6b6cfb5c..eb33a471 100644 --- a/aspnet-core/Lion.AbpPro.sln +++ b/aspnet-core/Lion.AbpPro.sln @@ -149,10 +149,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lion.AbpPro.FileManagement. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lion.AbpPro.FileManagement.HttpApi.Host", "modules\FileManagement\host\Lion.AbpPro.FileManagement.HttpApi.Host\Lion.AbpPro.FileManagement.HttpApi.Host.csproj", "{831CD22A-AC6E-4515-AB24-8C96B34C717F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lion.AbpPro.FreeSqlRepository", "services\src\Lion.AbpPro.FreeSqlRepository\Lion.AbpPro.FreeSqlRepository.csproj", "{27C7A0E6-4C2E-4AFF-9DE7-1F526DDC0D18}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lion.AbpPro.FreeSqlRepository.Tests", "services\test\Lion.AbpPro.FreeSqlRepository.Tests\Lion.AbpPro.FreeSqlRepository.Tests.csproj", "{7971DF5A-B001-4751-8F40-D7752C612BF1}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "host", "host", "{7FF93622-971D-4B30-A5FC-72D729D26E29}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lion.AbpPro.NotificationManagement.HttpApi.Host", "modules\NotificationManagement\host\Lion.AbpPro.NotificationManagement.HttpApi.Host\Lion.AbpPro.NotificationManagement.HttpApi.Host.csproj", "{FA5E029F-1826-4C1E-8AED-6FA5C3362A3A}" @@ -255,6 +251,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lion.AbpPro.Hangfire", "fra EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lion.AbpPro.SignalR", "frameworks\src\Lion.AbpPro.SignalR\Lion.AbpPro.SignalR.csproj", "{61F9FF69-B06B-4EE6-A34D-6BFA297D3097}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lion.AbpPro.FreeSqlRepository", "frameworks\src\Lion.AbpPro.FreeSqlRepository\Lion.AbpPro.FreeSqlRepository.csproj", "{929F258B-C222-48E5-9668-6FEDF858740F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -461,14 +459,6 @@ Global {831CD22A-AC6E-4515-AB24-8C96B34C717F}.Debug|Any CPU.Build.0 = Debug|Any CPU {831CD22A-AC6E-4515-AB24-8C96B34C717F}.Release|Any CPU.ActiveCfg = Release|Any CPU {831CD22A-AC6E-4515-AB24-8C96B34C717F}.Release|Any CPU.Build.0 = Release|Any CPU - {27C7A0E6-4C2E-4AFF-9DE7-1F526DDC0D18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {27C7A0E6-4C2E-4AFF-9DE7-1F526DDC0D18}.Debug|Any CPU.Build.0 = Debug|Any CPU - {27C7A0E6-4C2E-4AFF-9DE7-1F526DDC0D18}.Release|Any CPU.ActiveCfg = Release|Any CPU - {27C7A0E6-4C2E-4AFF-9DE7-1F526DDC0D18}.Release|Any CPU.Build.0 = Release|Any CPU - {7971DF5A-B001-4751-8F40-D7752C612BF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7971DF5A-B001-4751-8F40-D7752C612BF1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7971DF5A-B001-4751-8F40-D7752C612BF1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7971DF5A-B001-4751-8F40-D7752C612BF1}.Release|Any CPU.Build.0 = Release|Any CPU {FA5E029F-1826-4C1E-8AED-6FA5C3362A3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FA5E029F-1826-4C1E-8AED-6FA5C3362A3A}.Debug|Any CPU.Build.0 = Debug|Any CPU {FA5E029F-1826-4C1E-8AED-6FA5C3362A3A}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -629,6 +619,10 @@ Global {61F9FF69-B06B-4EE6-A34D-6BFA297D3097}.Debug|Any CPU.Build.0 = Debug|Any CPU {61F9FF69-B06B-4EE6-A34D-6BFA297D3097}.Release|Any CPU.ActiveCfg = Release|Any CPU {61F9FF69-B06B-4EE6-A34D-6BFA297D3097}.Release|Any CPU.Build.0 = Release|Any CPU + {929F258B-C222-48E5-9668-6FEDF858740F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {929F258B-C222-48E5-9668-6FEDF858740F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {929F258B-C222-48E5-9668-6FEDF858740F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {929F258B-C222-48E5-9668-6FEDF858740F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -698,8 +692,6 @@ Global {80E12564-E2B3-4307-B40E-20E24BF02916} = {40BF21CB-4520-45A6-A588-5FFB95BAC87C} {78589964-923E-4803-9B74-183487C3ED0F} = {40BF21CB-4520-45A6-A588-5FFB95BAC87C} {831CD22A-AC6E-4515-AB24-8C96B34C717F} = {C188A1F4-9601-42E5-9A0A-B282E13EAC41} - {27C7A0E6-4C2E-4AFF-9DE7-1F526DDC0D18} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} - {7971DF5A-B001-4751-8F40-D7752C612BF1} = {04DBDB01-70F4-4E06-B468-8F87850B22BE} {7FF93622-971D-4B30-A5FC-72D729D26E29} = {EB2B8705-18E7-49E1-A565-93A6DE5570D5} {FA5E029F-1826-4C1E-8AED-6FA5C3362A3A} = {7FF93622-971D-4B30-A5FC-72D729D26E29} {C2FE6BA0-3DE5-403F-A91F-BCB9ADA5B068} = {F8A8EB2A-2D4B-464F-9A13-F8F7B6A8FAA3} @@ -751,6 +743,7 @@ Global {89CCAEA6-8176-4E4B-8D84-A2ACE2715F88} = {7BE85EBC-99AD-4CDE-957E-4BDD087FC4E3} {6C2FDD3D-F711-46B0-A2F2-B94BC33F136B} = {7BE85EBC-99AD-4CDE-957E-4BDD087FC4E3} {61F9FF69-B06B-4EE6-A34D-6BFA297D3097} = {7BE85EBC-99AD-4CDE-957E-4BDD087FC4E3} + {929F258B-C222-48E5-9668-6FEDF858740F} = {7BE85EBC-99AD-4CDE-957E-4BDD087FC4E3} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {28315BFD-90E7-4E14-A2EA-F3D23AF4126F} diff --git a/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Lion/AbpPro/AspNetCore/AbpProAspNetCoreConsts.cs b/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Lion/AbpPro/AspNetCore/AbpProAspNetCoreConsts.cs index cfde401b..9d574479 100644 --- a/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Lion/AbpPro/AspNetCore/AbpProAspNetCoreConsts.cs +++ b/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Lion/AbpPro/AspNetCore/AbpProAspNetCoreConsts.cs @@ -10,7 +10,7 @@ public class AbpProAspNetCoreConsts /// /// Cookies名称 /// - public const string DefaultCookieName = "Lion.AbpPro.Http.Api"; + public const string DefaultCookieName = "Lion.AbpPro"; /// /// Consul网关配置节名称 @@ -46,4 +46,14 @@ public class AbpProAspNetCoreConsts /// token /// public const string Jwt = "Jwt"; + + /// + /// Cookie + /// + public const string Cookie = "Cookie"; + + /// + /// AntiForgery + /// + public const string AntiForgery = "AntiForgery"; } \ No newline at end of file diff --git a/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Lion/AbpPro/AspNetCore/AbpProAspNetCoreModule.cs b/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Lion/AbpPro/AspNetCore/AbpProAspNetCoreModule.cs index 52dc2495..c875b387 100644 --- a/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Lion/AbpPro/AspNetCore/AbpProAspNetCoreModule.cs +++ b/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Lion/AbpPro/AspNetCore/AbpProAspNetCoreModule.cs @@ -15,5 +15,7 @@ public class AbpProAspNetCoreModule : AbpModule context.Services.Configure(context.Configuration.GetSection(AbpProAspNetCoreConsts.Swagger)); context.Services.Configure(context.Configuration.GetSection(AbpProAspNetCoreConsts.Audit)); context.Services.Configure(context.Configuration.GetSection(AbpProAspNetCoreConsts.Jwt)); + context.Services.Configure(context.Configuration.GetSection(AbpProAspNetCoreConsts.Cookie)); + context.Services.Configure(context.Configuration.GetSection(AbpProAspNetCoreConsts.AntiForgery)); } } \ No newline at end of file diff --git a/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Lion/AbpPro/AspNetCore/Options/AbpProAntiForgeryOptions.cs b/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Lion/AbpPro/AspNetCore/Options/AbpProAntiForgeryOptions.cs new file mode 100644 index 00000000..8c039f72 --- /dev/null +++ b/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Lion/AbpPro/AspNetCore/Options/AbpProAntiForgeryOptions.cs @@ -0,0 +1,9 @@ +namespace Lion.AbpPro.AspNetCore.Options; + +public class AbpProAntiForgeryOptions +{ + /// + /// 是否启用 + /// + public bool Enabled { get; set; } +} \ No newline at end of file diff --git a/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Lion/AbpPro/AspNetCore/Options/AbpProCookieOptions.cs b/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Lion/AbpPro/AspNetCore/Options/AbpProCookieOptions.cs new file mode 100644 index 00000000..cb58357a --- /dev/null +++ b/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Lion/AbpPro/AspNetCore/Options/AbpProCookieOptions.cs @@ -0,0 +1,9 @@ +namespace Lion.AbpPro.AspNetCore.Options; + +public class AbpProCookieOptions +{ + /// + /// 名称 + /// + public string Name { get; set; } = AbpProAspNetCoreConsts.DefaultCookieName; +} \ No newline at end of file diff --git a/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Microsoft/Extensions/DependencyInjection/ServiceCollectionExtensions.cs b/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Microsoft/Extensions/DependencyInjection/ServiceCollectionExtensions.cs index 0a44220a..60a4a745 100644 --- a/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Microsoft/Extensions/DependencyInjection/ServiceCollectionExtensions.cs +++ b/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Microsoft/Extensions/DependencyInjection/ServiceCollectionExtensions.cs @@ -4,7 +4,7 @@ using Lion.AbpPro.AspNetCore.Options; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.IdentityModel.Tokens; - +using Swagger; using Volo.Abp.AspNetCore.Auditing; using Volo.Abp.AspNetCore.MultiTenancy; using Volo.Abp.AspNetCore.Mvc.AntiForgery; @@ -128,7 +128,12 @@ public static class ServiceCollectionExtensions /// public static IServiceCollection AddAbpProAntiForgery(this IServiceCollection service) { - service.Configure(options => { options.AutoValidate = false; }); + var antiForgeryOptions = service.BuildServiceProvider().GetRequiredService>().Value; + if (antiForgeryOptions.Enabled) + { + service.Configure(options => { options.AutoValidate = antiForgeryOptions.Enabled; }); + } + return service; } @@ -161,8 +166,8 @@ public static class ServiceCollectionExtensions options.SwaggerDoc(name, new OpenApiInfo { Title = name, Version = version }); options.DocInclusionPredicate((docName, description) => true); //options.EnableAnnotations(); // 启用注解 - //options.DocumentFilter(); - //options.SchemaFilter(); + options.DocumentFilter(); + options.SchemaFilter(); // 加载所有xml注释,这里会导致swagger加载有点缓慢 var xmlPaths = Directory.GetFiles(AppContext.BaseDirectory, "*.xml"); foreach (var xml in xmlPaths) @@ -244,6 +249,7 @@ public static class ServiceCollectionExtensions public static IServiceCollection AddAbpProAuthentication(this IServiceCollection service) { var jwtOptions = service.BuildServiceProvider().GetRequiredService>().Value; + var cookieOptions = service.BuildServiceProvider().GetRequiredService>().Value; service.AddAuthentication(options => { @@ -295,7 +301,7 @@ public static class ServiceCollectionExtensions if (accessToken.IsNullOrWhiteSpace()) { - accessToken = currentContext.Request.Cookies[AbpProAspNetCoreConsts.DefaultCookieName]; + accessToken = currentContext.Request.Cookies[cookieOptions.Name]; } currentContext.Token = accessToken; diff --git a/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Swagger/CachingSwaggerProvider.cs b/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Swagger/CachingSwaggerProvider.cs index ca4b8288..cfd40fd5 100644 --- a/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Swagger/CachingSwaggerProvider.cs +++ b/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Swagger/CachingSwaggerProvider.cs @@ -1,26 +1,26 @@ -// namespace Swagger; -// -// /// -// /// swagger注释加载慢,把文档添加到缓存 -// /// -// [Dependency(ReplaceServices = true)] -// [ExposeServices(typeof(ISwaggerProvider))] -// public class CachingSwaggerProvider : ISwaggerProvider, ITransientDependency -// { -// private static readonly ConcurrentDictionary _cache = new ConcurrentDictionary(); -// -// private readonly SwaggerGenerator _swaggerGenerator; -// -// public CachingSwaggerProvider( -// IOptions optionsAccessor, -// IApiDescriptionGroupCollectionProvider apiDescriptionsProvider, -// ISchemaGenerator schemaGenerator) -// { -// _swaggerGenerator = new SwaggerGenerator(optionsAccessor.Value, apiDescriptionsProvider, schemaGenerator); -// } -// -// public OpenApiDocument GetSwagger(string documentName, string host = null, string basePath = null) -// { -// return _cache.GetOrAdd(documentName, (_) => _swaggerGenerator.GetSwagger(documentName, host, basePath)); -// } -// } \ No newline at end of file +namespace Swagger; + +/// +/// swagger注释加载慢,把文档添加到缓存 +/// +[Dependency(ReplaceServices = true)] +[ExposeServices(typeof(ISwaggerProvider))] +public class CachingSwaggerProvider : ISwaggerProvider, ITransientDependency +{ + private static readonly ConcurrentDictionary _cache = new ConcurrentDictionary(); + + private readonly SwaggerGenerator _swaggerGenerator; + + public CachingSwaggerProvider( + IOptions optionsAccessor, + IApiDescriptionGroupCollectionProvider apiDescriptionsProvider, + ISchemaGenerator schemaGenerator) + { + _swaggerGenerator = new SwaggerGenerator(optionsAccessor.Value, apiDescriptionsProvider, schemaGenerator); + } + + public OpenApiDocument GetSwagger(string documentName, string host = null, string basePath = null) + { + return _cache.GetOrAdd(documentName, (_) => _swaggerGenerator.GetSwagger(documentName, host, basePath)); + } +} \ No newline at end of file diff --git a/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Swagger/EnumSchemaFilter.cs b/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Swagger/EnumSchemaFilter.cs index f0d9fd6e..1197d5de 100644 --- a/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Swagger/EnumSchemaFilter.cs +++ b/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Swagger/EnumSchemaFilter.cs @@ -1,21 +1,21 @@ -// namespace Swagger; -// -// /// -// /// swagger 枚举映射, -// /// 原因:前端代理生成枚举是数字 -// /// -// public class EnumSchemaFilter : ISchemaFilter -// { -// public void Apply(OpenApiSchema schema, SchemaFilterContext context) -// { -// if (context.Type.IsEnum) -// { -// var array = new OpenApiArray(); -// array.AddRange(Enum.GetNames(context.Type).Select(n => new OpenApiString(n))); -// // NSwag -// schema.Extensions.Add("x-enumNames", array); -// // Openapi-generator -// schema.Extensions.Add("x-enum-varnames", array); -// } -// } -// } \ No newline at end of file +namespace Swagger; + +/// +/// swagger 枚举映射, +/// 原因:前端代理生成枚举是数字 +/// +public class EnumSchemaFilter : ISchemaFilter +{ + public void Apply(OpenApiSchema schema, SchemaFilterContext context) + { + if (context.Type.IsEnum) + { + var array = new OpenApiArray(); + array.AddRange(Enum.GetNames(context.Type).Select(n => new OpenApiString(n))); + // NSwag + schema.Extensions.Add("x-enumNames", array); + // Openapi-generator + schema.Extensions.Add("x-enum-varnames", array); + } + } +} \ No newline at end of file diff --git a/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Swagger/HiddenAbpDefaultApiFilter.cs b/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Swagger/HiddenAbpDefaultApiFilter.cs index 2be59eba..e4155e36 100644 --- a/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Swagger/HiddenAbpDefaultApiFilter.cs +++ b/aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Swagger/HiddenAbpDefaultApiFilter.cs @@ -1,48 +1,48 @@ -// namespace Swagger; -// -// /// -// /// 在使用nswag的时候,原生默认的api导致生产的代理类存在问题 -// /// 所有隐藏原生的api,重写路由 -// /// -// public class HiddenAbpDefaultApiFilter : IDocumentFilter -// { -// public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context) -// { -// foreach (ApiDescription apiDescription in context.ApiDescriptions) -// { -// if (apiDescription.TryGetMethodInfo(out MethodInfo method)) -// { -// string key = "/" + apiDescription.RelativePath; -// var reuslt = IsHidden(key); -// if (reuslt) swaggerDoc.Paths.Remove(key); -// } -// } -// } -// -// private bool IsHidden(string key) -// { -// var list = GetHiddenAbpDefaultApiList(); -// foreach (var item in list) -// { -// if (key.Contains(item)) return true; -// } -// -// return false; -// } -// -// private List GetHiddenAbpDefaultApiList() -// { -// return new List() { -// "/api/abp/multi-tenancy/tenants", -// "/api/account", -// "/api/feature-management/features", -// "/api/permission-management/permissions", -// "/api/identity/my-profile", -// "/api/identity", -// "/api/multi-tenancy/tenants", -// "/api/setting-management/emailing", -// "/configuration", -// "/outputcache" -// }; -// } -// } \ No newline at end of file +namespace Swagger; + +/// +/// 在使用nswag的时候,原生默认的api导致生产的代理类存在问题 +/// 所有隐藏原生的api,重写路由 +/// +public class HiddenAbpDefaultApiFilter : IDocumentFilter +{ + public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context) + { + foreach (ApiDescription apiDescription in context.ApiDescriptions) + { + if (apiDescription.TryGetMethodInfo(out MethodInfo method)) + { + string key = "/" + apiDescription.RelativePath; + var reuslt = IsHidden(key); + if (reuslt) swaggerDoc.Paths.Remove(key); + } + } + } + + private bool IsHidden(string key) + { + var list = GetHiddenAbpDefaultApiList(); + foreach (var item in list) + { + if (key.Contains(item)) return true; + } + + return false; + } + + private List GetHiddenAbpDefaultApiList() + { + return new List() { + "/api/abp/multi-tenancy/tenants", + "/api/account", + "/api/feature-management/features", + "/api/permission-management/permissions", + "/api/identity/my-profile", + "/api/identity", + "/api/multi-tenancy/tenants", + "/api/setting-management/emailing", + "/configuration", + "/outputcache" + }; + } +} \ No newline at end of file diff --git a/aspnet-core/services/src/Lion.AbpPro.FreeSqlRepository/AbpProFreeSqlModule.cs b/aspnet-core/frameworks/src/Lion.AbpPro.FreeSqlRepository/AbpProFreeSqlModule.cs similarity index 55% rename from aspnet-core/services/src/Lion.AbpPro.FreeSqlRepository/AbpProFreeSqlModule.cs rename to aspnet-core/frameworks/src/Lion.AbpPro.FreeSqlRepository/AbpProFreeSqlModule.cs index 271b4a7f..1baa4af5 100644 --- a/aspnet-core/services/src/Lion.AbpPro.FreeSqlRepository/AbpProFreeSqlModule.cs +++ b/aspnet-core/frameworks/src/Lion.AbpPro.FreeSqlRepository/AbpProFreeSqlModule.cs @@ -7,14 +7,14 @@ public class AbpProFreeSqlModule : AbpModule var configuration = context.Services.GetConfiguration(); var connectionString = configuration.GetConnectionString("Default"); var freeSql = new FreeSql.FreeSqlBuilder() - .UseConnectionString(FreeSql.DataType.MySql, connectionString) + .UseConnectionString(FreeSql.DataType.OdbcPostgreSQL, connectionString) .Build(); - freeSql.Aop.CurdAfter += (s, e) => - { - Console.WriteLine($"ManagedThreadId:{Thread.CurrentThread.ManagedThreadId};" + - $" FullName:{e.EntityType.FullName} ElapsedMilliseconds:{e.ElapsedMilliseconds}ms, {e.Sql}"); - }; + // freeSql.Aop.CurdAfter += (s, e) => + // { + // Console.WriteLine($"ManagedThreadId:{Thread.CurrentThread.ManagedThreadId};" + + // $" FullName:{e.EntityType.FullName} ElapsedMilliseconds:{e.ElapsedMilliseconds}ms, {e.Sql}"); + // }; context.Services.AddSingleton(freeSql); } diff --git a/aspnet-core/services/src/Lion.AbpPro.FreeSqlRepository/FreeSqlBasicRepository.cs b/aspnet-core/frameworks/src/Lion.AbpPro.FreeSqlRepository/FreeSqlBasicRepository.cs similarity index 100% rename from aspnet-core/services/src/Lion.AbpPro.FreeSqlRepository/FreeSqlBasicRepository.cs rename to aspnet-core/frameworks/src/Lion.AbpPro.FreeSqlRepository/FreeSqlBasicRepository.cs diff --git a/aspnet-core/services/src/Lion.AbpPro.FreeSqlRepository/GlobalUsings.cs b/aspnet-core/frameworks/src/Lion.AbpPro.FreeSqlRepository/GlobalUsings.cs similarity index 100% rename from aspnet-core/services/src/Lion.AbpPro.FreeSqlRepository/GlobalUsings.cs rename to aspnet-core/frameworks/src/Lion.AbpPro.FreeSqlRepository/GlobalUsings.cs diff --git a/aspnet-core/services/src/Lion.AbpPro.FreeSqlRepository/Lion.AbpPro.FreeSqlRepository.csproj b/aspnet-core/frameworks/src/Lion.AbpPro.FreeSqlRepository/Lion.AbpPro.FreeSqlRepository.csproj similarity index 84% rename from aspnet-core/services/src/Lion.AbpPro.FreeSqlRepository/Lion.AbpPro.FreeSqlRepository.csproj rename to aspnet-core/frameworks/src/Lion.AbpPro.FreeSqlRepository/Lion.AbpPro.FreeSqlRepository.csproj index 6c792beb..56aa25fa 100644 --- a/aspnet-core/services/src/Lion.AbpPro.FreeSqlRepository/Lion.AbpPro.FreeSqlRepository.csproj +++ b/aspnet-core/frameworks/src/Lion.AbpPro.FreeSqlRepository/Lion.AbpPro.FreeSqlRepository.csproj @@ -7,7 +7,7 @@ - + diff --git a/aspnet-core/modules/LanguageManagement/src/Lion.AbpPro.LanguageManagement.Domain/DatabaseLanguageProvider.cs b/aspnet-core/modules/LanguageManagement/src/Lion.AbpPro.LanguageManagement.Domain/DatabaseLanguageProvider.cs index f3ee0a68..24e21554 100644 --- a/aspnet-core/modules/LanguageManagement/src/Lion.AbpPro.LanguageManagement.Domain/DatabaseLanguageProvider.cs +++ b/aspnet-core/modules/LanguageManagement/src/Lion.AbpPro.LanguageManagement.Domain/DatabaseLanguageProvider.cs @@ -1,5 +1,4 @@ using Lion.AbpPro.LanguageManagement.Languages; -using Mapster; namespace Lion.AbpPro.LanguageManagement; @@ -8,13 +7,11 @@ public class DatabaseLanguageProvider : ILanguageProvider, ITransientDependency { private readonly ILanguageManager _languageManager; private readonly IDistributedCache _distributedCache; - private readonly IObjectMapper _objectMapper; - public DatabaseLanguageProvider(ILanguageManager languageManager, IDistributedCache distributedCache, IObjectMapper objectMapper) + public DatabaseLanguageProvider(ILanguageManager languageManager, IDistributedCache distributedCache) { _languageManager = languageManager; _distributedCache = distributedCache; - _objectMapper = objectMapper; } public virtual async Task> GetLanguagesAsync() diff --git a/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Lion.AbpPro.HttpApi.Host.csproj b/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Lion.AbpPro.HttpApi.Host.csproj index b191c34f..1a71545d 100644 --- a/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Lion.AbpPro.HttpApi.Host.csproj +++ b/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Lion.AbpPro.HttpApi.Host.csproj @@ -22,7 +22,7 @@ - + diff --git a/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.Development.json b/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.Development.json new file mode 100644 index 00000000..cae2d1b0 --- /dev/null +++ b/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.Development.json @@ -0,0 +1,67 @@ +{ + "ConnectionStrings": { + //"Default": "Data Source=localhost;Port=3306;Database=LionAbpProDemo9;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true" + "Default": "User ID=postgres;Password=1q2w3E*;Host=localhost;Port=5432;Database=LionAbpProDemo10;" + }, + "Hangfire": { + "Redis": { + "Host": "localhost:6379,password=1q2w3E*", + "DB": "2" + } + }, + "Redis": { + "Configuration": "localhost:6379,password=1q2w3E*,defaultdatabase=2" + }, + "Jwt": { + "Audience": "Lion.AbpPro", + "SecurityKey": "dzehzRz9a8asdfasfdadfasdfasdfafsdadfasbasdf=", + "Issuer": "Lion.AbpPro", + "ExpirationTime": 2 + }, + "Cap": { + "RabbitMq": { + "HostName": "localhost", + "UserName": "admin", + "Password": "1q2w3E*", + "Port": 5672 + } + }, + "ElasticSearch": { + "Host": "http://es.cn", + "UserName": "elastic", + "Password": "aVVhjQ95RP7nbwNy" + }, + "MiniProfiler": { + "Enabled": true, + "RouteBasePath": "/profiler" + }, + "Swagger": { + "Enabled": true + }, + "Audit": { + "Enabled": true, + "ApplicationName": "Lion.AbpPro" + }, + "Cors": { + "Enabled": true, + "CorsOrigins": "http://localhost:4200,http://localhost:4201" + }, + "Consul": { + "Enabled": false, + "ServiceUrl": "http://localhost:8500", + "ClientName": "Lion.AbpPro.Api", + "ClientAddress": "localhost", + "ClientPort": 44315, + "HealthUrl": "http://localhost:44315/health", + "DeregisterCriticalServiceAfter": 30, + "Interval": 30, + "Timeout": 30 + }, + "MultiTenancy": { + "Enabled": true + }, + "Preheat": { + "Enabled": true, + "RequestUrl": "http://localhost:44315/api/abp/application-configuration?IncludeLocalizationResources=false" + } +} \ No newline at end of file diff --git a/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.Production.json b/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.Production.json index 656874b1..cae2d1b0 100644 --- a/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.Production.json +++ b/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.Production.json @@ -1,50 +1,7 @@ { - "Serilog": { - "Using": [ - "Serilog.Sinks.Console", - "Serilog.Sinks.File" - ], - "MinimumLevel": { - "Default": "Debug", - "Override": { - "Microsoft": "Information", - "Volo.Abp": "Information", - "Hangfire": "Information", - "DotNetCore.CAP": "Information", - "Serilog.AspNetCore": "Information", - "Microsoft.EntityFrameworkCore": "Warning", - "Microsoft.AspNetCore": "Information" - } - }, - "WriteTo": [ - { - "Name": "Console" - }, - { - "Name": "File", - "Args": { - "path": "logs/logs-.txt", - "rollingInterval": "Day" - } - }, - { - "Name": "Elastic", - "Args": { - "Enabled": false, - "Url": "http://es.cn", - "IndexFormat": "Lion.AbpPro.development.{0:yyyy.MM.dd}", - "UserName": "elastic", - "Password": "aVVhjQ95RP7nbwNy", - "ApplicationName": "Lion.AbpPro.HttpApi.Host" - } - } - ] - }, - "App": { - "SelfUrl": "http://localhost:44315", - }, "ConnectionStrings": { - "Default": "Data Source=localhost;Port=3306;Database=LionAbpProDemo9;uid=root;pwd=f616b8803ac7a9a0;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true" + //"Default": "Data Source=localhost;Port=3306;Database=LionAbpProDemo9;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true" + "Default": "User ID=postgres;Password=1q2w3E*;Host=localhost;Port=5432;Database=LionAbpProDemo10;" }, "Hangfire": { "Redis": { @@ -53,7 +10,7 @@ } }, "Redis": { - "Configuration": "localhost:6379,password=75He82bB5jFA84XZ1,defaultdatabase=2" + "Configuration": "localhost:6379,password=1q2w3E*,defaultdatabase=2" }, "Jwt": { "Audience": "Lion.AbpPro", @@ -89,8 +46,16 @@ "Enabled": true, "CorsOrigins": "http://localhost:4200,http://localhost:4201" }, - "Gateway": { - "Enabled": false + "Consul": { + "Enabled": false, + "ServiceUrl": "http://localhost:8500", + "ClientName": "Lion.AbpPro.Api", + "ClientAddress": "localhost", + "ClientPort": 44315, + "HealthUrl": "http://localhost:44315/health", + "DeregisterCriticalServiceAfter": 30, + "Interval": 30, + "Timeout": 30 }, "MultiTenancy": { "Enabled": true diff --git a/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.json b/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.json index 51d2d7b8..78385035 100644 --- a/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.json +++ b/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.json @@ -42,70 +42,5 @@ }, "App": { "SelfUrl": "http://localhost:44315", - }, - "ConnectionStrings": { - //"Default": "Data Source=localhost;Port=3306;Database=LionAbpProDemo9;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true" - "Default": "User ID=postgres;Password=1q2w3E*;Host=localhost;Port=5432;Database=LionAbpProDemo10;" - }, - "Hangfire": { - "Redis": { - "Host": "localhost:6379,password=1q2w3E*", - "DB": "2" - } - }, - "Redis": { - "Configuration": "localhost:6379,password=1q2w3E*,defaultdatabase=2" - }, - "Jwt": { - "Audience": "Lion.AbpPro", - "SecurityKey": "dzehzRz9a8asdfasfdadfasdfasdfafsdadfasbasdf=", - "Issuer": "Lion.AbpPro", - "ExpirationTime": 2 - }, - "Cap": { - "RabbitMq": { - "HostName": "localhost", - "UserName": "admin", - "Password": "1q2w3E*", - "Port": 5672 - } - }, - "ElasticSearch": { - "Host": "http://es.cn", - "UserName": "elastic", - "Password": "aVVhjQ95RP7nbwNy" - }, - "MiniProfiler": { - "Enabled": true, - "RouteBasePath": "/profiler" - }, - "Swagger": { - "Enabled": true - }, - "Audit": { - "Enabled": true, - "ApplicationName": "Lion.AbpPro" - }, - "Cors": { - "Enabled": true, - "CorsOrigins": "http://localhost:4200,http://localhost:4201" - }, - "Consul": { - "Enabled": false, - "ServiceUrl": "http://localhost:8500", - "ClientName": "Lion.AbpPro.Api", - "ClientAddress": "localhost", - "ClientPort": 44315, - "HealthUrl": "http://localhost:44315/health", - "DeregisterCriticalServiceAfter": 30, - "Interval": 30, - "Timeout": 30 - }, - "MultiTenancy": { - "Enabled": true - }, - "Preheat": { - "Enabled": true, - "RequestUrl": "http://localhost:44315/api/abp/application-configuration?IncludeLocalizationResources=false" } } \ No newline at end of file diff --git a/aspnet-core/services/src/Lion.AbpPro.Application.Contracts/Lion.AbpPro.Application.Contracts.csproj b/aspnet-core/services/src/Lion.AbpPro.Application.Contracts/Lion.AbpPro.Application.Contracts.csproj index 2206f3e3..760a399f 100644 --- a/aspnet-core/services/src/Lion.AbpPro.Application.Contracts/Lion.AbpPro.Application.Contracts.csproj +++ b/aspnet-core/services/src/Lion.AbpPro.Application.Contracts/Lion.AbpPro.Application.Contracts.csproj @@ -14,10 +14,5 @@ - - - - - - + diff --git a/aspnet-core/services/src/Lion.AbpPro.Application/AbpProApplicationModule.cs b/aspnet-core/services/src/Lion.AbpPro.Application/AbpProApplicationModule.cs index 93c58e84..7540b97e 100644 --- a/aspnet-core/services/src/Lion.AbpPro.Application/AbpProApplicationModule.cs +++ b/aspnet-core/services/src/Lion.AbpPro.Application/AbpProApplicationModule.cs @@ -10,8 +10,7 @@ namespace Lion.AbpPro typeof(NotificationManagementApplicationModule), typeof(LanguageManagementApplicationModule), typeof(NotificationManagementApplicationModule), - typeof(FileManagementApplicationModule), - typeof(AbpProFreeSqlModule) + typeof(FileManagementApplicationModule) )] public class AbpProApplicationModule : AbpModule { diff --git a/aspnet-core/services/src/Lion.AbpPro.Application/GlobalUsings.cs b/aspnet-core/services/src/Lion.AbpPro.Application/GlobalUsings.cs index 088a9fd4..061f4e83 100644 --- a/aspnet-core/services/src/Lion.AbpPro.Application/GlobalUsings.cs +++ b/aspnet-core/services/src/Lion.AbpPro.Application/GlobalUsings.cs @@ -7,7 +7,6 @@ global using System.Threading.Tasks; global using Lion.AbpPro.BasicManagement; global using Lion.AbpPro.DataDictionaryManagement; global using Lion.AbpPro.Core; -global using Lion.AbpPro.FreeSqlRepository; global using Lion.AbpPro.LanguageManagement; global using Lion.AbpPro.NotificationManagement; global using Lion.AbpPro.Permissions; diff --git a/aspnet-core/services/src/Lion.AbpPro.Application/Lion.AbpPro.Application.csproj b/aspnet-core/services/src/Lion.AbpPro.Application/Lion.AbpPro.Application.csproj index e9f220b5..2cfb13d2 100644 --- a/aspnet-core/services/src/Lion.AbpPro.Application/Lion.AbpPro.Application.csproj +++ b/aspnet-core/services/src/Lion.AbpPro.Application/Lion.AbpPro.Application.csproj @@ -15,7 +15,6 @@ - diff --git a/aspnet-core/services/src/Lion.AbpPro.DbMigrator/AbpProDbMigratorModule.cs b/aspnet-core/services/src/Lion.AbpPro.DbMigrator/AbpProDbMigratorModule.cs index 6542925e..2df3b245 100644 --- a/aspnet-core/services/src/Lion.AbpPro.DbMigrator/AbpProDbMigratorModule.cs +++ b/aspnet-core/services/src/Lion.AbpPro.DbMigrator/AbpProDbMigratorModule.cs @@ -5,8 +5,7 @@ namespace Lion.AbpPro.DbMigrator { [DependsOn( typeof(AbpAutofacModule), - typeof(AbpProEntityFrameworkCoreModule), - typeof(AbpProApplicationContractsModule) + typeof(AbpProEntityFrameworkCoreModule) )] public class AbpProDbMigratorModule : AbpModule { diff --git a/aspnet-core/services/src/Lion.AbpPro.DbMigrator/Lion.AbpPro.DbMigrator.csproj b/aspnet-core/services/src/Lion.AbpPro.DbMigrator/Lion.AbpPro.DbMigrator.csproj index 0e6bed15..ddee3a80 100644 --- a/aspnet-core/services/src/Lion.AbpPro.DbMigrator/Lion.AbpPro.DbMigrator.csproj +++ b/aspnet-core/services/src/Lion.AbpPro.DbMigrator/Lion.AbpPro.DbMigrator.csproj @@ -17,8 +17,6 @@ - - diff --git a/aspnet-core/services/src/Lion.AbpPro.DbMigrator/appsettings.json b/aspnet-core/services/src/Lion.AbpPro.DbMigrator/appsettings.json index 7b75bd3b..8cd50196 100644 --- a/aspnet-core/services/src/Lion.AbpPro.DbMigrator/appsettings.json +++ b/aspnet-core/services/src/Lion.AbpPro.DbMigrator/appsettings.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { // "Default": "Data Source=localhost;Port=3306;Database=LionAbpProDemo10;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true" - "Default": "User ID=postgres;Password=1q2w3E*;Host=localhost;Port=5432;Database=LionAbpProDemo10;" + "Default": "User ID=postgres;Password=1q2w3E*;Host=localhost;Port=5432;Database=LionAbpProDemo1000;" } } \ No newline at end of file diff --git a/aspnet-core/services/src/Lion.AbpPro.Domain/Users/IUserFreeSqlBasicRepository.cs b/aspnet-core/services/src/Lion.AbpPro.Domain/Users/IUserFreeSqlBasicRepository.cs deleted file mode 100644 index fd2d64a0..00000000 --- a/aspnet-core/services/src/Lion.AbpPro.Domain/Users/IUserFreeSqlBasicRepository.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Lion.AbpPro.Users -{ - public interface IUserFreeSqlBasicRepository - { - Task> GetListAsync(); - } -} diff --git a/aspnet-core/services/src/Lion.AbpPro.EntityFrameworkCore/Lion.AbpPro.EntityFrameworkCore.csproj b/aspnet-core/services/src/Lion.AbpPro.EntityFrameworkCore/Lion.AbpPro.EntityFrameworkCore.csproj index 08e2a7f8..dad12c5c 100644 --- a/aspnet-core/services/src/Lion.AbpPro.EntityFrameworkCore/Lion.AbpPro.EntityFrameworkCore.csproj +++ b/aspnet-core/services/src/Lion.AbpPro.EntityFrameworkCore/Lion.AbpPro.EntityFrameworkCore.csproj @@ -13,14 +13,13 @@ - + runtime; build; native; contentfiles; analyzers compile; contentFiles; build; buildMultitargeting; buildTransitive; analyzers; native - \ No newline at end of file diff --git a/aspnet-core/services/src/Lion.AbpPro.FreeSqlRepository/UserFreeSqlBasicRepository.cs b/aspnet-core/services/src/Lion.AbpPro.FreeSqlRepository/UserFreeSqlBasicRepository.cs deleted file mode 100644 index d245872b..00000000 --- a/aspnet-core/services/src/Lion.AbpPro.FreeSqlRepository/UserFreeSqlBasicRepository.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Lion.AbpPro.Users; -using Lion.AbpPro.Users.Dto; - -namespace Lion.AbpPro.FreeSqlRepository -{ - public class UserFreeSqlBasicRepository : FreeSqlBasicRepository, IUserFreeSqlBasicRepository - { - public async Task> GetListAsync() - { - var sql = "select id from AbpUsers"; - var result = await FreeSql.Select() - .WithSql(sql) - .ToListAsync(); - return result; - } - } -} diff --git a/aspnet-core/services/test/Lion.AbpPro.FreeSqlRepository.Tests/AbpProFreeSqlRepositoryTestBase.cs b/aspnet-core/services/test/Lion.AbpPro.FreeSqlRepository.Tests/AbpProFreeSqlRepositoryTestBase.cs deleted file mode 100644 index 4e797272..00000000 --- a/aspnet-core/services/test/Lion.AbpPro.FreeSqlRepository.Tests/AbpProFreeSqlRepositoryTestBase.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Lion.AbpPro.FreeSqlRepository.Tests -{ - public abstract class AbpProFreeSqlRepositoryTestBase: AbpProTestBase - { - protected AbpProFreeSqlRepositoryTestBase() - { - - } - } -} diff --git a/aspnet-core/services/test/Lion.AbpPro.FreeSqlRepository.Tests/AbpProFreeSqlRepositoryTestModule.cs b/aspnet-core/services/test/Lion.AbpPro.FreeSqlRepository.Tests/AbpProFreeSqlRepositoryTestModule.cs deleted file mode 100644 index 8be814c8..00000000 --- a/aspnet-core/services/test/Lion.AbpPro.FreeSqlRepository.Tests/AbpProFreeSqlRepositoryTestModule.cs +++ /dev/null @@ -1,63 +0,0 @@ -namespace Lion.AbpPro.FreeSqlReppsitory.Tests; - -[DependsOn( - typeof(AbpProTestBaseModule), - typeof(AbpProEntityFrameworkCoreModule), - typeof(AbpEntityFrameworkCoreSqliteModule), - typeof(AbpProFreeSqlModule) -)] -public class AbpProFreeSqlRepositoryTestModule : AbpModule -{ - private SqliteConnection _sqliteConnection; - private const string ConnectionString = "Data Source=:memory:"; - public override void ConfigureServices(ServiceConfigurationContext context) - { - var freeSql = new FreeSql.FreeSqlBuilder() - .UseConnectionString(FreeSql.DataType.Sqlite, ConnectionString) - .UseAutoSyncStructure(true) - .Build(); - context.Services.AddSingleton(freeSql); - ConfigureInMemorySqlite(context.Services,freeSql); - - } - - private void ConfigureInMemorySqlite(IServiceCollection services,IFreeSql freeSql) - { - _sqliteConnection = CreateDatabaseAndGetConnection(freeSql); - - services.Configure(options => - { - options.Configure(context => - { - context.DbContextOptions.UseSqlite(_sqliteConnection); - }); - }); - } - - public override void OnApplicationShutdown(ApplicationShutdownContext context) - { - _sqliteConnection.Dispose(); - } - - private static SqliteConnection CreateDatabaseAndGetConnection(IFreeSql freeSql) - { - var connection = new SqliteConnection(ConnectionString); - connection.Open(); - - var options = new DbContextOptionsBuilder() - .UseSqlite(connection) - .Options; - - using (var context = new AbpProDbContext(options)) - { - foreach (var entityType in context.Model.GetEntityTypes()) - { - freeSql.CodeFirst.SyncStructure(entityType.ClrType, entityType.GetTableName(), true); - } - context.GetService().CreateTables(); - } - - return connection; - } - -} \ No newline at end of file diff --git a/aspnet-core/services/test/Lion.AbpPro.FreeSqlRepository.Tests/GlobalUsings.cs b/aspnet-core/services/test/Lion.AbpPro.FreeSqlRepository.Tests/GlobalUsings.cs deleted file mode 100644 index a55bd828..00000000 --- a/aspnet-core/services/test/Lion.AbpPro.FreeSqlRepository.Tests/GlobalUsings.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Global using directives - -global using System.Threading.Tasks; -global using Lion.AbpPro.EntityFrameworkCore; -global using Lion.AbpPro.FreeSqlRepository; -global using Lion.AbpPro.FreeSqlReppsitory.Tests; -global using Lion.AbpPro.Users; -global using Microsoft.Data.Sqlite; -global using Microsoft.EntityFrameworkCore; -global using Microsoft.EntityFrameworkCore.Infrastructure; -global using Microsoft.EntityFrameworkCore.Storage; -global using Microsoft.Extensions.DependencyInjection; -global using Shouldly; -global using Volo.Abp; -global using Volo.Abp.EntityFrameworkCore; -global using Volo.Abp.EntityFrameworkCore.Sqlite; -global using Volo.Abp.Modularity; -global using Xunit; \ No newline at end of file diff --git a/aspnet-core/services/test/Lion.AbpPro.FreeSqlRepository.Tests/Lion.AbpPro.FreeSqlRepository.Tests.csproj b/aspnet-core/services/test/Lion.AbpPro.FreeSqlRepository.Tests/Lion.AbpPro.FreeSqlRepository.Tests.csproj deleted file mode 100644 index c2fbaf8e..00000000 --- a/aspnet-core/services/test/Lion.AbpPro.FreeSqlRepository.Tests/Lion.AbpPro.FreeSqlRepository.Tests.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - net10.0 - - false - - Lion.AbpPro.FreeSqlRepository.Tests - - - - - - - - - - - - - - - diff --git a/aspnet-core/services/test/Lion.AbpPro.FreeSqlRepository.Tests/Users/UserFreeSqlBasicRepository_Tests.cs b/aspnet-core/services/test/Lion.AbpPro.FreeSqlRepository.Tests/Users/UserFreeSqlBasicRepository_Tests.cs deleted file mode 100644 index e3cbabb5..00000000 --- a/aspnet-core/services/test/Lion.AbpPro.FreeSqlRepository.Tests/Users/UserFreeSqlBasicRepository_Tests.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Lion.AbpPro.FreeSqlRepository.Tests.Users -{ - - - public class UserFreeSqlBasicRepository_Tests: AbpProFreeSqlRepositoryTestBase - { - private readonly IUserFreeSqlBasicRepository _userFreeSqlBasicRepository; - public UserFreeSqlBasicRepository_Tests() - { - _userFreeSqlBasicRepository = GetRequiredService(); - } - - [Fact] - public async Task Should_NotThrow_ListAsyncTest() - { - var result = await _userFreeSqlBasicRepository.GetListAsync(); - result.ShouldNotBeNull(); - } - } - -}