From c652ce61e23f8d52857126fe186f0a1603dfc576 Mon Sep 17 00:00:00 2001 From: colin Date: Mon, 27 May 2024 19:03:48 +0800 Subject: [PATCH] upgrade: upgrade abp framework to 8.1.2 --- .github/workflows/publish.yml | 2 +- .github/workflows/release.yml | 4 +- Directory.Packages.props | 7 +- aspnet-core/LINGYUN.MicroService.All.sln | 32 +- .../FodyWeavers.xml | 3 + .../LINGYUN.Abp.Aliyun.Features.csproj | 15 + .../AliyunFeatureDefinitionProvider.cs | 27 + .../Abp/Aliyun/Features/AliyunFeatureNames.cs | 38 + .../AliyunSettingAppService.cs | 138 ++- .../LINGYUN.Abp.Aliyun.csproj | 5 + .../LINGYUN/Abp/Aliyun/AbpAliyunModule.cs | 4 +- .../LINGYUN/Abp/Aliyun/AcsClientFactory.cs | 3 + .../AliyunFeatureDefinitionProvider.cs | 53 + .../Abp/Aliyun/Features/AliyunFeatureNames.cs | 38 + .../Abp/Aliyun/Localization/Resources/en.json | 11 + .../Localization/Resources/zh-Hans.json | 43 +- .../Aliyun/Settings/AliyunSettingProvider.cs | 1 + .../TencentCloudSettingAppService.cs | 47 +- .../BlobStoring/Aliyun/AliyunBlobProvider.cs | 6 +- .../Aliyun/AliyunBlobProviderConfiguration.cs | 11 - .../BlobStoring/Aliyun/IOssClientFactory.cs | 8 +- .../BlobStoring/Aliyun/OssClientFactory.cs | 25 +- .../LINGYUN/Abp/Sms/Aliyun/AliyunSmsSender.cs | 10 + .../OpenApiAuthorizationService.cs | 84 +- .../FodyWeavers.xml | 3 + .../FodyWeavers.xsd | 30 + .../LINGYUN.Abp.OpenApi.IdentityServer.csproj | 19 + .../AbpOpenApiIdentityServerModule.cs | 11 + .../IdentityServerAppKeyStore.cs | 70 ++ .../FodyWeavers.xml | 3 + .../FodyWeavers.xsd | 30 + .../LINGYUN.Abp.OpenApi.OpenIddict.csproj | 19 + .../OpenIddict/AbpOpenApiOpenIddictModule.cs | 11 + .../OpenIddict/OpenIddictAppKeyStore.cs | 59 ++ .../LINGYUN/Abp/OpenApi/AbpOpenApiConsts.cs | 3 + .../Abp/OpenApi/AlwaysAllowClientChecker.cs | 15 + .../OpenApi/AlwaysAllowIpAddressChecker.cs | 15 + .../ConfigurationStore/DefaultAppKeyStore.cs | 10 +- .../LINGYUN/Abp/OpenApi/IAppKeyStore.cs | 14 +- .../LINGYUN/Abp/OpenApi/IClientChecker.cs | 9 + .../LINGYUN/Abp/OpenApi/IIpAddressChecker.cs | 8 + .../OpenApi/Localization/Resources/en.json | 4 +- .../Localization/Resources/zh-Hans.json | 4 +- .../PushPlusSettingAppService.cs | 8 +- .../PushPlusSettingController.cs | 4 +- .../WeChatSettingAppService.cs | 12 +- .../WxPusherSettingAppService.cs | 4 +- .../LINGYUN.Abp.WxPusher.csproj | 1 - ...e-Tenant-Id-With-Text-Template.Designer.cs | 938 ++++++++++++++++++ ...536_Remote-Tenant-Id-With-Text-Template.cs | 48 + ...ndAdminMigrationsDbContextModelSnapshot.cs | 6 +- .../WeChat/Work/WeChatWorkGrantValidator.cs | 2 +- .../Work/WeChatWorkTokenExtensionGrant.cs | 2 +- .../Aliyun/AliyunOssContainer.cs | 2 +- .../OssManagementSettingAppService.cs | 6 +- .../OrganizationUnitDeletedEventHandler.cs | 1 + ...izationUnitPermissionManagementProvider.cs | 4 +- ...nizationUnitPermissionManagerExtensions.cs | 12 +- .../NotificationDefinitionInitializer.cs | 2 +- .../SettingManagement/SettingAppService.cs | 154 +-- .../Quartz/QuartzJobListener.cs | 16 +- .../Abp/TextTemplating/TextTemplateEto.cs | 8 +- .../IStaticTemplateDefinitionSaver.cs | 7 - .../TextTemplating/IStaticTemplateSaver.cs | 9 + .../InMemoryTemplateDefinitionStoreCache.cs | 2 +- ...initionSaver.cs => StaticTemplateSaver.cs} | 225 +++-- .../Abp/TextTemplating/TextTemplate.cs | 4 +- .../TextTemplateCacheItemInvalidator.cs | 5 +- .../TextTemplateContentCacheItem.cs | 2 + .../TextTemplateContentContributor.cs | 9 +- .../TextTemplateDefinitionInitializer.cs | 6 +- ...platingDbContextModelCreatingExtensions.cs | 2 +- .../FodyWeavers.xml | 3 + .../FodyWeavers.xsd | 30 + .../LINGYUN.Abp.TextTemplating.Scriban.csproj | 18 + .../Scriban/AbpTextTemplatingScribanModule.cs | 17 + .../ScribanTemplateDefinitionExtensions.cs | 12 + .../Scriban/ScribanTemplateLocalizer.cs | 64 ++ .../Scriban/ScribanTemplateRenderingEngine.cs | 154 +++ .../AuthServerHttpApiHostModule.Configure.cs | 11 +- .../AuthServerHttpApiHostModule.cs | 3 +- ...BackendAdminHttpApiHostModule.Configure.cs | 9 + .../BackendAdminHttpApiHostModule.cs | 21 +- ...roService.BackendAdmin.HttpApi.Host.csproj | 6 + ...entityServerHttpApiHostModule.Configure.cs | 11 +- .../IdentityServerHttpApiHostModule.cs | 3 +- .../IdentityServerModule.Configure.cs | 9 + ...onManagementHttpApiHostModule.Configure.cs | 11 +- ...LocalizationManagementHttpApiHostModule.cs | 3 +- ...rmManagementHttpApiHostModule.Configure.cs | 11 +- .../PlatformManagementHttpApiHostModule.cs | 4 +- ...ervice.RealtimeMessage.HttpApi.Host.csproj | 1 + ...ltimeMessageHttpApiHostModule.Configure.cs | 21 +- .../RealtimeMessageHttpApiHostModule.cs | 9 +- ...skManagementHttpApiHostModule.Configure.cs | 9 + .../TaskManagementHttpApiHostModule.cs | 1 + ...ksManagementHttpApiHostModule.Configure.cs | 9 + .../WebhooksManagementHttpApiHostModule.cs | 1 + ...owManagementHttpApiHostModule.Configure.cs | 8 + .../WorkflowManagementHttpApiHostModule.cs | 1 + common.props | 4 +- ...NGYUN.MicroService.Internal.ApiGateway.sln | 28 + .../Controllers/HomeController.cs | 12 + .../InternalGatewayModule.cs | 175 ++++ ...NGYUN.MicroService.Internal.Gateway.csproj | 39 + .../Program.cs | 55 + .../Properties/launchSettings.json | 13 + .../appsettings.Development.json | 74 ++ .../appsettings.json | 73 ++ .../yarp.json | 156 +++ .../InternalApiGatewayModule.cs | 14 + .../LY.MicroService.ApiGateway.csproj | 2 + 112 files changed, 3162 insertions(+), 396 deletions(-) create mode 100644 aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.Features/FodyWeavers.xml create mode 100644 aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.Features/LINGYUN.Abp.Aliyun.Features.csproj create mode 100644 aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.Features/LINGYUN/Abp/Aliyun/Features/AliyunFeatureDefinitionProvider.cs create mode 100644 aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.Features/LINGYUN/Abp/Aliyun/Features/AliyunFeatureNames.cs create mode 100644 aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Features/AliyunFeatureDefinitionProvider.cs create mode 100644 aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Features/AliyunFeatureNames.cs create mode 100644 aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.IdentityServer/FodyWeavers.xml create mode 100644 aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.IdentityServer/FodyWeavers.xsd create mode 100644 aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.IdentityServer/LINGYUN.Abp.OpenApi.IdentityServer.csproj create mode 100644 aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.IdentityServer/LINGYUN/Abp/OpenApi/IdentityServer/AbpOpenApiIdentityServerModule.cs create mode 100644 aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.IdentityServer/LINGYUN/Abp/OpenApi/IdentityServer/IdentityServerAppKeyStore.cs create mode 100644 aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.OpenIddict/FodyWeavers.xml create mode 100644 aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.OpenIddict/FodyWeavers.xsd create mode 100644 aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.OpenIddict/LINGYUN.Abp.OpenApi.OpenIddict.csproj create mode 100644 aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.OpenIddict/LINGYUN/Abp/OpenApi/OpenIddict/AbpOpenApiOpenIddictModule.cs create mode 100644 aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.OpenIddict/LINGYUN/Abp/OpenApi/OpenIddict/OpenIddictAppKeyStore.cs create mode 100644 aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/AlwaysAllowClientChecker.cs create mode 100644 aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/AlwaysAllowIpAddressChecker.cs create mode 100644 aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/IClientChecker.cs create mode 100644 aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/IIpAddressChecker.cs create mode 100644 aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/Migrations/20240527092536_Remote-Tenant-Id-With-Text-Template.Designer.cs create mode 100644 aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/Migrations/20240527092536_Remote-Tenant-Id-With-Text-Template.cs delete mode 100644 aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/IStaticTemplateDefinitionSaver.cs create mode 100644 aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/IStaticTemplateSaver.cs rename aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/{StaticTemplateDefinitionSaver.cs => StaticTemplateSaver.cs} (68%) create mode 100644 aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/FodyWeavers.xml create mode 100644 aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/FodyWeavers.xsd create mode 100644 aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/LINGYUN.Abp.TextTemplating.Scriban.csproj create mode 100644 aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/LINGYUN/Abp/TextTemplating/Scriban/AbpTextTemplatingScribanModule.cs create mode 100644 aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/LINGYUN/Abp/TextTemplating/Scriban/ScribanTemplateDefinitionExtensions.cs create mode 100644 aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/LINGYUN/Abp/TextTemplating/Scriban/ScribanTemplateLocalizer.cs create mode 100644 aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/LINGYUN/Abp/TextTemplating/Scriban/ScribanTemplateRenderingEngine.cs create mode 100644 gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/Controllers/HomeController.cs create mode 100644 gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/InternalGatewayModule.cs create mode 100644 gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/LINGYUN.MicroService.Internal.Gateway.csproj create mode 100644 gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/Program.cs create mode 100644 gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/Properties/launchSettings.json create mode 100644 gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/appsettings.Development.json create mode 100644 gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/appsettings.json create mode 100644 gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/yarp.json diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index be01cda7c..5c3ddfe0a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,7 +2,7 @@ name: "Publish" on: push: - branches: [ rel-8.1.1 ] + branches: [ rel-8.1.2 ] env: DOTNET_VERSION: "8.0.200" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3c4323a4a..b5240064b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ name: "Tagged Release" on: push: - branches: [ rel-8.1.1 ] + branches: [ rel-8.1.2 ] jobs: tagged-release: @@ -14,4 +14,4 @@ jobs: with: repo_token: "${{ secrets.GITHUB_TOKEN }}" prerelease: false - automatic_release_tag: "8.1.1" + automatic_release_tag: "8.1.2" diff --git a/Directory.Packages.props b/Directory.Packages.props index e297afc67..2d78b3bb9 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -2,8 +2,8 @@ 8.1.1 2.14.1 - 8.1.1 - 8.1.1 + 8.1.2 + 8.1.2 8.0.0 8.0.0 8.0.0 @@ -244,6 +244,7 @@ + @@ -252,6 +253,6 @@ - + \ No newline at end of file diff --git a/aspnet-core/LINGYUN.MicroService.All.sln b/aspnet-core/LINGYUN.MicroService.All.sln index d6f586903..5ff1e18e9 100644 --- a/aspnet-core/LINGYUN.MicroService.All.sln +++ b/aspnet-core/LINGYUN.MicroService.All.sln @@ -106,6 +106,9 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Platform.HttpApi", "modules\platform\LINGYUN.Platform.HttpApi\LINGYUN.Platform.HttpApi.csproj", "{5FBBBA6A-D6EC-42E1-8164-15C411EC77BE}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "admin", "admin", "{F4615BCE-D5C1-407A-8681-8EEE92DEF9D0}" + ProjectSection(SolutionItems) = preProject + ..\..\upgrade\aspnet-core\services\LY.MicroService.BackendAdmin.HttpApi.Host\appsettings.Production.json = ..\..\upgrade\aspnet-core\services\LY.MicroService.BackendAdmin.HttpApi.Host\appsettings.Production.json + EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.EntityFrameworkCore.Tests", "tests\LINGYUN.Abp.EntityFrameworkCore.Tests\LINGYUN.Abp.EntityFrameworkCore.Tests.csproj", "{F3D9B137-32DE-4018-8058-78AB17FCDF9C}" EndProject @@ -728,13 +731,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.DataProtectionM EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.AspNetCore.Wrapper", "framework\common\LINGYUN.Abp.AspNetCore.Wrapper\LINGYUN.Abp.AspNetCore.Wrapper.csproj", "{30FB6AD7-3CC5-4A8D-B170-BDA772E6BA3C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.DataProtectionManagement.Application.Contracts", "modules\data-protection\LINGYUN.Abp.DataProtectionManagement.Application.Contracts\LINGYUN.Abp.DataProtectionManagement.Application.Contracts.csproj", "{40D7A0A3-68BD-431E-A67A-E2A35508D55D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.DataProtectionManagement.Application.Contracts", "modules\data-protection\LINGYUN.Abp.DataProtectionManagement.Application.Contracts\LINGYUN.Abp.DataProtectionManagement.Application.Contracts.csproj", "{40D7A0A3-68BD-431E-A67A-E2A35508D55D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.DataProtectionManagement.Application", "modules\data-protection\LINGYUN.Abp.DataProtectionManagement.Application\LINGYUN.Abp.DataProtectionManagement.Application.csproj", "{8EA8C998-F81A-46E9-8C7E-C944D2503A0A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.DataProtection.Abstractions", "framework\data-protection\LINGYUN.Abp.DataProtection.Abstractions\LINGYUN.Abp.DataProtection.Abstractions.csproj", "{47550AB9-FA06-42D6-A4B8-7DD12FE66563}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.DataProtectionManagement.HttpApi", "modules\data-protection\LINGYUN.Abp.DataProtectionManagement.HttpApi\LINGYUN.Abp.DataProtectionManagement.HttpApi.csproj", "{835E51CE-1E6B-4C8C-9736-8C5B61F5E08E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.DataProtectionManagement.Application", "modules\data-protection\LINGYUN.Abp.DataProtectionManagement.Application\LINGYUN.Abp.DataProtectionManagement.Application.csproj", "{8EA8C998-F81A-46E9-8C7E-C944D2503A0A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OpenApi.IdentityServer", "framework\open-api\LINGYUN.Abp.OpenApi.IdentityServer\LINGYUN.Abp.OpenApi.IdentityServer.csproj", "{FDAAAD2E-42A7-44EC-8971-B5277FD6D404}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.DataProtection.Abstractions", "framework\data-protection\LINGYUN.Abp.DataProtection.Abstractions\LINGYUN.Abp.DataProtection.Abstractions.csproj", "{47550AB9-FA06-42D6-A4B8-7DD12FE66563}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OpenApi.OpenIddict", "framework\open-api\LINGYUN.Abp.OpenApi.OpenIddict\LINGYUN.Abp.OpenApi.OpenIddict.csproj", "{ED3DF100-C5DB-4334-A847-118922B28D95}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.DataProtectionManagement.HttpApi", "modules\data-protection\LINGYUN.Abp.DataProtectionManagement.HttpApi\LINGYUN.Abp.DataProtectionManagement.HttpApi.csproj", "{835E51CE-1E6B-4C8C-9736-8C5B61F5E08E}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.TextTemplating.Scriban", "modules\text-templating\LINGYUN.Abp.TextTemplating.Scriban\LINGYUN.Abp.TextTemplating.Scriban.csproj", "{15482834-9242-4D20-9736-9DA571A9A83A}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -1874,6 +1883,18 @@ Global {835E51CE-1E6B-4C8C-9736-8C5B61F5E08E}.Debug|Any CPU.Build.0 = Debug|Any CPU {835E51CE-1E6B-4C8C-9736-8C5B61F5E08E}.Release|Any CPU.ActiveCfg = Release|Any CPU {835E51CE-1E6B-4C8C-9736-8C5B61F5E08E}.Release|Any CPU.Build.0 = Release|Any CPU + {FDAAAD2E-42A7-44EC-8971-B5277FD6D404}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FDAAAD2E-42A7-44EC-8971-B5277FD6D404}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FDAAAD2E-42A7-44EC-8971-B5277FD6D404}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FDAAAD2E-42A7-44EC-8971-B5277FD6D404}.Release|Any CPU.Build.0 = Release|Any CPU + {ED3DF100-C5DB-4334-A847-118922B28D95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ED3DF100-C5DB-4334-A847-118922B28D95}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ED3DF100-C5DB-4334-A847-118922B28D95}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ED3DF100-C5DB-4334-A847-118922B28D95}.Release|Any CPU.Build.0 = Release|Any CPU + {15482834-9242-4D20-9736-9DA571A9A83A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {15482834-9242-4D20-9736-9DA571A9A83A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {15482834-9242-4D20-9736-9DA571A9A83A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {15482834-9242-4D20-9736-9DA571A9A83A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2229,6 +2250,9 @@ Global {8EA8C998-F81A-46E9-8C7E-C944D2503A0A} = {F6A9D966-0022-440B-AE27-564A74CDED48} {47550AB9-FA06-42D6-A4B8-7DD12FE66563} = {529DF802-97C4-4BF2-BE7C-39663B3D9EA3} {835E51CE-1E6B-4C8C-9736-8C5B61F5E08E} = {F6A9D966-0022-440B-AE27-564A74CDED48} + {FDAAAD2E-42A7-44EC-8971-B5277FD6D404} = {3C7A8246-DE82-4330-8697-24EF1B1C515D} + {ED3DF100-C5DB-4334-A847-118922B28D95} = {3C7A8246-DE82-4330-8697-24EF1B1C515D} + {15482834-9242-4D20-9736-9DA571A9A83A} = {ABD89F39-62D9-439E-8662-BE4F36BFA04F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C95FDF91-16F2-4A8B-A4BE-0E62D1B66718} diff --git a/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.Features/FodyWeavers.xml b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.Features/FodyWeavers.xml new file mode 100644 index 000000000..1715698cc --- /dev/null +++ b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.Features/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.Features/LINGYUN.Abp.Aliyun.Features.csproj b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.Features/LINGYUN.Abp.Aliyun.Features.csproj new file mode 100644 index 000000000..7b0b41108 --- /dev/null +++ b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.Features/LINGYUN.Abp.Aliyun.Features.csproj @@ -0,0 +1,15 @@ + + + + + + + netstandard2.0 + + + + + + + + diff --git a/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.Features/LINGYUN/Abp/Aliyun/Features/AliyunFeatureDefinitionProvider.cs b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.Features/LINGYUN/Abp/Aliyun/Features/AliyunFeatureDefinitionProvider.cs new file mode 100644 index 000000000..0374fe8af --- /dev/null +++ b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.Features/LINGYUN/Abp/Aliyun/Features/AliyunFeatureDefinitionProvider.cs @@ -0,0 +1,27 @@ +using LINGYUN.Abp.Aliyun.Localization; +using Volo.Abp.Features; +using Volo.Abp.Localization; +using Volo.Abp.Validation.StringValues; + +namespace LINGYUN.Abp.Aliyun.Features; +public class AliyunFeatureDefinitionProvider : FeatureDefinitionProvider +{ + public override void Define(IFeatureDefinitionContext context) + { + var featureGroup = context.AddGroup( + name: AliyunFeatureNames.GroupName, + displayName: L("Features:AlibabaCloud")); + + featureGroup.AddFeature( + name: AliyunFeatureNames.IsEnabled, + defaultValue: false.ToString(), + displayName: L("Features:AlibabaCloud:IsEnabled"), + description: L("Features:AlibabaCloud:IsEnabledDesc"), + valueType: new ToggleStringValueType(new BooleanValueValidator())); + } + + private static ILocalizableString L(string name) + { + return LocalizableString.Create(name); + } +} diff --git a/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.Features/LINGYUN/Abp/Aliyun/Features/AliyunFeatureNames.cs b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.Features/LINGYUN/Abp/Aliyun/Features/AliyunFeatureNames.cs new file mode 100644 index 000000000..a6d7a616d --- /dev/null +++ b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.Features/LINGYUN/Abp/Aliyun/Features/AliyunFeatureNames.cs @@ -0,0 +1,38 @@ +namespace LINGYUN.Abp.Aliyun.Features; +public static class AliyunFeatureNames +{ + public const string GroupName = "AlibabaCloud"; + + public const string IsEnabled = GroupName + ".IsEnabled"; + + public static class Sms + { + public const string Default = GroupName + ".Sms"; + + public const string IsEnabled = Default + ".IsEnabled"; + + /// + /// 发送次数上限 + /// + public const string SendLimit = Default + ".SendLimit"; + /// + /// 发送次数上限时长 + /// + public const string SendLimitInterval = Default + ".SendLimitInterval"; + /// + /// 默认发送次数上限 + /// + public const int DefaultSendLimit = 1000; + /// + /// 默认发送次数上限时长 + /// + public const int DefaultSendLimitInterval = 1; + } + + public static class Oss + { + public const string Default = GroupName + ".Sms"; + + public const string IsEnabled = GroupName + ".IsEnabled"; + } +} \ No newline at end of file diff --git a/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.SettingManagement/LINGYUN/Abp/Aliyun/SettingManagement/AliyunSettingAppService.cs b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.SettingManagement/LINGYUN/Abp/Aliyun/SettingManagement/AliyunSettingAppService.cs index f3aaf426c..9bf7ff4ac 100644 --- a/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.SettingManagement/LINGYUN/Abp/Aliyun/SettingManagement/AliyunSettingAppService.cs +++ b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.SettingManagement/LINGYUN/Abp/Aliyun/SettingManagement/AliyunSettingAppService.cs @@ -1,6 +1,8 @@ -using LINGYUN.Abp.Aliyun.Localization; +using LINGYUN.Abp.Aliyun.Features; +using LINGYUN.Abp.Aliyun.Localization; using LINGYUN.Abp.Aliyun.Settings; using LINGYUN.Abp.SettingManagement; +using System.Collections.Generic; using System.Threading.Tasks; using Volo.Abp.Application.Services; using Volo.Abp.Authorization.Permissions; @@ -43,7 +45,8 @@ protected async virtual Task GetAllForProviderAsync(string p var settingGroups = new SettingGroupResult(); // 无权限返回空结果,直接报错的话,网关聚合会抛出异常 - if (await PermissionChecker.IsGrantedAsync(AliyunSettingPermissionNames.Settings)) + if (await FeatureChecker.IsEnabledAsync(AliyunFeatureNames.Enable) && + await PermissionChecker.IsGrantedAsync(AliyunSettingPermissionNames.Settings)) { var aliyunSettingGroup = new SettingGroupDto(L["DisplayName:Aliyun"], L["Description:Aliyun"]); #region 访问控制 @@ -54,8 +57,9 @@ protected async virtual Task GetAllForProviderAsync(string p await SettingDefinitionManager.GetAsync(AliyunSettingNames.Authorization.RegionId), StringLocalizerFactory, await SettingManager.GetOrNullAsync(AliyunSettingNames.Authorization.RegionId, providerName, providerKey), - ValueType.String, - providerName); + ValueType.Option, + providerName) + .AddOptions(GetAvailableRegionOptions()); ramSetting.AddDetail( await SettingDefinitionManager.GetAsync(AliyunSettingNames.Authorization.AccessKeyId), StringLocalizerFactory, @@ -103,49 +107,52 @@ await SettingManager.GetOrNullAsync(AliyunSettingNames.Authorization.DurationSec #region 短信 - var smsSetting = aliyunSettingGroup.AddSetting(L["DisplayName:Aliyun.Sms"], L["Description:Aliyun.Sms"]); - smsSetting.AddDetail( - await SettingDefinitionManager.GetAsync(AliyunSettingNames.Sms.Domain), - StringLocalizerFactory, - await SettingManager.GetOrNullAsync(AliyunSettingNames.Sms.Domain, providerName, providerKey), - ValueType.String, - providerName); - smsSetting.AddDetail( - await SettingDefinitionManager.GetAsync(AliyunSettingNames.Sms.Version), - StringLocalizerFactory, - await SettingManager.GetOrNullAsync(AliyunSettingNames.Sms.Version, providerName, providerKey), - ValueType.String, - providerName); - smsSetting.AddDetail( - await SettingDefinitionManager.GetAsync(AliyunSettingNames.Sms.ActionName), - StringLocalizerFactory, - await SettingManager.GetOrNullAsync(AliyunSettingNames.Sms.ActionName, providerName, providerKey), - ValueType.String, - providerName); - smsSetting.AddDetail( - await SettingDefinitionManager.GetAsync(AliyunSettingNames.Sms.DefaultPhoneNumber), - StringLocalizerFactory, - await SettingManager.GetOrNullAsync(AliyunSettingNames.Sms.DefaultPhoneNumber, providerName, providerKey), - ValueType.String, - providerName); - smsSetting.AddDetail( - await SettingDefinitionManager.GetAsync(AliyunSettingNames.Sms.DefaultSignName), - StringLocalizerFactory, - await SettingManager.GetOrNullAsync(AliyunSettingNames.Sms.DefaultSignName, providerName, providerKey), - ValueType.String, - providerName); - smsSetting.AddDetail( - await SettingDefinitionManager.GetAsync(AliyunSettingNames.Sms.DefaultTemplateCode), - StringLocalizerFactory, - await SettingManager.GetOrNullAsync(AliyunSettingNames.Sms.DefaultTemplateCode, providerName, providerKey), - ValueType.String, - providerName); - smsSetting.AddDetail( - await SettingDefinitionManager.GetAsync(AliyunSettingNames.Sms.VisableErrorToClient), - StringLocalizerFactory, - await SettingManager.GetOrNullAsync(AliyunSettingNames.Sms.VisableErrorToClient, providerName, providerKey), - ValueType.Boolean, - providerName); + if (await FeatureChecker.IsEnabledAsync(AliyunFeatureNames.Sms.Enable)) + { + var smsSetting = aliyunSettingGroup.AddSetting(L["DisplayName:Aliyun.Sms"], L["Description:Aliyun.Sms"]); + smsSetting.AddDetail( + await SettingDefinitionManager.GetAsync(AliyunSettingNames.Sms.Domain), + StringLocalizerFactory, + await SettingManager.GetOrNullAsync(AliyunSettingNames.Sms.Domain, providerName, providerKey), + ValueType.String, + providerName); + smsSetting.AddDetail( + await SettingDefinitionManager.GetAsync(AliyunSettingNames.Sms.Version), + StringLocalizerFactory, + await SettingManager.GetOrNullAsync(AliyunSettingNames.Sms.Version, providerName, providerKey), + ValueType.String, + providerName); + smsSetting.AddDetail( + await SettingDefinitionManager.GetAsync(AliyunSettingNames.Sms.ActionName), + StringLocalizerFactory, + await SettingManager.GetOrNullAsync(AliyunSettingNames.Sms.ActionName, providerName, providerKey), + ValueType.String, + providerName); + smsSetting.AddDetail( + await SettingDefinitionManager.GetAsync(AliyunSettingNames.Sms.DefaultPhoneNumber), + StringLocalizerFactory, + await SettingManager.GetOrNullAsync(AliyunSettingNames.Sms.DefaultPhoneNumber, providerName, providerKey), + ValueType.String, + providerName); + smsSetting.AddDetail( + await SettingDefinitionManager.GetAsync(AliyunSettingNames.Sms.DefaultSignName), + StringLocalizerFactory, + await SettingManager.GetOrNullAsync(AliyunSettingNames.Sms.DefaultSignName, providerName, providerKey), + ValueType.String, + providerName); + smsSetting.AddDetail( + await SettingDefinitionManager.GetAsync(AliyunSettingNames.Sms.DefaultTemplateCode), + StringLocalizerFactory, + await SettingManager.GetOrNullAsync(AliyunSettingNames.Sms.DefaultTemplateCode, providerName, providerKey), + ValueType.String, + providerName); + smsSetting.AddDetail( + await SettingDefinitionManager.GetAsync(AliyunSettingNames.Sms.VisableErrorToClient), + StringLocalizerFactory, + await SettingManager.GetOrNullAsync(AliyunSettingNames.Sms.VisableErrorToClient, providerName, providerKey), + ValueType.Boolean, + providerName); + } #endregion @@ -154,5 +161,42 @@ await SettingManager.GetOrNullAsync(AliyunSettingNames.Sms.VisableErrorToClient, return settingGroups; } + + protected virtual IEnumerable GetAvailableRegionOptions() + { + return new OptionDto[] + { + new OptionDto(L["Region:HangZhou"], "oss-cn-hangzhou"), + new OptionDto(L["Region:ShangHai"], "oss-cn-shanghai"), + new OptionDto(L["Region:NanJing"], "oss-cn-nanjing"), + new OptionDto(L["Region:FuZhou"], "oss-cn-fuzhou"), + new OptionDto(L["Region:WuHan"], "oss-cn-wuhan"), + new OptionDto(L["Region:QingDao"], "oss-cn-qingdao"), + new OptionDto(L["Region:BeiJing"], "oss-cn-beijing"), + new OptionDto(L["Region:ZhangJiaKou"], "oss-cn-zhangjiakou"), + new OptionDto(L["Region:HuHeHaoTe"], "oss-cn-huhehaote"), + new OptionDto(L["Region:WuLanChaBu"], "oss-cn-wulanchabu"), + new OptionDto(L["Region:ShenZhen"], "oss-cn-shenzhen"), + new OptionDto(L["Region:HeYuan"], "oss-cn-heyuan"), + new OptionDto(L["Region:GuangZhou"], "oss-cn-guangzhou"), + new OptionDto(L["Region:ChengDu"], "oss-cn-chengdu"), + new OptionDto(L["Region:HongKong"], "oss-cn-hongkong"), + new OptionDto(L["Region:SiliconValley"], "oss-us-west-1"), + new OptionDto(L["Region:Virginia"], "oss-us-east-1"), + new OptionDto(L["Region:Tokoyo"], "oss-ap-northeast-1"), + new OptionDto(L["Region:Seoul"], "oss-ap-northeast-2"), + new OptionDto(L["Region:Singapore"], "oss-ap-southeast-1"), + new OptionDto(L["Region:Sydney"], "oss-ap-southeast-2"), + new OptionDto(L["Region:KualaLumpur"], "oss-ap-southeast-3"), + new OptionDto(L["Region:Jakarta"], "oss-ap-southeast-5"), + new OptionDto(L["Region:Manila"], "oss-ap-southeast-6"), + new OptionDto(L["Region:Bangkok"], "oss-ap-southeast-7"), + new OptionDto(L["Region:Bombay"], "oss-ap-south-1"), + new OptionDto(L["Region:Frankfurt"], "oss-eu-central-1"), + new OptionDto(L["Region:London"], "oss-eu-west-1"), + new OptionDto(L["Region:Dubai"], "oss-me-east-1"), + new OptionDto(L["Region:MainLand"], "oss-rg-china-mainland"), + }; + } } } diff --git a/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN.Abp.Aliyun.csproj b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN.Abp.Aliyun.csproj index 7fc6a14a1..eefdbc878 100644 --- a/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN.Abp.Aliyun.csproj +++ b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN.Abp.Aliyun.csproj @@ -22,9 +22,14 @@ + + + + + diff --git a/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/AbpAliyunModule.cs b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/AbpAliyunModule.cs index 603401ae3..0b0ffd5d0 100644 --- a/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/AbpAliyunModule.cs +++ b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/AbpAliyunModule.cs @@ -1,4 +1,5 @@ using LINGYUN.Abp.Aliyun.Localization; +using LINGYUN.Abp.Features.LimitValidation; using Volo.Abp.Caching; using Volo.Abp.Json; using Volo.Abp.Localization; @@ -12,7 +13,8 @@ namespace LINGYUN.Abp.Aliyun typeof(AbpCachingModule), typeof(AbpSettingsModule), typeof(AbpJsonModule), - typeof(AbpLocalizationModule))] + typeof(AbpLocalizationModule), + typeof(AbpFeaturesLimitValidationModule))] public class AbpAliyunModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) diff --git a/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/AcsClientFactory.cs b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/AcsClientFactory.cs index 9517c87b2..da868a1db 100644 --- a/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/AcsClientFactory.cs +++ b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/AcsClientFactory.cs @@ -1,12 +1,15 @@ using Aliyun.Acs.Core; using Aliyun.Acs.Core.Auth; using Aliyun.Acs.Core.Profile; +using LINGYUN.Abp.Aliyun.Features; using Volo.Abp.Caching; using Volo.Abp.DependencyInjection; +using Volo.Abp.Features; using Volo.Abp.Settings; namespace LINGYUN.Abp.Aliyun { + [RequiresFeature(AliyunFeatureNames.Enable)] public class AcsClientFactory : AliyunClientFactory, IAcsClientFactory, ITransientDependency { public AcsClientFactory( diff --git a/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Features/AliyunFeatureDefinitionProvider.cs b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Features/AliyunFeatureDefinitionProvider.cs new file mode 100644 index 000000000..599d902dd --- /dev/null +++ b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Features/AliyunFeatureDefinitionProvider.cs @@ -0,0 +1,53 @@ +using LINGYUN.Abp.Aliyun.Localization; +using Volo.Abp.Features; +using Volo.Abp.Localization; +using Volo.Abp.Validation.StringValues; + +namespace LINGYUN.Abp.Aliyun.Features; +public class AliyunFeatureDefinitionProvider : FeatureDefinitionProvider +{ + public override void Define(IFeatureDefinitionContext context) + { + var featureGroup = context.AddGroup( + name: AliyunFeatureNames.GroupName, + displayName: L("Features:AlibabaCloud")); + + featureGroup.AddFeature( + name: AliyunFeatureNames.Enable, + defaultValue: false.ToString(), + displayName: L("Features:AlibabaCloud:IsEnabled"), + description: L("Features:AlibabaCloud:IsEnabledDesc"), + valueType: new ToggleStringValueType(new BooleanValueValidator())); + + var smsFeature = featureGroup.AddFeature( + name: AliyunFeatureNames.Sms.Enable, + defaultValue: false.ToString(), + displayName: L("Features:AlibabaCloud:Sms"), + description: L("Features:AlibabaCloud:SmsDesc"), + valueType: new ToggleStringValueType(new BooleanValueValidator())); + smsFeature.CreateChild( + name: AliyunFeatureNames.Sms.SendLimit, + defaultValue: AliyunFeatureNames.Sms.DefaultSendLimit.ToString(), + displayName: L("Features:AlibabaCloud:Sms.SendLimit"), + description: L("Features:AlibabaCloud:Sms.SendLimitDesc"), + valueType: new FreeTextStringValueType(new NumericValueValidator(1, 100_0000))); + smsFeature.CreateChild( + name: AliyunFeatureNames.Sms.SendLimitInterval, + defaultValue: AliyunFeatureNames.Sms.DefaultSendLimitInterval.ToString(), + displayName: L("Features:AlibabaCloud:Sms.SendLimitInterval"), + description: L("Features:AlibabaCloud:Sms.SendLimitIntervalDesc"), + valueType: new FreeTextStringValueType(new NumericValueValidator(1, 100_0000))); + + var blobFeature = featureGroup.AddFeature( + name: AliyunFeatureNames.BlobStoring.Enable, + defaultValue: false.ToString(), + displayName: L("Features:AlibabaCloud:Oss"), + description: L("Features:AlibabaCloud:OssDesc"), + valueType: new ToggleStringValueType(new BooleanValueValidator())); + } + + private static ILocalizableString L(string name) + { + return LocalizableString.Create(name); + } +} diff --git a/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Features/AliyunFeatureNames.cs b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Features/AliyunFeatureNames.cs new file mode 100644 index 000000000..916d010bd --- /dev/null +++ b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Features/AliyunFeatureNames.cs @@ -0,0 +1,38 @@ +namespace LINGYUN.Abp.Aliyun.Features; +public static class AliyunFeatureNames +{ + public const string GroupName = "AlibabaCloud"; + + public const string Enable = GroupName + ".Enable"; + + public static class Sms + { + public const string Default = GroupName + ".Sms"; + + public const string Enable = Default + ".Enable"; + + /// + /// 发送次数上限 + /// + public const string SendLimit = Default + ".SendLimit"; + /// + /// 发送次数上限时长 + /// + public const string SendLimitInterval = Default + ".SendLimitInterval"; + /// + /// 默认发送次数上限 + /// + public const int DefaultSendLimit = 1000; + /// + /// 默认发送次数上限时长 + /// + public const int DefaultSendLimitInterval = 1; + } + + public static class BlobStoring + { + public const string Default = GroupName + ".BlobStoring"; + + public const string Enable = Default + ".Enable"; + } +} \ No newline at end of file diff --git a/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Localization/Resources/en.json b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Localization/Resources/en.json index 6a5367804..314098cdf 100644 --- a/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Localization/Resources/en.json +++ b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Localization/Resources/en.json @@ -1,6 +1,17 @@ { "culture": "en", "texts": { + "Features:AlibabaCloud": "Alibaba Cloud", + "Features:AlibabaCloud:IsEnabled": "Enabling Alibaba Cloud Services", + "Features:AlibabaCloud:IsEnabledDesc": "Enable the ability to enable applications to have Alibaba Cloud services.", + "Features:AlibabaCloud:Sms": "Alibaba Cloud Sms Service", + "Features:AlibabaCloud:SmsDesc": "Enable the ability to use Alibaba Cloud SMS services.", + "Features:AlibabaCloud:Sms.SendLimit": "Sending SMS restriction", + "Features:AlibabaCloud:Sms.SendLimitDesc": "Limit SMS service calls within a certain period of time", + "Features:AlibabaCloud:Sms.SendLimitInterval": "Limit the duration of sending text messages", + "Features:AlibabaCloud:Sms.SendLimitIntervalDesc": "Limit the duration of template SMS service call limit, with a cycle of months", + "Features:AlibabaCloud:Oss": "Alibaba Cloud Oss Service", + "Features:AlibabaCloud:OssDesc": "Enable the ability to use Alibaba Cloud Oss services.", "DisplayName:Aliyun.RAM": "RAM", "Description:Aliyun.RAM": "RAM", "DisplayName:Authorization": "Authorization", diff --git a/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Localization/Resources/zh-Hans.json b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Localization/Resources/zh-Hans.json index a91311318..1e9a8b872 100644 --- a/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Localization/Resources/zh-Hans.json +++ b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Localization/Resources/zh-Hans.json @@ -1,6 +1,17 @@ { "culture": "zh-Hans", "texts": { + "Features:AlibabaCloud": "阿里云服务", + "Features:AlibabaCloud:IsEnabled": "启用阿里云服务", + "Features:AlibabaCloud:IsEnabledDesc": "启用使应用程序拥有阿里云服务的能力.", + "Features:AlibabaCloud:Sms": "阿里云短信", + "Features:AlibabaCloud:SmsDesc": "启用以使用阿里云短信服务的能力.", + "Features:AlibabaCloud:Sms.SendLimit": "发送短信限制", + "Features:AlibabaCloud:Sms.SendLimitDesc": "在一定周期内限制短信服务调用上限", + "Features:AlibabaCloud:Sms.SendLimitInterval": "发送短信限制时长", + "Features:AlibabaCloud:Sms.SendLimitIntervalDesc": "限制模板短信服务调用上限的时长,周期为月", + "Features:AlibabaCloud:Oss": "阿里云对象存储", + "Features:AlibabaCloud:OssDesc": "启用以使用阿里云对象存储的能力.", "DisplayName:Aliyun.RAM": "访问控制", "Description:Aliyun.RAM": "阿里云服务访问控制", "DisplayName:Authorization": "阿里云身份认证凭据", @@ -36,6 +47,36 @@ "DisplayName:Version": "阿里云sms服务版本号", "Description:Version": "阿里云sms服务版本号", "DisplayName:VisableErrorToClient": "发送错误到客户端", - "Description:VisableErrorToClient": "当短信服务发送出现错误时是否发送错误详情到客户端" + "Description:VisableErrorToClient": "当短信服务发送出现错误时是否发送错误详情到客户端", + "Region:HangZhou": "华东1(杭州)", + "Region:ShangHai": "华东2(上海)", + "Region:NanJing": "华东5(南京-本地地域)", + "Region:FuZhou": "华东6(福州-本地地域)", + "Region:WuHan": "华中1(武汉-本地地域)", + "Region:QingDao": "华北1(青岛)", + "Region:BeiJing": "华北2(北京)", + "Region:ZhangJiaKou": "华北 3(张家口)", + "Region:HuHeHaoTe": "华北5(呼和浩特)", + "Region:WuLanChaBu": "华北6(乌兰察布)", + "Region:ShenZhen": "华南1(深圳)", + "Region:HeYuan": "华南2(河源)", + "Region:GuangZhou": "华南3(广州)", + "Region:ChengDu": "西南1(成都)", + "Region:HongKong": "中国香港", + "Region:SiliconValley": "美国(硅谷)", + "Region:Virginia": "美国(弗吉尼亚)", + "Region:Tokoyo": "日本(东京)", + "Region:Seoul": "韩国(首尔)", + "Region:Singapore": "新加坡", + "Region:Sydney": "澳大利亚(悉尼)", + "Region:KualaLumpur": "马来西亚(吉隆坡)", + "Region:Jakarta": "印度尼西亚(雅加达)", + "Region:Manila": "菲律宾(马尼拉)", + "Region:Bangkok": "泰国(曼谷)", + "Region:Bombay": "印度(孟买)", + "Region:Frankfurt": "德国(法兰克福)", + "Region:London": "英国(伦敦)", + "Region:Dubai": "阿联酋(迪拜)", + "Region:MainLand": "无地域属性(中国内地)" } } \ No newline at end of file diff --git a/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Settings/AliyunSettingProvider.cs b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Settings/AliyunSettingProvider.cs index f174f1398..a5d519b79 100644 --- a/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Settings/AliyunSettingProvider.cs +++ b/aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Settings/AliyunSettingProvider.cs @@ -78,6 +78,7 @@ private SettingDefinition[] GetAuthorizationSettings() TenantSettingValueProvider.ProviderName), new SettingDefinition( AliyunSettingNames.Authorization.RegionId, + defaultValue: "oss-cn-hangzhou", displayName: L("DisplayName:RegionId"), description: L("Description:RegionId"), isVisibleToClients: false diff --git a/aspnet-core/framework/cloud-tencent/LINGYUN.Abp.Tencent.SettingManagement/LINGYUN/Abp/Tencent/SettingManagement/TencentCloudSettingAppService.cs b/aspnet-core/framework/cloud-tencent/LINGYUN.Abp.Tencent.SettingManagement/LINGYUN/Abp/Tencent/SettingManagement/TencentCloudSettingAppService.cs index 0b50e1b9d..71cf1ee4d 100644 --- a/aspnet-core/framework/cloud-tencent/LINGYUN.Abp.Tencent.SettingManagement/LINGYUN/Abp/Tencent/SettingManagement/TencentCloudSettingAppService.cs +++ b/aspnet-core/framework/cloud-tencent/LINGYUN.Abp.Tencent.SettingManagement/LINGYUN/Abp/Tencent/SettingManagement/TencentCloudSettingAppService.cs @@ -1,4 +1,5 @@ using LINGYUN.Abp.SettingManagement; +using LINGYUN.Abp.Tencent.Features; using LINGYUN.Abp.Tencent.Localization; using LINGYUN.Abp.Tencent.QQ.Settings; using LINGYUN.Abp.Tencent.Settings; @@ -112,27 +113,31 @@ await SettingManager.GetOrNullAsync(TencentCloudSettingNames.Connection.WebProxy #region 短信设置 - var smsSetting = settingGroup.AddSetting( - L["DisplayName:TenantCloud.SmsSetting"], L["Description:TenantCloud.SmsSetting"]); - - smsSetting.AddDetail( - await SettingDefinitionManager.GetAsync(TencentCloudSettingNames.Sms.AppId), - StringLocalizerFactory, - await SettingManager.GetOrNullAsync(TencentCloudSettingNames.Sms.AppId, providerName, providerKey), - ValueType.String, - providerName); - smsSetting.AddDetail( - await SettingDefinitionManager.GetAsync(TencentCloudSettingNames.Sms.DefaultTemplateId), - StringLocalizerFactory, - await SettingManager.GetOrNullAsync(TencentCloudSettingNames.Sms.DefaultTemplateId, providerName, providerKey), - ValueType.String, - providerName); - smsSetting.AddDetail( - await SettingDefinitionManager.GetAsync(TencentCloudSettingNames.Sms.DefaultSignName), - StringLocalizerFactory, - await SettingManager.GetOrNullAsync(TencentCloudSettingNames.Sms.DefaultSignName, providerName, providerKey), - ValueType.String, - providerName); + if (await FeatureChecker.IsEnabledAsync(TencentCloudFeatures.Sms.Enable)) + { + + var smsSetting = settingGroup.AddSetting( + L["DisplayName:TenantCloud.SmsSetting"], L["Description:TenantCloud.SmsSetting"]); + + smsSetting.AddDetail( + await SettingDefinitionManager.GetAsync(TencentCloudSettingNames.Sms.AppId), + StringLocalizerFactory, + await SettingManager.GetOrNullAsync(TencentCloudSettingNames.Sms.AppId, providerName, providerKey), + ValueType.String, + providerName); + smsSetting.AddDetail( + await SettingDefinitionManager.GetAsync(TencentCloudSettingNames.Sms.DefaultTemplateId), + StringLocalizerFactory, + await SettingManager.GetOrNullAsync(TencentCloudSettingNames.Sms.DefaultTemplateId, providerName, providerKey), + ValueType.String, + providerName); + smsSetting.AddDetail( + await SettingDefinitionManager.GetAsync(TencentCloudSettingNames.Sms.DefaultSignName), + StringLocalizerFactory, + await SettingManager.GetOrNullAsync(TencentCloudSettingNames.Sms.DefaultSignName, providerName, providerKey), + ValueType.String, + providerName); + } #endregion diff --git a/aspnet-core/framework/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/AliyunBlobProvider.cs b/aspnet-core/framework/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/AliyunBlobProvider.cs index 0eadfb477..499d6102a 100644 --- a/aspnet-core/framework/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/AliyunBlobProvider.cs +++ b/aspnet-core/framework/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/AliyunBlobProvider.cs @@ -1,13 +1,16 @@ using Aliyun.OSS; +using LINGYUN.Abp.Aliyun.Features; using System; using System.Collections.Generic; using System.IO; using System.Threading.Tasks; using Volo.Abp.BlobStoring; using Volo.Abp.DependencyInjection; +using Volo.Abp.Features; namespace LINGYUN.Abp.BlobStoring.Aliyun { + [RequiresFeature(AliyunFeatureNames.BlobStoring.Enable)] public class AliyunBlobProvider : BlobProviderBase, ITransientDependency { protected IOssClientFactory OssClientFactory { get; } @@ -92,8 +95,7 @@ public override async Task SaveAsync(BlobProviderSaveArgs args) protected async virtual Task GetOssClientAsync(BlobProviderArgs args) { - var configuration = args.Configuration.GetAliyunConfiguration(); - var ossClient = await OssClientFactory.CreateAsync(configuration); + var ossClient = await OssClientFactory.CreateAsync(); return ossClient; } diff --git a/aspnet-core/framework/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/AliyunBlobProviderConfiguration.cs b/aspnet-core/framework/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/AliyunBlobProviderConfiguration.cs index b6f2637ab..c13ba5c9c 100644 --- a/aspnet-core/framework/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/AliyunBlobProviderConfiguration.cs +++ b/aspnet-core/framework/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/AliyunBlobProviderConfiguration.cs @@ -6,17 +6,6 @@ namespace LINGYUN.Abp.BlobStoring.Aliyun { public class AliyunBlobProviderConfiguration { - /// - /// 数据中心 - /// - /// - /// 详见 https://help.aliyun.com/document_detail/31837.html?spm=a2c4g.11186623.2.14.417cd47eLc9LHc#concept-zt4-cvy-5db - /// - public string Endpoint - { - get => _containerConfiguration.GetConfiguration(AliyunBlobProviderConfigurationNames.Endpoint); - set => _containerConfiguration.SetConfiguration(AliyunBlobProviderConfigurationNames.Endpoint, Check.NotNullOrWhiteSpace(value, nameof(value))); - } /// /// 命名空间 /// diff --git a/aspnet-core/framework/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/IOssClientFactory.cs b/aspnet-core/framework/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/IOssClientFactory.cs index 4ec2aea01..ae7e77d1b 100644 --- a/aspnet-core/framework/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/IOssClientFactory.cs +++ b/aspnet-core/framework/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/IOssClientFactory.cs @@ -9,12 +9,6 @@ public interface IOssClientFactory /// 构建Oss客户端 /// /// - Task CreateAsync(); - /// - /// 通过配置信息构建Oss客户端调用 - /// - /// - /// - Task CreateAsync(AliyunBlobProviderConfiguration configuration); + Task CreateAsync(); } } diff --git a/aspnet-core/framework/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/OssClientFactory.cs b/aspnet-core/framework/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/OssClientFactory.cs index 4d271876f..a6a627b86 100644 --- a/aspnet-core/framework/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/OssClientFactory.cs +++ b/aspnet-core/framework/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/OssClientFactory.cs @@ -1,59 +1,46 @@ using Aliyun.OSS; using LINGYUN.Abp.Aliyun; -using System.Threading.Tasks; -using Volo.Abp.BlobStoring; using Volo.Abp.Caching; using Volo.Abp.DependencyInjection; using Volo.Abp.Settings; namespace LINGYUN.Abp.BlobStoring.Aliyun { - public class OssClientFactory : AliyunClientFactory, IOssClientFactory, ITransientDependency + public class OssClientFactory : AliyunClientFactory, IOssClientFactory, ITransientDependency { - protected IBlobContainerConfigurationProvider ConfigurationProvider { get; } public OssClientFactory( ISettingProvider settingProvider, - IBlobContainerConfigurationProvider configurationProvider, IDistributedCache cache) : base(settingProvider, cache) { - ConfigurationProvider = configurationProvider; - } - - public async virtual Task CreateAsync() - { - var configuration = ConfigurationProvider.Get(); - - return await CreateAsync(configuration.GetAliyunConfiguration()); } /// /// 普通方式构建Oss客户端 /// - /// /// /// /// /// - protected override IOss GetClient(AliyunBlobProviderConfiguration configuration, string regionId, string accessKeyId, string accessKeySecret) + protected override IOss GetClient(string regionId, string accessKeyId, string accessKeySecret) { return new OssClient( - configuration.Endpoint, + regionId, accessKeyId, accessKeySecret); } + /// /// 通过用户安全令牌构建Oss客户端 /// - /// /// /// /// /// /// - protected override IOss GetSecurityTokenClient(AliyunBlobProviderConfiguration configuration, string regionId, string accessKeyId, string accessKeySecret, string securityToken) + protected override IOss GetSecurityTokenClient(string regionId, string accessKeyId, string accessKeySecret, string securityToken) { return new OssClient( - configuration.Endpoint, + regionId, accessKeyId, accessKeySecret, securityToken); diff --git a/aspnet-core/framework/common/LINGYUN.Abp.Sms.Aliyun/LINGYUN/Abp/Sms/Aliyun/AliyunSmsSender.cs b/aspnet-core/framework/common/LINGYUN.Abp.Sms.Aliyun/LINGYUN/Abp/Sms/Aliyun/AliyunSmsSender.cs index e8ddde4e7..1ee917994 100644 --- a/aspnet-core/framework/common/LINGYUN.Abp.Sms.Aliyun/LINGYUN/Abp/Sms/Aliyun/AliyunSmsSender.cs +++ b/aspnet-core/framework/common/LINGYUN.Abp.Sms.Aliyun/LINGYUN/Abp/Sms/Aliyun/AliyunSmsSender.cs @@ -2,7 +2,9 @@ using Aliyun.Acs.Core.Exceptions; using Aliyun.Acs.Core.Http; using LINGYUN.Abp.Aliyun; +using LINGYUN.Abp.Aliyun.Features; using LINGYUN.Abp.Aliyun.Settings; +using LINGYUN.Abp.Features.LimitValidation; using Microsoft.Extensions.DependencyInjection; using System; using System.Linq; @@ -10,6 +12,7 @@ using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.DependencyInjection; +using Volo.Abp.Features; using Volo.Abp.Json; using Volo.Abp.Settings; using Volo.Abp.Sms; @@ -18,6 +21,7 @@ namespace LINGYUN.Abp.Sms.Aliyun { [Dependency(ServiceLifetime.Singleton)] [ExposeServices(typeof(ISmsSender), typeof(AliyunSmsSender))] + [RequiresFeature(AliyunFeatureNames.Sms.Enable)] public class AliyunSmsSender : ISmsSender { protected IJsonSerializer JsonSerializer { get; } @@ -36,6 +40,12 @@ public AliyunSmsSender( AcsClientFactory = acsClientFactory; } + [RequiresLimitFeature( + AliyunFeatureNames.Sms.SendLimit, + AliyunFeatureNames.Sms.SendLimitInterval, + LimitPolicy.Month, + AliyunFeatureNames.Sms.DefaultSendLimit, + AliyunFeatureNames.Sms.DefaultSendLimitInterval)] public async virtual Task SendAsync(SmsMessage smsMessage) { var domain = await SettingProvider.GetOrNullAsync(AliyunSettingNames.Sms.Domain); diff --git a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.Authorization/LINGYUN/Abp/OpenApi/Authorization/OpenApiAuthorizationService.cs b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.Authorization/LINGYUN/Abp/OpenApi/Authorization/OpenApiAuthorizationService.cs index 7cc9b61c0..f5bdda243 100644 --- a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.Authorization/LINGYUN/Abp/OpenApi/Authorization/OpenApiAuthorizationService.cs +++ b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.Authorization/LINGYUN/Abp/OpenApi/Authorization/OpenApiAuthorizationService.cs @@ -3,7 +3,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Microsoft.Extensions.Primitives; -using Microsoft.Net.Http.Headers; using System; using System.Collections.Generic; using System.Linq; @@ -27,17 +26,23 @@ public class OpenApiAuthorizationService : IOpenApiAuthorizationService, ITransi private readonly AbpOpenApiOptions _openApiOptions; private readonly ICurrentClient _currentClient; private readonly IWebClientInfoProvider _clientInfoProvider; + private readonly IClientChecker _clientChecker; + private readonly IIpAddressChecker _ipAddressChecker; private readonly AbpExceptionHandlingOptions _exceptionHandlingOptions; public OpenApiAuthorizationService( IAppKeyStore appKeyStore, ICurrentClient currentClient, + IClientChecker clientChecker, + IIpAddressChecker ipAddressChecker, IWebClientInfoProvider clientInfoProvider, IOptionsMonitor options, IOptions exceptionHandlingOptions) { _appKeyStore = appKeyStore; _currentClient = currentClient; + _clientChecker = clientChecker; + _ipAddressChecker = ipAddressChecker; _clientInfoProvider = clientInfoProvider; _openApiOptions = options.CurrentValue; _exceptionHandlingOptions = exceptionHandlingOptions.Value; @@ -50,37 +55,72 @@ public async virtual Task AuthorizeAsync(HttpContext httpContext) return true; } - // TODO: 不够优雅,应该用接口来实现 - //if (_currentClient.IsAuthenticated && - // _openApiOptions.HasWhiteClient(_currentClient.Id)) - //{ - // return true; - //} + if (!await ValidateClient(httpContext)) + { + return false; + } + + if (!await ValidateQueryString(httpContext)) + { + return false; + } + + if (!await ValidatAppDescriptor(httpContext)) + { + return false; + } + + return true; + } + + protected async virtual Task ValidateClient(HttpContext httpContext) + { + if (_currentClient.IsAuthenticated && !await _clientChecker.IsGrantAsync(_currentClient.Id, httpContext.RequestAborted)) + { + var exception = new BusinessException( + AbpOpenApiConsts.InvalidAccessWithClientId, + $"Client Id {_currentClient.Id} Not Allowed", + $"Client Id {_currentClient.Id} Not Allowed"); + await Unauthorized(httpContext, exception); + return false; + } - //if (!string.IsNullOrWhiteSpace(_clientInfoProvider.ClientIpAddress) && - // _openApiOptions.HasWhiteIpAddress(_clientInfoProvider.ClientIpAddress)) - //{ - // return true; - //} + if (!string.IsNullOrWhiteSpace(_clientInfoProvider.ClientIpAddress) && + !await _ipAddressChecker.IsGrantAsync(_clientInfoProvider.ClientIpAddress, httpContext.RequestAborted)) + { + var exception = new BusinessException( + AbpOpenApiConsts.InvalidAccessWithIpAddress, + $"Client IpAddress {_clientInfoProvider.ClientIpAddress} Not Allowed", + $"Client IpAddress {_clientInfoProvider.ClientIpAddress} Not Allowed"); + await Unauthorized(httpContext, exception); + return false; + } + return true; + } - BusinessException exception; + protected async virtual Task ValidateQueryString(HttpContext httpContext) + { if (!httpContext.Request.QueryString.HasValue) { - exception = new BusinessException( + var exception = new BusinessException( AbpOpenApiConsts.InvalidAccessWithAppKeyNotFound, $"{AbpOpenApiConsts.AppKeyFieldName} Not Found", $"{AbpOpenApiConsts.AppKeyFieldName} Not Found"); await Unauthorized(httpContext, exception); return false; } + return true; + } + protected async virtual Task ValidatAppDescriptor(HttpContext httpContext) + { httpContext.Request.Query.TryGetValue(AbpOpenApiConsts.AppKeyFieldName, out var appKey); httpContext.Request.Query.TryGetValue(AbpOpenApiConsts.SignatureFieldName, out var sign); httpContext.Request.Query.TryGetValue(AbpOpenApiConsts.TimeStampFieldName, out var timeStampString); if (StringValues.IsNullOrEmpty(appKey)) { - exception = new BusinessException( + var exception = new BusinessException( AbpOpenApiConsts.InvalidAccessWithAppKeyNotFound, $"{AbpOpenApiConsts.AppKeyFieldName} Not Found", $"{AbpOpenApiConsts.AppKeyFieldName} Not Found"); @@ -90,7 +130,7 @@ public async virtual Task AuthorizeAsync(HttpContext httpContext) if (StringValues.IsNullOrEmpty(sign)) { - exception = new BusinessException( + var exception = new BusinessException( AbpOpenApiConsts.InvalidAccessWithSignNotFound, $"{AbpOpenApiConsts.SignatureFieldName} Not Found", $"{AbpOpenApiConsts.SignatureFieldName} Not Found"); @@ -101,7 +141,7 @@ public async virtual Task AuthorizeAsync(HttpContext httpContext) if (StringValues.IsNullOrEmpty(timeStampString)) { - exception = new BusinessException( + var exception = new BusinessException( AbpOpenApiConsts.InvalidAccessWithTimestampNotFound, $"{AbpOpenApiConsts.TimeStampFieldName} Not Found", $"{AbpOpenApiConsts.TimeStampFieldName} Not Found"); @@ -112,7 +152,7 @@ public async virtual Task AuthorizeAsync(HttpContext httpContext) if (!long.TryParse(timeStampString.ToString(), out long timeStamp)) { - exception = new BusinessException( + var exception = new BusinessException( AbpOpenApiConsts.InvalidAccessWithTimestamp, "invalid timestamp", "invalid timestamp"); @@ -121,10 +161,10 @@ public async virtual Task AuthorizeAsync(HttpContext httpContext) return false; } - var appDescriptor = await _appKeyStore.FindAsync(appKey.ToString()); + var appDescriptor = await _appKeyStore.FindAsync(appKey.ToString(), httpContext.RequestAborted); if (appDescriptor == null) { - exception = new BusinessException( + var exception = new BusinessException( AbpOpenApiConsts.InvalidAccessWithAppKey, "invalid appKey", "invalid appKey") @@ -148,7 +188,7 @@ public async virtual Task AuthorizeAsync(HttpContext httpContext) var requiredSign = CalculationSignature(httpContext.Request.Path.Value, queryDictionary); if (!string.Equals(requiredSign, sign.ToString())) { - exception = new BusinessException( + var exception = new BusinessException( AbpOpenApiConsts.InvalidAccessWithSign, "invalid signature", "invalid signature"); @@ -163,7 +203,7 @@ public async virtual Task AuthorizeAsync(HttpContext httpContext) if ((now - timeStamp) / 1000 > appDescriptor.SignLifetime.Value) { - exception = new BusinessException( + var exception = new BusinessException( AbpOpenApiConsts.InvalidAccessWithTimestamp, "session timed out or expired", "session timed out or expired"); diff --git a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.IdentityServer/FodyWeavers.xml b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.IdentityServer/FodyWeavers.xml new file mode 100644 index 000000000..1715698cc --- /dev/null +++ b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.IdentityServer/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.IdentityServer/FodyWeavers.xsd b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.IdentityServer/FodyWeavers.xsd new file mode 100644 index 000000000..3f3946e28 --- /dev/null +++ b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.IdentityServer/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.IdentityServer/LINGYUN.Abp.OpenApi.IdentityServer.csproj b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.IdentityServer/LINGYUN.Abp.OpenApi.IdentityServer.csproj new file mode 100644 index 000000000..b17c8a6cc --- /dev/null +++ b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.IdentityServer/LINGYUN.Abp.OpenApi.IdentityServer.csproj @@ -0,0 +1,19 @@ + + + + + + + net8.0 + + + + + + + + + + + + diff --git a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.IdentityServer/LINGYUN/Abp/OpenApi/IdentityServer/AbpOpenApiIdentityServerModule.cs b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.IdentityServer/LINGYUN/Abp/OpenApi/IdentityServer/AbpOpenApiIdentityServerModule.cs new file mode 100644 index 000000000..1ce6fc837 --- /dev/null +++ b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.IdentityServer/LINGYUN/Abp/OpenApi/IdentityServer/AbpOpenApiIdentityServerModule.cs @@ -0,0 +1,11 @@ +using Volo.Abp.IdentityServer; +using Volo.Abp.Modularity; + +namespace LINGYUN.Abp.OpenApi.IdentityServer; + +[DependsOn( + typeof(AbpOpenApiModule), + typeof(AbpIdentityServerDomainModule))] +public class AbpOpenApiIdentityServerModule : AbpModule +{ +} diff --git a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.IdentityServer/LINGYUN/Abp/OpenApi/IdentityServer/IdentityServerAppKeyStore.cs b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.IdentityServer/LINGYUN/Abp/OpenApi/IdentityServer/IdentityServerAppKeyStore.cs new file mode 100644 index 000000000..42713b0cc --- /dev/null +++ b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.IdentityServer/LINGYUN/Abp/OpenApi/IdentityServer/IdentityServerAppKeyStore.cs @@ -0,0 +1,70 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Guids; +using Volo.Abp.IdentityServer.Clients; + +namespace LINGYUN.Abp.OpenApi.IdentityServer; + +[Dependency(ServiceLifetime.Transient, ReplaceServices = true)] +public class IdentityServerAppKeyStore : IAppKeyStore, ITransientDependency +{ + public ILogger Logger { protected get; set; } + + private readonly IGuidGenerator _guidGenerator; + private readonly IClientRepository _clientRepository; + + public IdentityServerAppKeyStore( + IGuidGenerator guidGenerator, + IClientRepository clientRepository) + { + _guidGenerator = guidGenerator; + _clientRepository = clientRepository; + + Logger = NullLogger.Instance; + } + + public async virtual Task FindAsync(string appKey, CancellationToken cancellationToken = default) + { + var client = await _clientRepository.FindByClientIdAsync(appKey, cancellationToken: cancellationToken); + if (client != null) + { + int? signLifeTime = null; + + var appSecret = client.FindSecret(nameof(AppDescriptor.AppSecret)); + if (appSecret == null) + { + Logger.LogWarning("Found a client {ClientId} that meets the criteria, but did not specify the client key [AppSecret]", client.ClientId); + return null; + } + + var signLifeTimeProp = client.FindProperty(nameof(AppDescriptor.SignLifetime)); + if (signLifeTimeProp != null && int.TryParse(signLifeTimeProp.Value, out var time)) + { + signLifeTime = time; + } + + return new AppDescriptor(client.ClientName, client.ClientId, appSecret.Value, signLifeTime: signLifeTime); + } + + return null; + } + + public async virtual Task StoreAsync(AppDescriptor descriptor, CancellationToken cancellationToken = default) + { + var client = new Client(_guidGenerator.Create(), descriptor.AppKey) + { + ClientName = descriptor.AppName, + }; + client.AddSecret(descriptor.AppSecret); + if (descriptor.SignLifetime.HasValue) + { + client.AddProperty(nameof(AppDescriptor.SignLifetime), descriptor.SignLifetime.Value.ToString()); + } + + await _clientRepository.InsertAsync(client, cancellationToken: cancellationToken); + } +} diff --git a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.OpenIddict/FodyWeavers.xml b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.OpenIddict/FodyWeavers.xml new file mode 100644 index 000000000..1715698cc --- /dev/null +++ b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.OpenIddict/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.OpenIddict/FodyWeavers.xsd b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.OpenIddict/FodyWeavers.xsd new file mode 100644 index 000000000..3f3946e28 --- /dev/null +++ b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.OpenIddict/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.OpenIddict/LINGYUN.Abp.OpenApi.OpenIddict.csproj b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.OpenIddict/LINGYUN.Abp.OpenApi.OpenIddict.csproj new file mode 100644 index 000000000..926fa3a56 --- /dev/null +++ b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.OpenIddict/LINGYUN.Abp.OpenApi.OpenIddict.csproj @@ -0,0 +1,19 @@ + + + + + + + net8.0 + + + + + + + + + + + + diff --git a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.OpenIddict/LINGYUN/Abp/OpenApi/OpenIddict/AbpOpenApiOpenIddictModule.cs b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.OpenIddict/LINGYUN/Abp/OpenApi/OpenIddict/AbpOpenApiOpenIddictModule.cs new file mode 100644 index 000000000..df6547328 --- /dev/null +++ b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.OpenIddict/LINGYUN/Abp/OpenApi/OpenIddict/AbpOpenApiOpenIddictModule.cs @@ -0,0 +1,11 @@ +using Volo.Abp.Modularity; +using Volo.Abp.OpenIddict; + +namespace LINGYUN.Abp.OpenApi.OpenIddict; + +[DependsOn( + typeof(AbpOpenApiModule), + typeof(AbpOpenIddictDomainModule))] +public class AbpOpenApiOpenIddictModule : AbpModule +{ +} diff --git a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.OpenIddict/LINGYUN/Abp/OpenApi/OpenIddict/OpenIddictAppKeyStore.cs b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.OpenIddict/LINGYUN/Abp/OpenApi/OpenIddict/OpenIddictAppKeyStore.cs new file mode 100644 index 000000000..1a3e5b6e6 --- /dev/null +++ b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi.OpenIddict/LINGYUN/Abp/OpenApi/OpenIddict/OpenIddictAppKeyStore.cs @@ -0,0 +1,59 @@ +using Microsoft.Extensions.DependencyInjection; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Guids; +using Volo.Abp.OpenIddict.Applications; + +namespace LINGYUN.Abp.OpenApi.OpenIddict; + +[Dependency(ServiceLifetime.Transient, ReplaceServices = true)] +public class OpenIddictAppKeyStore : IAppKeyStore, ITransientDependency +{ + private readonly IAbpOpenIdApplicationStore _appStore; + private readonly IGuidGenerator _guidGenerator; + + public OpenIddictAppKeyStore( + IAbpOpenIdApplicationStore appStore, + IGuidGenerator guidGenerator) + { + _appStore = appStore; + _guidGenerator = guidGenerator; + } + + public async virtual Task FindAsync(string appKey, CancellationToken cancellationToken = default) + { + var application = await _appStore.FindByClientIdAsync(appKey, cancellationToken); + if (application != null) + { + int? signLifeTime = null; + + var signLifeTimeProp = application.GetProperty(nameof(AppDescriptor.SignLifetime)); + if (signLifeTimeProp != null && int.TryParse(signLifeTimeProp.ToString(), out var time)) + { + signLifeTime = time; + } + + return new AppDescriptor(application.DisplayName, application.ClientId, application.ClientSecret, signLifeTime: signLifeTime); + } + + return null; + } + + public async virtual Task StoreAsync(AppDescriptor descriptor, CancellationToken cancellationToken = default) + { + var application = new OpenIddictApplicationModel + { + Id = _guidGenerator.Create(), + ClientId = descriptor.AppKey, + ClientSecret = descriptor.AppSecret, + DisplayName = descriptor.AppName, + }; + if (descriptor.SignLifetime.HasValue) + { + application.SetProperty(nameof(AppDescriptor.SignLifetime), descriptor.SignLifetime); + } + await _appStore.CreateAsync(application, cancellationToken); + } +} diff --git a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/AbpOpenApiConsts.cs b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/AbpOpenApiConsts.cs index 78d60fb87..ad092f245 100644 --- a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/AbpOpenApiConsts.cs +++ b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/AbpOpenApiConsts.cs @@ -18,5 +18,8 @@ public static class AbpOpenApiConsts public const string InvalidAccessWithTimestamp = KeyPrefix + ":9210"; public const string InvalidAccessWithTimestampNotFound = KeyPrefix + ":9211"; + + public const string InvalidAccessWithClientId = KeyPrefix + ":9300"; + public const string InvalidAccessWithIpAddress = KeyPrefix + ":9400"; } } diff --git a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/AlwaysAllowClientChecker.cs b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/AlwaysAllowClientChecker.cs new file mode 100644 index 000000000..5046f5ff9 --- /dev/null +++ b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/AlwaysAllowClientChecker.cs @@ -0,0 +1,15 @@ +using Microsoft.Extensions.DependencyInjection; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; + +namespace LINGYUN.Abp.OpenApi; + +[Dependency(ServiceLifetime.Singleton, TryRegister = true)] +public class AlwaysAllowClientChecker : IClientChecker +{ + public Task IsGrantAsync(string clientId, CancellationToken cancellationToken = default) + { + return Task.FromResult(true); + } +} diff --git a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/AlwaysAllowIpAddressChecker.cs b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/AlwaysAllowIpAddressChecker.cs new file mode 100644 index 000000000..a8c09fa9e --- /dev/null +++ b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/AlwaysAllowIpAddressChecker.cs @@ -0,0 +1,15 @@ +using Microsoft.Extensions.DependencyInjection; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; + +namespace LINGYUN.Abp.OpenApi; + +[Dependency(ServiceLifetime.Singleton, TryRegister = true)] +public class AlwaysAllowIpAddressChecker : IIpAddressChecker +{ + public Task IsGrantAsync(string ipAddress, CancellationToken cancellationToken = default) + { + return Task.FromResult(true); + } +} diff --git a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/ConfigurationStore/DefaultAppKeyStore.cs b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/ConfigurationStore/DefaultAppKeyStore.cs index db2df8820..ae91920c2 100644 --- a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/ConfigurationStore/DefaultAppKeyStore.cs +++ b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/ConfigurationStore/DefaultAppKeyStore.cs @@ -1,5 +1,7 @@ using Microsoft.Extensions.Options; +using System.Collections.Generic; using System.Linq; +using System.Threading; using System.Threading.Tasks; using Volo.Abp.DependencyInjection; @@ -15,7 +17,7 @@ public DefaultAppKeyStore(IOptionsMonitor options) _options = options.CurrentValue; } - public Task FindAsync(string appKey) + public Task FindAsync(string appKey, CancellationToken cancellationToken = default) { return Task.FromResult(Find(appKey)); } @@ -24,5 +26,11 @@ public AppDescriptor Find(string appKey) { return _options.AppDescriptors?.FirstOrDefault(t => t.AppKey == appKey); } + + public Task StoreAsync(AppDescriptor descriptor, CancellationToken cancellationToken = default) + { + _options.AppDescriptors.AddIfNotContains(descriptor); + return Task.CompletedTask; + } } } diff --git a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/IAppKeyStore.cs b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/IAppKeyStore.cs index dad816af0..1db9649ac 100644 --- a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/IAppKeyStore.cs +++ b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/IAppKeyStore.cs @@ -1,9 +1,11 @@ -using System.Threading.Tasks; +using System.Threading; +using System.Threading.Tasks; -namespace LINGYUN.Abp.OpenApi +namespace LINGYUN.Abp.OpenApi; + +public interface IAppKeyStore { - public interface IAppKeyStore - { - Task FindAsync(string appKey); - } + Task FindAsync(string appKey, CancellationToken cancellationToken = default); + + Task StoreAsync(AppDescriptor descriptor, CancellationToken cancellationToken = default); } diff --git a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/IClientChecker.cs b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/IClientChecker.cs new file mode 100644 index 000000000..a430145d9 --- /dev/null +++ b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/IClientChecker.cs @@ -0,0 +1,9 @@ +using System.Threading; +using System.Threading.Tasks; + +namespace LINGYUN.Abp.OpenApi; + +public interface IClientChecker +{ + Task IsGrantAsync(string clientId, CancellationToken cancellationToken = default); +} diff --git a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/IIpAddressChecker.cs b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/IIpAddressChecker.cs new file mode 100644 index 000000000..ef9788355 --- /dev/null +++ b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/IIpAddressChecker.cs @@ -0,0 +1,8 @@ +using System.Threading; +using System.Threading.Tasks; + +namespace LINGYUN.Abp.OpenApi; +public interface IIpAddressChecker +{ + Task IsGrantAsync(string ipAddress, CancellationToken cancellationToken = default); +} diff --git a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/Localization/Resources/en.json b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/Localization/Resources/en.json index cffd482c2..761c17dfe 100644 --- a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/Localization/Resources/en.json +++ b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/Localization/Resources/en.json @@ -6,6 +6,8 @@ "AbpOpenApi:9110": "Invalid sign.", "AbpOpenApi:9111": "sign not found.", "AbpOpenApi:9210": "Request timed out or the session expired.", - "AbpOpenApi:9211": "timestamp not found." + "AbpOpenApi:9211": "timestamp not found.", + "AbpOpenApi:9300": "The client is not within the allowed range.", + "AbpOpenApi:9400": "The client IP is not within the allowed range." } } \ No newline at end of file diff --git a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/Localization/Resources/zh-Hans.json b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/Localization/Resources/zh-Hans.json index 0853fa4df..83b7aaef8 100644 --- a/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/Localization/Resources/zh-Hans.json +++ b/aspnet-core/framework/open-api/LINGYUN.Abp.OpenApi/LINGYUN/Abp/OpenApi/Localization/Resources/zh-Hans.json @@ -6,6 +6,8 @@ "AbpOpenApi:9110": "无效的签名 sign.", "AbpOpenApi:9111": "未携带签名(sign).", "AbpOpenApi:9210": "请求超时或会话已过期.", - "AbpOpenApi:9211": "未携带时间戳标识." + "AbpOpenApi:9211": "未携带时间戳标识.", + "AbpOpenApi:9300": "客户端不在允许的范围内.", + "AbpOpenApi:9400": "客户端IP不在允许的范围内." } } \ No newline at end of file diff --git a/aspnet-core/framework/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/PushPlusSettingAppService.cs b/aspnet-core/framework/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/PushPlusSettingAppService.cs index 634f87e5a..06f171e35 100644 --- a/aspnet-core/framework/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/PushPlusSettingAppService.cs +++ b/aspnet-core/framework/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/PushPlusSettingAppService.cs @@ -7,16 +7,17 @@ using Volo.Abp.MultiTenancy; using Volo.Abp.SettingManagement; using Volo.Abp.Settings; +using LINGYUN.Abp.PushPlus.Features; namespace LINGYUN.Abp.PushPlus.SettingManagement { - public class WxPusherSettingAppService : ApplicationService, IPushPlusSettingAppService + public class PushPlusSettingAppService : ApplicationService, IPushPlusSettingAppService { protected ISettingManager SettingManager { get; } protected IPermissionChecker PermissionChecker { get; } protected ISettingDefinitionManager SettingDefinitionManager { get; } - public WxPusherSettingAppService( + public PushPlusSettingAppService( ISettingManager settingManager, IPermissionChecker permissionChecker, ISettingDefinitionManager settingDefinitionManager) @@ -42,7 +43,8 @@ protected async virtual Task GetAllForProviderAsync(string p var settingGroups = new SettingGroupResult(); var pushPlusSettingGroup = new SettingGroupDto(L["DisplayName:PushPlus"], L["Description:PushPlus"]); - if (await PermissionChecker.IsGrantedAsync(PushPlusSettingPermissionNames.ManageSetting)) + if (await FeatureChecker.IsEnabledAsync(PushPlusFeatureNames.Message.Enable) && + await PermissionChecker.IsGrantedAsync(PushPlusSettingPermissionNames.ManageSetting)) { var securitySetting = pushPlusSettingGroup.AddSetting(L["Security"], L["Security"]); securitySetting.AddDetail( diff --git a/aspnet-core/framework/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/PushPlusSettingController.cs b/aspnet-core/framework/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/PushPlusSettingController.cs index a27f1c2dc..ebc6cca4c 100644 --- a/aspnet-core/framework/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/PushPlusSettingController.cs +++ b/aspnet-core/framework/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/PushPlusSettingController.cs @@ -9,11 +9,11 @@ namespace LINGYUN.Abp.PushPlus.SettingManagement [RemoteService(Name = AbpSettingManagementRemoteServiceConsts.RemoteServiceName)] [Area(AbpSettingManagementRemoteServiceConsts.ModuleName)] [Route($"api/{AbpSettingManagementRemoteServiceConsts.ModuleName}/push-plus")] - public class WxPusherSettingController : AbpControllerBase, IPushPlusSettingAppService + public class PushPlusSettingController : AbpControllerBase, IPushPlusSettingAppService { protected IPushPlusSettingAppService Service { get; } - public WxPusherSettingController( + public PushPlusSettingController( IPushPlusSettingAppService service) { Service = service; diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.SettingManagement/LINGYUN/Abp/WeChat/SettingManagement/WeChatSettingAppService.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.SettingManagement/LINGYUN/Abp/WeChat/SettingManagement/WeChatSettingAppService.cs index 1616fcd76..e03d89bdb 100644 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.SettingManagement/LINGYUN/Abp/WeChat/SettingManagement/WeChatSettingAppService.cs +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.SettingManagement/LINGYUN/Abp/WeChat/SettingManagement/WeChatSettingAppService.cs @@ -1,8 +1,11 @@ using LINGYUN.Abp.SettingManagement; using LINGYUN.Abp.WeChat.Localization; +using LINGYUN.Abp.WeChat.MiniProgram.Features; using LINGYUN.Abp.WeChat.MiniProgram.Settings; +using LINGYUN.Abp.WeChat.Official.Features; using LINGYUN.Abp.WeChat.Official.Settings; using LINGYUN.Abp.WeChat.Settings; +using LINGYUN.Abp.WeChat.Work.Features; using LINGYUN.Abp.WeChat.Work.Settings; using System.Threading.Tasks; using Volo.Abp.Application.Services; @@ -54,7 +57,8 @@ await SettingManager.GetOrNullAsync(WeChatSettingNames.EnabledQuickLogin, provid providerName); // 无权限返回空结果,直接报错的话,网关聚合会抛出异常 - if (await PermissionChecker.IsGrantedAsync(WeChatSettingPermissionNames.Official)) + if (await FeatureChecker.IsEnabledAsync(WeChatOfficialFeatures.Enable) && + await PermissionChecker.IsGrantedAsync(WeChatSettingPermissionNames.Official)) { #region 公众号 @@ -99,7 +103,8 @@ await SettingManager.GetOrNullAsync(WeChatOfficialSettingNames.EncodingAESKey, p #endregion } - if (await PermissionChecker.IsGrantedAsync(WeChatSettingPermissionNames.MiniProgram)) + if (await FeatureChecker.IsEnabledAsync(WeChatMiniProgramFeatures.Enable) && + await PermissionChecker.IsGrantedAsync(WeChatSettingPermissionNames.MiniProgram)) { #region 小程序 @@ -134,7 +139,8 @@ await SettingManager.GetOrNullAsync(WeChatMiniProgramSettingNames.EncodingAESKey settingGroups.AddGroup(wechatSettingGroup); - if (await PermissionChecker.IsGrantedAsync(WeChatSettingPermissionNames.Work)) + if (await FeatureChecker.IsEnabledAsync(WeChatWorkFeatureNames.Enable) && + await PermissionChecker.IsGrantedAsync(WeChatSettingPermissionNames.Work)) { #region 企业微信 var wechatWorkSettingGroup = new SettingGroupDto(L["DisplayName:WeChatWork"], L["Description:WeChatWork"]); diff --git a/aspnet-core/framework/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/WxPusherSettingAppService.cs b/aspnet-core/framework/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/WxPusherSettingAppService.cs index dcb31559d..8689fa90c 100644 --- a/aspnet-core/framework/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/WxPusherSettingAppService.cs +++ b/aspnet-core/framework/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/WxPusherSettingAppService.cs @@ -1,4 +1,5 @@ using LINGYUN.Abp.SettingManagement; +using LINGYUN.Abp.WxPusher.Features; using LINGYUN.Abp.WxPusher.Localization; using LINGYUN.Abp.WxPusher.Settings; using System.Threading.Tasks; @@ -42,7 +43,8 @@ protected async virtual Task GetAllForProviderAsync(string p var settingGroups = new SettingGroupResult(); var wxPusherSettingGroup = new SettingGroupDto(L["DisplayName:WxPusher"], L["Description:WxPusher"]); - if (await PermissionChecker.IsGrantedAsync(WxPusherSettingPermissionNames.ManageSetting)) + if (await FeatureChecker.IsEnabledAsync(WxPusherFeatureNames.Enable) && + await PermissionChecker.IsGrantedAsync(WxPusherSettingPermissionNames.ManageSetting)) { var securitySetting = wxPusherSettingGroup.AddSetting(L["Security"], L["Security"]); securitySetting.AddDetail( diff --git a/aspnet-core/framework/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN.Abp.WxPusher.csproj b/aspnet-core/framework/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN.Abp.WxPusher.csproj index bc79cce77..9e5d55058 100644 --- a/aspnet-core/framework/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN.Abp.WxPusher.csproj +++ b/aspnet-core/framework/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN.Abp.WxPusher.csproj @@ -1,7 +1,6 @@  - diff --git a/aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/Migrations/20240527092536_Remote-Tenant-Id-With-Text-Template.Designer.cs b/aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/Migrations/20240527092536_Remote-Tenant-Id-With-Text-Template.Designer.cs new file mode 100644 index 000000000..bc41c6d64 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/Migrations/20240527092536_Remote-Tenant-Id-With-Text-Template.Designer.cs @@ -0,0 +1,938 @@ +// +using System; +using LY.MicroService.BackendAdmin.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.BackendAdmin.EntityFrameworkCore.Migrations +{ + [DbContext(typeof(BackendAdminMigrationsDbContext))] + [Migration("20240527092536_Remote-Tenant-Id-With-Text-Template")] + partial class RemoteTenantIdWithTextTemplate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Abp.DataProtectionManagement.EntityPropertyInfo", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Name"); + + b.Property("TypeFullName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("TypeFullName"); + + b.Property("TypeInfoId") + .HasColumnType("char(36)"); + + b.Property("ValueRange") + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("ValueRange"); + + b.HasKey("Id"); + + b.HasIndex("TypeInfoId", "TypeFullName"); + + b.ToTable("AbpAuthEntityProperties", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.DataProtectionManagement.EntityTypeInfo", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsAuditEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Name"); + + b.Property("TypeFullName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("TypeFullName"); + + b.HasKey("Id"); + + b.HasIndex("TypeFullName"); + + b.ToTable("AbpAuthEntitites", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.DataProtectionManagement.OrganizationUnitEntityRule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AllowProperties") + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("AllowProperties"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("EntityTypeFullName") + .HasColumnType("longtext"); + + b.Property("EntityTypeId") + .HasColumnType("char(36)"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("FilterGroup") + .HasColumnType("longtext") + .HasColumnName("FilterGroup"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Operation") + .HasColumnType("int"); + + b.Property("OrgCode") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("OrgCode"); + + b.Property("OrgId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("EntityTypeId"); + + b.ToTable("AbpAuthOrganizationUnitEntityRules", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.DataProtectionManagement.RoleEntityRule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AllowProperties") + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("AllowProperties"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("EntityTypeFullName") + .HasColumnType("longtext"); + + b.Property("EntityTypeId") + .HasColumnType("char(36)"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("FilterGroup") + .HasColumnType("longtext") + .HasColumnName("FilterGroup"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Operation") + .HasColumnType("int"); + + b.Property("RoleId") + .HasColumnType("char(36)"); + + b.Property("RoleName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("RoleName"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("EntityTypeId"); + + b.ToTable("AbpAuthRoleEntityRules", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Editions.Edition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("EntityVersion") + .HasColumnType("int"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.HasKey("Id"); + + b.HasIndex("DisplayName"); + + b.ToTable("AbpEditions", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("DisableTime") + .HasColumnType("datetime(6)"); + + b.Property("EditionId") + .HasColumnType("char(36)"); + + b.Property("EnableTime") + .HasColumnType("datetime(6)"); + + b.Property("EntityVersion") + .HasColumnType("int"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("NormalizedName") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.HasKey("Id"); + + b.HasIndex("EditionId"); + + b.HasIndex("Name"); + + b.HasIndex("NormalizedName"); + + b.ToTable("AbpTenants", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.TenantConnectionString", b => + { + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.Property("Name") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.HasKey("TenantId", "Name"); + + b.ToTable("AbpTenantConnectionStrings", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.TextTemplating.TextTemplate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Content") + .HasMaxLength(1048576) + .HasColumnType("longtext") + .HasColumnName("Content"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Culture") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Culture"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("DisplayName"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("Name"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .HasDatabaseName("IX_Tenant_Text_Template_Name"); + + b.ToTable("AbpTextTemplates", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.TextTemplating.TextTemplateDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("DefaultCultureName") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("DefaultCultureName"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsInlineLocalized") + .HasColumnType("tinyint(1)"); + + b.Property("IsLayout") + .HasColumnType("tinyint(1)"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("Layout") + .HasMaxLength(60) + .HasColumnType("varchar(60)") + .HasColumnName("Layout"); + + b.Property("LocalizationResourceName") + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("LocalizationResourceName"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("Name"); + + b.Property("RenderEngine") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("RenderEngine"); + + b.HasKey("Id"); + + b.ToTable("AbpTextTemplateDefinitions", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AllowedProviders") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("DefaultValue") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("Description") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("GroupName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("IsAvailableToHost") + .HasColumnType("tinyint(1)"); + + b.Property("IsVisibleToClients") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ParentName") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ValueType") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.HasKey("Id"); + + b.HasIndex("GroupName"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpFeatures", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureGroupDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpFeatureGroups", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureValue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ProviderKey") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ProviderName") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("Name", "ProviderName", "ProviderKey") + .IsUnique(); + + b.ToTable("AbpFeatureValues", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("GroupName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("MultiTenancySide") + .HasColumnType("tinyint unsigned"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ParentName") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Providers") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("StateCheckers") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("GroupName"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpPermissions", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGrant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ProviderKey") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ProviderName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Name", "ProviderName", "ProviderKey") + .IsUnique(); + + b.ToTable("AbpPermissionGrants", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGroupDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpPermissionGroups", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.SettingManagement.Setting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ProviderKey") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ProviderName") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.HasKey("Id"); + + b.HasIndex("Name", "ProviderName", "ProviderKey") + .IsUnique(); + + b.ToTable("AbpSettings", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.SettingManagement.SettingDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("DefaultValue") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("Description") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsEncrypted") + .HasColumnType("tinyint(1)"); + + b.Property("IsInherited") + .HasColumnType("tinyint(1)"); + + b.Property("IsVisibleToClients") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Providers") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpSettingDefinitions", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.DataProtectionManagement.EntityPropertyInfo", b => + { + b.HasOne("LINGYUN.Abp.DataProtectionManagement.EntityTypeInfo", "TypeInfo") + .WithMany("Properties") + .HasForeignKey("TypeInfoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TypeInfo"); + }); + + modelBuilder.Entity("LINGYUN.Abp.DataProtectionManagement.OrganizationUnitEntityRule", b => + { + b.HasOne("LINGYUN.Abp.DataProtectionManagement.EntityTypeInfo", "EntityTypeInfo") + .WithMany() + .HasForeignKey("EntityTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EntityTypeInfo"); + }); + + modelBuilder.Entity("LINGYUN.Abp.DataProtectionManagement.RoleEntityRule", b => + { + b.HasOne("LINGYUN.Abp.DataProtectionManagement.EntityTypeInfo", "EntityTypeInfo") + .WithMany() + .HasForeignKey("EntityTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EntityTypeInfo"); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => + { + b.HasOne("LINGYUN.Abp.Saas.Editions.Edition", "Edition") + .WithMany() + .HasForeignKey("EditionId"); + + b.Navigation("Edition"); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.TenantConnectionString", b => + { + b.HasOne("LINGYUN.Abp.Saas.Tenants.Tenant", null) + .WithMany("ConnectionStrings") + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LINGYUN.Abp.DataProtectionManagement.EntityTypeInfo", b => + { + b.Navigation("Properties"); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => + { + b.Navigation("ConnectionStrings"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/Migrations/20240527092536_Remote-Tenant-Id-With-Text-Template.cs b/aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/Migrations/20240527092536_Remote-Tenant-Id-With-Text-Template.cs new file mode 100644 index 000000000..31949421b --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/Migrations/20240527092536_Remote-Tenant-Id-With-Text-Template.cs @@ -0,0 +1,48 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LY.MicroService.BackendAdmin.EntityFrameworkCore.Migrations +{ + /// + public partial class RemoteTenantIdWithTextTemplate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_Tenant_Text_Template_Name", + table: "AbpTextTemplates"); + + migrationBuilder.DropColumn( + name: "TenantId", + table: "AbpTextTemplates"); + + migrationBuilder.CreateIndex( + name: "IX_Tenant_Text_Template_Name", + table: "AbpTextTemplates", + column: "Name"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_Tenant_Text_Template_Name", + table: "AbpTextTemplates"); + + migrationBuilder.AddColumn( + name: "TenantId", + table: "AbpTextTemplates", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + + migrationBuilder.CreateIndex( + name: "IX_Tenant_Text_Template_Name", + table: "AbpTextTemplates", + columns: new[] { "TenantId", "Name" }); + } + } +} diff --git a/aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/Migrations/BackendAdminMigrationsDbContextModelSnapshot.cs b/aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/Migrations/BackendAdminMigrationsDbContextModelSnapshot.cs index 9b028cb4e..fe631da35 100644 --- a/aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/Migrations/BackendAdminMigrationsDbContextModelSnapshot.cs +++ b/aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/Migrations/BackendAdminMigrationsDbContextModelSnapshot.cs @@ -481,13 +481,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("varchar(100)") .HasColumnName("Name"); - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - b.HasKey("Id"); - b.HasIndex("TenantId", "Name") + b.HasIndex("Name") .HasDatabaseName("IX_Tenant_Text_Template_Name"); b.ToTable("AbpTextTemplates", (string)null); diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.WeChat.Work/LINGYUN/Abp/IdentityServer/WeChat/Work/WeChatWorkGrantValidator.cs b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.WeChat.Work/LINGYUN/Abp/IdentityServer/WeChat/Work/WeChatWorkGrantValidator.cs index 36dff4903..f31356bdd 100644 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.WeChat.Work/LINGYUN/Abp/IdentityServer/WeChat/Work/WeChatWorkGrantValidator.cs +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.WeChat.Work/LINGYUN/Abp/IdentityServer/WeChat/Work/WeChatWorkGrantValidator.cs @@ -92,7 +92,7 @@ public async virtual Task ValidateAsync(ExtensionGrantValidationContext context) if (!await SettingProvider.IsTrueAsync("Abp.Account.IsSelfRegistrationEnabled") || !await SettingProvider.IsTrueAsync(WeChatWorkSettingNames.EnabledQuickLogin)) { - Logger.LogWarning("Invalid grant type: wechat work user not register", userInfo.UserId); + Logger.LogWarning("Invalid grant type: wechat work user {userId} not register", userInfo.UserId); context.Result = new GrantValidationResult(TokenRequestErrors.InvalidGrant, WeChatWorkLocalizer["InvalidGrant:UserIdNotRegister"]); return; diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.WeChat.Work/LINGYUN/Abp/OpenIddict/WeChat/Work/WeChatWorkTokenExtensionGrant.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.WeChat.Work/LINGYUN/Abp/OpenIddict/WeChat/Work/WeChatWorkTokenExtensionGrant.cs index 6a616d45a..0c9edc875 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.WeChat.Work/LINGYUN/Abp/OpenIddict/WeChat/Work/WeChatWorkTokenExtensionGrant.cs +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.WeChat.Work/LINGYUN/Abp/OpenIddict/WeChat/Work/WeChatWorkTokenExtensionGrant.cs @@ -77,7 +77,7 @@ protected async virtual Task HandleWeChatAsync(ExtensionGrantCont if (!await settingProvider.IsTrueAsync("Abp.Account.IsSelfRegistrationEnabled") || !await settingProvider.IsTrueAsync(WeChatWorkSettingNames.EnabledQuickLogin)) { - logger.LogWarning("Invalid grant type: wechat work user not register", userInfo.UserId); + logger.LogWarning("Invalid grant type: wechat work user {userId} not register", userInfo.UserId); var properties = new AuthenticationProperties(new Dictionary { diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Aliyun/LINGYUN/Abp/OssManagement/Aliyun/AliyunOssContainer.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Aliyun/LINGYUN/Abp/OssManagement/Aliyun/AliyunOssContainer.cs index fff56230e..570da80ef 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Aliyun/LINGYUN/Abp/OssManagement/Aliyun/AliyunOssContainer.cs +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Aliyun/LINGYUN/Abp/OssManagement/Aliyun/AliyunOssContainer.cs @@ -396,7 +396,7 @@ protected virtual bool ObjectExists(IOss client, string bucketName, string objec protected async virtual Task CreateClientAsync() { - return await OssClientFactory.CreateAsync(); + return await OssClientFactory.CreateAsync(); } } } diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.SettingManagement/LINGYUN/Abp/OssManagement/SettingManagement/OssManagementSettingAppService.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.SettingManagement/LINGYUN/Abp/OssManagement/SettingManagement/OssManagementSettingAppService.cs index 46901f558..c7d4b8ae0 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.SettingManagement/LINGYUN/Abp/OssManagement/SettingManagement/OssManagementSettingAppService.cs +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.SettingManagement/LINGYUN/Abp/OssManagement/SettingManagement/OssManagementSettingAppService.cs @@ -1,4 +1,5 @@ -using LINGYUN.Abp.OssManagement.Localization; +using LINGYUN.Abp.OssManagement.Features; +using LINGYUN.Abp.OssManagement.Localization; using LINGYUN.Abp.OssManagement.Permissions; using LINGYUN.Abp.OssManagement.Settings; using LINGYUN.Abp.SettingManagement; @@ -44,7 +45,8 @@ protected async virtual Task GetAllForProviderAsync(string p var settingGroups = new SettingGroupResult(); // 无权限返回空结果,直接报错的话,网关聚合会抛出异常 - if (await PermissionChecker.IsGrantedAsync(AbpOssManagementPermissions.OssObject.Default)) + if (await FeatureChecker.IsEnabledAsync(AbpOssManagementFeatureNames.OssObject.Enable) && + await PermissionChecker.IsGrantedAsync(AbpOssManagementPermissions.OssObject.Default)) { var ossSettingGroup = new SettingGroupDto(L["DisplayName:OssManagement"], L["Description:OssManagement"]); diff --git a/aspnet-core/modules/permissions-management/LINGYUN.Abp.PermissionManagement.Domain.OrganizationUnits/LINGYUN/Abp/PermissionManagement/OrganizationUnits/OrganizationUnitDeletedEventHandler.cs b/aspnet-core/modules/permissions-management/LINGYUN.Abp.PermissionManagement.Domain.OrganizationUnits/LINGYUN/Abp/PermissionManagement/OrganizationUnits/OrganizationUnitDeletedEventHandler.cs index 01df3ad84..a5315aaa2 100644 --- a/aspnet-core/modules/permissions-management/LINGYUN.Abp.PermissionManagement.Domain.OrganizationUnits/LINGYUN/Abp/PermissionManagement/OrganizationUnits/OrganizationUnitDeletedEventHandler.cs +++ b/aspnet-core/modules/permissions-management/LINGYUN.Abp.PermissionManagement.Domain.OrganizationUnits/LINGYUN/Abp/PermissionManagement/OrganizationUnits/OrganizationUnitDeletedEventHandler.cs @@ -21,6 +21,7 @@ public OrganizationUnitDeletedEventHandler(IPermissionManager permissionManager) public async Task HandleEventAsync(EntityDeletedEto eventData) { + await PermissionManager.DeleteAsync(OrganizationUnitPermissionValueProvider.ProviderName, eventData.Entity.Code); await PermissionManager.DeleteAsync(OrganizationUnitPermissionValueProvider.ProviderName, eventData.Entity.Id.ToString()); } } diff --git a/aspnet-core/modules/permissions-management/LINGYUN.Abp.PermissionManagement.Domain.OrganizationUnits/LINGYUN/Abp/PermissionManagement/OrganizationUnits/OrganizationUnitPermissionManagementProvider.cs b/aspnet-core/modules/permissions-management/LINGYUN.Abp.PermissionManagement.Domain.OrganizationUnits/LINGYUN/Abp/PermissionManagement/OrganizationUnits/OrganizationUnitPermissionManagementProvider.cs index 8bf9af5a1..2919c135d 100644 --- a/aspnet-core/modules/permissions-management/LINGYUN.Abp.PermissionManagement.Domain.OrganizationUnits/LINGYUN/Abp/PermissionManagement/OrganizationUnits/OrganizationUnitPermissionManagementProvider.cs +++ b/aspnet-core/modules/permissions-management/LINGYUN.Abp.PermissionManagement.Domain.OrganizationUnits/LINGYUN/Abp/PermissionManagement/OrganizationUnits/OrganizationUnitPermissionManagementProvider.cs @@ -65,7 +65,7 @@ public override async Task CheckAsync( { var role = await IdentityRoleRepository.FindByNormalizedNameAsync(UserManager.NormalizeName(providerKey)); var organizationUnits = await IdentityRoleRepository.GetOrganizationUnitsAsync(role.Id); - var roleOrganizationUnits = organizationUnits.Select(x => x.Id.ToString()); + var roleOrganizationUnits = organizationUnits.Select(x => x.Code.ToString()); var quaryble = await PermissionGrantBasicRepository.GetQueryableAsync(); quaryble = quaryble.Where(x => x.ProviderName == Name && roleOrganizationUnits.Contains(x.ProviderKey) && names.Contains(x.Name)); @@ -78,7 +78,7 @@ public override async Task CheckAsync( { var userId = Guid.Parse(providerKey); var organizationUnits = await IdentityUserRepository.GetOrganizationUnitsAsync(id: userId); - var userOrganizationUnits = organizationUnits.Select(x => x.Id.ToString()); + var userOrganizationUnits = organizationUnits.Select(x => x.Code.ToString()); var quaryble = await PermissionGrantBasicRepository.GetQueryableAsync(); quaryble = quaryble.Where(x => x.ProviderName == Name && userOrganizationUnits.Contains(x.ProviderKey) && names.Contains(x.Name)); diff --git a/aspnet-core/modules/permissions-management/LINGYUN.Abp.PermissionManagement.Domain.OrganizationUnits/Volo/Abp/PermissionManagement/OrganizationUnitPermissionManagerExtensions.cs b/aspnet-core/modules/permissions-management/LINGYUN.Abp.PermissionManagement.Domain.OrganizationUnits/Volo/Abp/PermissionManagement/OrganizationUnitPermissionManagerExtensions.cs index 20ee29e9e..d36a42fd6 100644 --- a/aspnet-core/modules/permissions-management/LINGYUN.Abp.PermissionManagement.Domain.OrganizationUnits/Volo/Abp/PermissionManagement/OrganizationUnitPermissionManagerExtensions.cs +++ b/aspnet-core/modules/permissions-management/LINGYUN.Abp.PermissionManagement.Domain.OrganizationUnits/Volo/Abp/PermissionManagement/OrganizationUnitPermissionManagerExtensions.cs @@ -10,31 +10,31 @@ public static class OrganizationUnitPermissionManagerExtensions { public static Task GetForOrganizationUnitAsync( [NotNull] this IPermissionManager permissionManager, - Guid organizationUnitId, + string organizationUnitCode, string permissionName) { Check.NotNull(permissionManager, nameof(permissionManager)); - return permissionManager.GetAsync(permissionName, OrganizationUnitPermissionValueProvider.ProviderName, organizationUnitId.ToString()); + return permissionManager.GetAsync(permissionName, OrganizationUnitPermissionValueProvider.ProviderName, organizationUnitCode); } public static Task> GetAllForOrganizationUnitAsync( [NotNull] this IPermissionManager permissionManager, - Guid organizationUnitId) + string organizationUnitCode) { Check.NotNull(permissionManager, nameof(permissionManager)); - return permissionManager.GetAllAsync(OrganizationUnitPermissionValueProvider.ProviderName, organizationUnitId.ToString()); + return permissionManager.GetAllAsync(OrganizationUnitPermissionValueProvider.ProviderName, organizationUnitCode); } public static Task SetForOrganizationUnitAsync( [NotNull] this IPermissionManager permissionManager, - Guid organizationUnitId, + string organizationUnitCode, [NotNull] string permissionName, bool isGranted) { Check.NotNull(permissionManager, nameof(permissionManager)); - return permissionManager.SetAsync(permissionName, OrganizationUnitPermissionValueProvider.ProviderName, organizationUnitId.ToString(), isGranted); + return permissionManager.SetAsync(permissionName, OrganizationUnitPermissionValueProvider.ProviderName, organizationUnitCode, isGranted); } } diff --git a/aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionInitializer.cs b/aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionInitializer.cs index b96a44ae1..41bc29fc6 100644 --- a/aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionInitializer.cs +++ b/aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Domain/LINGYUN/Abp/Notifications/NotificationDefinitionInitializer.cs @@ -52,7 +52,7 @@ public async virtual Task InitializeDynamicNotifications(CancellationToken cance return; } - await PreCacheDynamicNotificationsAsync(scope); + // await PreCacheDynamicNotificationsAsync(scope); } } catch (OperationCanceledException) diff --git a/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application/LINGYUN/Abp/SettingManagement/SettingAppService.cs b/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application/LINGYUN/Abp/SettingManagement/SettingAppService.cs index 9dbea3259..ab47f06e5 100644 --- a/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application/LINGYUN/Abp/SettingManagement/SettingAppService.cs +++ b/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application/LINGYUN/Abp/SettingManagement/SettingAppService.cs @@ -373,91 +373,95 @@ await SettingManager.GetOrNullAsync(IdentitySettingNames.OrganizationUnit.MaxUse #region 邮件设置 - var emailSettingGroup = new SettingGroupDto(L["DisplayName:Emailing"], L["Description:Emailing"]); - - var defaultMailSetting = emailSettingGroup.AddSetting(L["DisplayName:Emailing.Default"], L["Description:Emailing.Default"]); - defaultMailSetting.AddDetail( - await SettingDefinitionManager.GetAsync(EmailSettingNames.DefaultFromAddress), - StringLocalizerFactory, - await SettingManager.GetOrNullAsync(EmailSettingNames.DefaultFromAddress, providerName, providerKey), - ValueType.String, - providerName) - .RequiredPermission("SettingManagement.Emailing"); - defaultMailSetting.AddDetail( - await SettingDefinitionManager.GetAsync(EmailSettingNames.DefaultFromDisplayName), - StringLocalizerFactory, - await SettingManager.GetOrNullAsync(EmailSettingNames.DefaultFromDisplayName, providerName, providerKey), - ValueType.String, - providerName) - .RequiredPermission("SettingManagement.Emailing"); - - // 防止邮件设置泄露 - if (await AuthorizationService.IsGrantedAsync(AbpSettingManagementPermissions.Settings.Manager)) + if (await FeatureChecker.IsEnabledAsync(true, [SettingManagementFeatures.Enable, SettingManagementFeatures.AllowChangingEmailSettings])) { - var smtpSetting = emailSettingGroup.AddSetting(L["DisplayName:Emailing.Smtp"], L["Description:Emailing.Smtp"]); - smtpSetting.AddDetail( - await SettingDefinitionManager.GetAsync(EmailSettingNames.Smtp.EnableSsl), - StringLocalizerFactory, - await SettingManager.GetOrNullAsync(EmailSettingNames.Smtp.EnableSsl, providerName, providerKey), - ValueType.Boolean, - providerName) - .RequiredPermission("SettingManagement.Emailing"); - smtpSetting.AddDetail( - await SettingDefinitionManager.GetAsync(EmailSettingNames.Smtp.UseDefaultCredentials), - StringLocalizerFactory, - await SettingManager.GetOrNullAsync(EmailSettingNames.Smtp.UseDefaultCredentials, providerName, providerKey), - ValueType.Boolean, - providerName) - .RequiredPermission("SettingManagement.Emailing"); - smtpSetting.AddDetail( - await SettingDefinitionManager.GetAsync(EmailSettingNames.Smtp.Domain), - StringLocalizerFactory, - await SettingManager.GetOrNullAsync(EmailSettingNames.Smtp.Domain, providerName, providerKey), - ValueType.String, - providerName) - .RequiredPermission("SettingManagement.Emailing"); - smtpSetting.AddDetail( - await SettingDefinitionManager.GetAsync(EmailSettingNames.Smtp.Host), - StringLocalizerFactory, - await SettingManager.GetOrNullAsync(EmailSettingNames.Smtp.Host, providerName, providerKey), - ValueType.String, - providerName); - smtpSetting.AddDetail( - await SettingDefinitionManager.GetAsync(EmailSettingNames.Smtp.Port), - StringLocalizerFactory, - await SettingManager.GetOrNullAsync(EmailSettingNames.Smtp.Port, providerName, providerKey), - ValueType.Number, - providerName) - .RequiredPermission("SettingManagement.Emailing"); - smtpSetting.AddDetail( - await SettingDefinitionManager.GetAsync(EmailSettingNames.Smtp.UserName), - StringLocalizerFactory, - await SettingManager.GetOrNullAsync(EmailSettingNames.Smtp.UserName, providerName, providerKey), - ValueType.String, - providerName) - .RequiredPermission("SettingManagement.Emailing"); - smtpSetting.AddDetail( - await SettingDefinitionManager.GetAsync(EmailSettingNames.Smtp.Password), + var emailSettingGroup = new SettingGroupDto(L["DisplayName:Emailing"], L["Description:Emailing"]); + + var defaultMailSetting = emailSettingGroup.AddSetting(L["DisplayName:Emailing.Default"], L["Description:Emailing.Default"]); + defaultMailSetting.AddDetail( + await SettingDefinitionManager.GetAsync(EmailSettingNames.DefaultFromAddress), StringLocalizerFactory, - await SettingManager.GetOrNullAsync(EmailSettingNames.Smtp.Password, providerName, providerKey), + await SettingManager.GetOrNullAsync(EmailSettingNames.DefaultFromAddress, providerName, providerKey), ValueType.String, providerName) .RequiredPermission("SettingManagement.Emailing"); - // 一个占位符,用于展现发送测试邮件 - smtpSetting.AddDetail( - new SettingDefinition( - name: "SendTestEmail", - displayName: LocalizableString.Create("DisplayName:Emailing.SendTestEmail"), - description: LocalizableString.Create("Description:Emailing.SendTestEmail")), + defaultMailSetting.AddDetail( + await SettingDefinitionManager.GetAsync(EmailSettingNames.DefaultFromDisplayName), StringLocalizerFactory, - "", + await SettingManager.GetOrNullAsync(EmailSettingNames.DefaultFromDisplayName, providerName, providerKey), ValueType.String, providerName) - .WithSlot("send-test-email") .RequiredPermission("SettingManagement.Emailing"); - } - settingGroups.AddGroup(emailSettingGroup); + // 防止邮件设置泄露 + if (await AuthorizationService.IsGrantedAsync(AbpSettingManagementPermissions.Settings.Manager)) + { + var smtpSetting = emailSettingGroup.AddSetting(L["DisplayName:Emailing.Smtp"], L["Description:Emailing.Smtp"]); + smtpSetting.AddDetail( + await SettingDefinitionManager.GetAsync(EmailSettingNames.Smtp.EnableSsl), + StringLocalizerFactory, + await SettingManager.GetOrNullAsync(EmailSettingNames.Smtp.EnableSsl, providerName, providerKey), + ValueType.Boolean, + providerName) + .RequiredPermission("SettingManagement.Emailing"); + smtpSetting.AddDetail( + await SettingDefinitionManager.GetAsync(EmailSettingNames.Smtp.UseDefaultCredentials), + StringLocalizerFactory, + await SettingManager.GetOrNullAsync(EmailSettingNames.Smtp.UseDefaultCredentials, providerName, providerKey), + ValueType.Boolean, + providerName) + .RequiredPermission("SettingManagement.Emailing"); + smtpSetting.AddDetail( + await SettingDefinitionManager.GetAsync(EmailSettingNames.Smtp.Domain), + StringLocalizerFactory, + await SettingManager.GetOrNullAsync(EmailSettingNames.Smtp.Domain, providerName, providerKey), + ValueType.String, + providerName) + .RequiredPermission("SettingManagement.Emailing"); + smtpSetting.AddDetail( + await SettingDefinitionManager.GetAsync(EmailSettingNames.Smtp.Host), + StringLocalizerFactory, + await SettingManager.GetOrNullAsync(EmailSettingNames.Smtp.Host, providerName, providerKey), + ValueType.String, + providerName); + smtpSetting.AddDetail( + await SettingDefinitionManager.GetAsync(EmailSettingNames.Smtp.Port), + StringLocalizerFactory, + await SettingManager.GetOrNullAsync(EmailSettingNames.Smtp.Port, providerName, providerKey), + ValueType.Number, + providerName) + .RequiredPermission("SettingManagement.Emailing"); + smtpSetting.AddDetail( + await SettingDefinitionManager.GetAsync(EmailSettingNames.Smtp.UserName), + StringLocalizerFactory, + await SettingManager.GetOrNullAsync(EmailSettingNames.Smtp.UserName, providerName, providerKey), + ValueType.String, + providerName) + .RequiredPermission("SettingManagement.Emailing"); + smtpSetting.AddDetail( + await SettingDefinitionManager.GetAsync(EmailSettingNames.Smtp.Password), + StringLocalizerFactory, + await SettingManager.GetOrNullAsync(EmailSettingNames.Smtp.Password, providerName, providerKey), + ValueType.String, + providerName) + .RequiredPermission("SettingManagement.Emailing"); + // 一个占位符,用于展现发送测试邮件 + smtpSetting.AddDetail( + new SettingDefinition( + name: "SendTestEmail", + displayName: LocalizableString.Create("DisplayName:Emailing.SendTestEmail"), + description: LocalizableString.Create("Description:Emailing.SendTestEmail")), + StringLocalizerFactory, + "", + ValueType.String, + providerName) + .WithSlot("send-test-email") + .RequiredPermission("SettingManagement.Emailing"); + } + + + settingGroups.AddGroup(emailSettingGroup); + } #endregion diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Quartz/LINGYUN/Abp/BackgroundTasks/Quartz/QuartzJobListener.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Quartz/LINGYUN/Abp/BackgroundTasks/Quartz/QuartzJobListener.cs index 540519d19..066c92913 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Quartz/LINGYUN/Abp/BackgroundTasks/Quartz/QuartzJobListener.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Quartz/LINGYUN/Abp/BackgroundTasks/Quartz/QuartzJobListener.cs @@ -128,11 +128,17 @@ public override async Task JobWasExecuted(IJobExecutionContext context, JobExecu jobEventData.RepeatCount = simpleTrigger.RepeatCount; } jobEventData.Description = context.JobDetail.Description; - jobEventData.RunTime = Clock.Now; - jobEventData.LastRunTime = context.PreviousFireTimeUtc?.LocalDateTime - ?? context.Trigger.GetPreviousFireTimeUtc()?.LocalDateTime; - jobEventData.NextRunTime = context.NextFireTimeUtc?.LocalDateTime - ?? context.Trigger.GetNextFireTimeUtc()?.LocalDateTime; + jobEventData.RunTime = Clock.Normalize(context.FireTimeUtc.DateTime); + var lastRunTime = context.PreviousFireTimeUtc?.DateTime ?? context.Trigger.GetPreviousFireTimeUtc()?.DateTime; + if (lastRunTime.HasValue) + { + jobEventData.RunTime = Clock.Normalize(lastRunTime.Value); + } + var nextRunTime = context.NextFireTimeUtc?.DateTime ?? context.Trigger.GetNextFireTimeUtc()?.DateTime; + if (nextRunTime.HasValue) + { + jobEventData.NextRunTime = Clock.Normalize(nextRunTime.Value); + } if (context.Result != null) { jobEventData.Result = context.Result?.ToString(); diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/LINGYUN/Abp/TextTemplating/TextTemplateEto.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/LINGYUN/Abp/TextTemplating/TextTemplateEto.cs index 9592d9691..c14994177 100644 --- a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/LINGYUN/Abp/TextTemplating/TextTemplateEto.cs +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/LINGYUN/Abp/TextTemplating/TextTemplateEto.cs @@ -1,11 +1,7 @@ -using System; -using Volo.Abp.MultiTenancy; +namespace LINGYUN.Abp.TextTemplating; -namespace LINGYUN.Abp.TextTemplating; - -public class TextTemplateEto : IMultiTenant +public class TextTemplateEto { - public Guid? TenantId { get; set; } public string Name { get; set; } public string DisplayName { get; set; } public string Content { get; set; } diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/IStaticTemplateDefinitionSaver.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/IStaticTemplateDefinitionSaver.cs deleted file mode 100644 index 7ec0daae6..000000000 --- a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/IStaticTemplateDefinitionSaver.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System.Threading.Tasks; - -namespace LINGYUN.Abp.TextTemplating; -public interface IStaticTemplateDefinitionSaver -{ - Task SaveAsync(); -} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/IStaticTemplateSaver.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/IStaticTemplateSaver.cs new file mode 100644 index 000000000..9c1caf94a --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/IStaticTemplateSaver.cs @@ -0,0 +1,9 @@ +using System.Threading.Tasks; + +namespace LINGYUN.Abp.TextTemplating; +public interface IStaticTemplateSaver +{ + Task SaveDefinitionTemplateAsync(); + + Task SaveTemplateContentAsync(); +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/InMemoryTemplateDefinitionStoreCache.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/InMemoryTemplateDefinitionStoreCache.cs index c8ece18b5..d2d4ca43f 100644 --- a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/InMemoryTemplateDefinitionStoreCache.cs +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/InMemoryTemplateDefinitionStoreCache.cs @@ -37,7 +37,7 @@ public virtual Task FillAsync( { var templateDefinition = new TemplateDefinition( templateDefinitionRecord.Name, - typeof(NonTypedLocalizationResource), + templateDefinitionRecord.LocalizationResourceName, LocalizableStringSerializer.Deserialize(templateDefinitionRecord.DisplayName), templateDefinitionRecord.IsLayout, templateDefinitionRecord.Layout, diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/StaticTemplateDefinitionSaver.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/StaticTemplateSaver.cs similarity index 68% rename from aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/StaticTemplateDefinitionSaver.cs rename to aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/StaticTemplateSaver.cs index a457fded7..85384a127 100644 --- a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/StaticTemplateDefinitionSaver.cs +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/StaticTemplateSaver.cs @@ -1,96 +1,129 @@ -using Microsoft.Extensions.Options; -using System.Collections.Generic; -using System.Threading.Tasks; -using Volo.Abp.Caching; -using Volo.Abp.Data; -using Volo.Abp.DependencyInjection; -using Volo.Abp.DistributedLocking; -using Volo.Abp.Guids; -using Volo.Abp.Localization; -using Volo.Abp.TextTemplating; -using Volo.Abp.Uow; - -namespace LINGYUN.Abp.TextTemplating; - -public class StaticTemplateDefinitionSaver : IStaticTemplateDefinitionSaver, ITransientDependency -{ - protected AbpDistributedCacheOptions CacheOptions { get; } - protected IGuidGenerator GuidGenerator { get; } - protected IAbpDistributedLock DistributedLock { get; } - protected ITextTemplateDefinitionRepository TemplateDefinitionRepository { get; } - protected AbpTextTemplatingCachingOptions TemplatingCachingOptions { get; } - protected IStaticTemplateDefinitionStore StaticTemplateDefinitionStore { get; } - protected ILocalizableStringSerializer LocalizableStringSerializer { get; } - - public StaticTemplateDefinitionSaver( - IOptions cacheOptions, - IOptions templatingCachingOptions, - IGuidGenerator guidGenerator, - IAbpDistributedLock distributedLock, - ITextTemplateDefinitionRepository templateDefinitionRepository, - IStaticTemplateDefinitionStore staticTemplateDefinitionStore, - ILocalizableStringSerializer localizableStringSerializer) - { - CacheOptions = cacheOptions.Value; - GuidGenerator = guidGenerator; - DistributedLock = distributedLock; - TemplateDefinitionRepository = templateDefinitionRepository; - TemplatingCachingOptions = templatingCachingOptions.Value; - StaticTemplateDefinitionStore = staticTemplateDefinitionStore; - LocalizableStringSerializer = localizableStringSerializer; - } - - [UnitOfWork] - public async virtual Task SaveAsync() - { - if (TemplatingCachingOptions.SaveStaticTemplateDefinitionToDatabase) - { - await using var commonLockHandle = await DistributedLock - .TryAcquireAsync(GetCommonDistributedLockKey(), TemplatingCachingOptions.TemplateDefinitionsCacheStampTimeOut); - - if (commonLockHandle == null) - { - return; - } - - var templateDefinitions = await StaticTemplateDefinitionStore.GetAllAsync(); - - var saveNewTemplateDefinitionRecords = new List(); - - foreach (var templateDefinition in templateDefinitions) - { - if (await TemplateDefinitionRepository.FindByNameAsync(templateDefinition.Name) != null) - { - continue; - } - - var templateDefinitionRecord = new TextTemplateDefinition( - GuidGenerator.Create(), - templateDefinition.Name, - LocalizableStringSerializer.Serialize(templateDefinition.DisplayName), - templateDefinition.IsLayout, - templateDefinition.Layout, - templateDefinition.IsInlineLocalized, - templateDefinition.DefaultCultureName, - templateDefinition.RenderEngine) - { - IsStatic = true - }; - - foreach (var property in templateDefinition.Properties) - { - templateDefinitionRecord.SetProperty(property.Key, property.Value); - } - - saveNewTemplateDefinitionRecords.Add(templateDefinitionRecord); - } - - await TemplateDefinitionRepository.InsertManyAsync(saveNewTemplateDefinitionRecords); - } - } - - protected virtual string GetCommonDistributedLockKey() - { - return $"{CacheOptions.KeyPrefix}_Common_AbpTemplateDefinitionStaticSaverLock"; - } -} +using Microsoft.Extensions.Options; +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp.Caching; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; +using Volo.Abp.DistributedLocking; +using Volo.Abp.Guids; +using Volo.Abp.Localization; +using Volo.Abp.TextTemplating; +using Volo.Abp.Uow; + +namespace LINGYUN.Abp.TextTemplating; + +public class StaticTemplateSaver : IStaticTemplateSaver, ITransientDependency +{ + protected AbpDistributedCacheOptions CacheOptions { get; } + protected IGuidGenerator GuidGenerator { get; } + protected IAbpDistributedLock DistributedLock { get; } + protected ITextTemplateRepository TextTemplateRepository { get; } + protected ITextTemplateDefinitionRepository TemplateDefinitionRepository { get; } + protected AbpTextTemplatingCachingOptions TemplatingCachingOptions { get; } + protected IStaticTemplateDefinitionStore StaticTemplateDefinitionStore { get; } + protected ILocalizableStringSerializer LocalizableStringSerializer { get; } + protected ITemplateContentProvider TemplateContentProvider { get; } + + public StaticTemplateSaver( + IOptions cacheOptions, + IOptions templatingCachingOptions, + IGuidGenerator guidGenerator, + IAbpDistributedLock distributedLock, + ITextTemplateRepository textTemplateRepository, + ITextTemplateDefinitionRepository templateDefinitionRepository, + IStaticTemplateDefinitionStore staticTemplateDefinitionStore, + ILocalizableStringSerializer localizableStringSerializer, + ITemplateContentProvider templateContentProvider) + { + CacheOptions = cacheOptions.Value; + GuidGenerator = guidGenerator; + DistributedLock = distributedLock; + TextTemplateRepository = textTemplateRepository; + TemplateDefinitionRepository = templateDefinitionRepository; + TemplatingCachingOptions = templatingCachingOptions.Value; + StaticTemplateDefinitionStore = staticTemplateDefinitionStore; + LocalizableStringSerializer = localizableStringSerializer; + TemplateContentProvider = templateContentProvider; + } + + [UnitOfWork] + public async virtual Task SaveDefinitionTemplateAsync() + { + if (TemplatingCachingOptions.SaveStaticTemplateDefinitionToDatabase) + { + await using var commonLockHandle = await DistributedLock + .TryAcquireAsync(GetCommonDistributedLockKey(), TemplatingCachingOptions.TemplateDefinitionsCacheStampTimeOut); + + if (commonLockHandle == null) + { + return; + } + + var templateDefinitions = await StaticTemplateDefinitionStore.GetAllAsync(); + + var saveNewTemplateDefinitionRecords = new List(); + + foreach (var templateDefinition in templateDefinitions) + { + if (await TemplateDefinitionRepository.FindByNameAsync(templateDefinition.Name) != null) + { + continue; + } + + var templateDefinitionRecord = new TextTemplateDefinition( + GuidGenerator.Create(), + templateDefinition.Name, + LocalizableStringSerializer.Serialize(templateDefinition.DisplayName), + templateDefinition.IsLayout, + templateDefinition.Layout, + templateDefinition.IsInlineLocalized, + templateDefinition.DefaultCultureName, + templateDefinition.LocalizationResourceName, + templateDefinition.RenderEngine) + { + IsStatic = true + }; + + foreach (var property in templateDefinition.Properties) + { + templateDefinitionRecord.SetProperty(property.Key, property.Value); + } + + saveNewTemplateDefinitionRecords.Add(templateDefinitionRecord); + } + + await TemplateDefinitionRepository.InsertManyAsync(saveNewTemplateDefinitionRecords); + } + } + + [UnitOfWork] + public async virtual Task SaveTemplateContentAsync() + { + var saveNewTemplates = new List(); + var templateDefinitions = await StaticTemplateDefinitionStore.GetAllAsync(); + foreach (var templateDefinition in templateDefinitions) + { + var culture = templateDefinition.IsInlineLocalized ? null : templateDefinition.DefaultCultureName; + if (await TextTemplateRepository.FindByNameAsync(templateDefinition.Name, culture) != null) + { + continue; + } + + var content = await TemplateContentProvider.GetContentOrNullAsync(templateDefinition, culture); + var textTemplate = new TextTemplate( + GuidGenerator.Create(), + templateDefinition.Name, + LocalizableStringSerializer.Serialize(templateDefinition.DisplayName), + content, + culture); + saveNewTemplates.Add(textTemplate); + } + + await TextTemplateRepository.InsertManyAsync(saveNewTemplates); + } + + protected virtual string GetCommonDistributedLockKey() + { + return $"{CacheOptions.KeyPrefix}_Common_AbpTemplateDefinitionStaticSaverLock"; + } +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplate.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplate.cs index 0d28bca80..4b09ea03f 100644 --- a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplate.cs +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplate.cs @@ -1,13 +1,11 @@ using System; using Volo.Abp; using Volo.Abp.Domain.Entities.Auditing; -using Volo.Abp.MultiTenancy; namespace LINGYUN.Abp.TextTemplating; -public class TextTemplate : AuditedEntity, IMultiTenant +public class TextTemplate : AuditedEntity { - public virtual Guid? TenantId { get; protected set; } public virtual string Name { get; private set; } public virtual string DisplayName { get; private set; } public virtual string Content { get; private set; } diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplateCacheItemInvalidator.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplateCacheItemInvalidator.cs index 7e96e7dc1..2f1fc65aa 100644 --- a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplateCacheItemInvalidator.cs +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplateCacheItemInvalidator.cs @@ -39,10 +39,7 @@ protected async virtual Task RemoveCacheItemAsync(TextTemplate template) template.Culture ); - using (CurrentTenant.Change(template.TenantId)) - { - await Cache.RemoveAsync(cacheKey); - } + await Cache.RemoveAsync(cacheKey); } protected virtual string CalculateCacheKey(string name, string culture = null) diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplateContentCacheItem.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplateContentCacheItem.cs index 3e1ae6a0b..9e2034a66 100644 --- a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplateContentCacheItem.cs +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplateContentCacheItem.cs @@ -1,8 +1,10 @@ using System; +using Volo.Abp.MultiTenancy; namespace LINGYUN.Abp.TextTemplating; [Serializable] +[IgnoreMultiTenancy] public class TextTemplateContentCacheItem { private const string CacheKeyFormat = "pn:template-content,n:{0},c:{1}"; diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplateContentContributor.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplateContentContributor.cs index cef7df099..6c6b15a72 100644 --- a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplateContentContributor.cs +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplateContentContributor.cs @@ -23,7 +23,10 @@ public TextTemplateContentContributor( public async virtual Task GetOrNullAsync(TemplateContentContributorContext context) { - var cacheKey = TextTemplateContentCacheItem.CalculateCacheKey(context.TemplateDefinition.Name, context.Culture); + // 2024/05/27 fixed 内联本地化不需要多语言 + var culture = context.TemplateDefinition.IsInlineLocalized ? null : context.Culture; + + var cacheKey = TextTemplateContentCacheItem.CalculateCacheKey(context.TemplateDefinition.Name, culture); var cacheItem = await TextTemplateContentCache.GetOrAddAsync(cacheKey, () => CreateTemplateContentCache(context), @@ -34,8 +37,10 @@ public async virtual Task GetOrNullAsync(TemplateContentContributorConte protected async virtual Task CreateTemplateContentCache(TemplateContentContributorContext context) { + // 2024/05/27 fixed 内联本地化不需要多语言 + var culture = context.TemplateDefinition.IsInlineLocalized ? null : context.Culture; var repository = context.ServiceProvider.GetRequiredService(); - var template = await repository.FindByNameAsync(context.TemplateDefinition.Name, context.Culture); + var template = await repository.FindByNameAsync(context.TemplateDefinition.Name, culture); return new TextTemplateContentCacheItem( template?.Name, diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplateDefinitionInitializer.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplateDefinitionInitializer.cs index e4e853623..a108e7ec9 100644 --- a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplateDefinitionInitializer.cs +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplateDefinitionInitializer.cs @@ -69,9 +69,11 @@ await Policy try { // ReSharper disable once AccessToDisposedClosure - var saver = serviceScope.ServiceProvider.GetRequiredService(); + var saver = serviceScope.ServiceProvider.GetRequiredService(); - await saver.SaveAsync(); + await saver.SaveDefinitionTemplateAsync(); + + await saver.SaveTemplateContentAsync(); } catch (Exception ex) { diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN/Abp/TextTemplating/AbpTextTemplatingDbContextModelCreatingExtensions.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN/Abp/TextTemplating/AbpTextTemplatingDbContextModelCreatingExtensions.cs index bc4c949a6..52f4b5062 100644 --- a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN/Abp/TextTemplating/AbpTextTemplatingDbContextModelCreatingExtensions.cs +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN/Abp/TextTemplating/AbpTextTemplatingDbContextModelCreatingExtensions.cs @@ -33,7 +33,7 @@ public static void ConfigureTextTemplating( .HasColumnName(nameof(TextTemplate.Content)) .HasMaxLength(TextTemplateConsts.MaxContentLength); - b.HasIndex(p => new { p.TenantId, p.Name }) + b.HasIndex(p => p.Name) .HasDatabaseName("IX_Tenant_Text_Template_Name"); b.ApplyObjectExtensionMappings(); diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/FodyWeavers.xml b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/FodyWeavers.xml new file mode 100644 index 000000000..5d6962159 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/FodyWeavers.xsd b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/FodyWeavers.xsd new file mode 100644 index 000000000..3f3946e28 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/LINGYUN.Abp.TextTemplating.Scriban.csproj b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/LINGYUN.Abp.TextTemplating.Scriban.csproj new file mode 100644 index 000000000..903171620 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/LINGYUN.Abp.TextTemplating.Scriban.csproj @@ -0,0 +1,18 @@ + + + + + + + netstandard2.0 + enable + Nullable + + + + + + + + + diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/LINGYUN/Abp/TextTemplating/Scriban/AbpTextTemplatingScribanModule.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/LINGYUN/Abp/TextTemplating/Scriban/AbpTextTemplatingScribanModule.cs new file mode 100644 index 000000000..fb90dee0a --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/LINGYUN/Abp/TextTemplating/Scriban/AbpTextTemplatingScribanModule.cs @@ -0,0 +1,17 @@ +using Volo.Abp.Modularity; +using Volo.Abp.TextTemplating; + +namespace LINGYUN.Abp.TextTemplating.Scriban; + +[DependsOn(typeof(AbpTextTemplatingCoreModule))] +public class AbpTextTemplatingScribanModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.DefaultRenderingEngine = ScribanTemplateRenderingEngine.EngineName; + options.RenderingEngines[ScribanTemplateRenderingEngine.EngineName] = typeof(ScribanTemplateRenderingEngine); + }); + } +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/LINGYUN/Abp/TextTemplating/Scriban/ScribanTemplateDefinitionExtensions.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/LINGYUN/Abp/TextTemplating/Scriban/ScribanTemplateDefinitionExtensions.cs new file mode 100644 index 000000000..ff29b4ae0 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/LINGYUN/Abp/TextTemplating/Scriban/ScribanTemplateDefinitionExtensions.cs @@ -0,0 +1,12 @@ +using JetBrains.Annotations; +using Volo.Abp.TextTemplating; + +namespace LINGYUN.Abp.TextTemplating.Scriban; + +public static class ScribanTemplateDefinitionExtensions +{ + public static TemplateDefinition WithScribanEngine([NotNull] this TemplateDefinition templateDefinition) + { + return templateDefinition.WithRenderEngine(ScribanTemplateRenderingEngine.EngineName); + } +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/LINGYUN/Abp/TextTemplating/Scriban/ScribanTemplateLocalizer.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/LINGYUN/Abp/TextTemplating/Scriban/ScribanTemplateLocalizer.cs new file mode 100644 index 000000000..473f15e0a --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/LINGYUN/Abp/TextTemplating/Scriban/ScribanTemplateLocalizer.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.Extensions.Localization; +using Scriban; +using Scriban.Runtime; +using Scriban.Syntax; + +namespace LINGYUN.Abp.TextTemplating.Scriban; + +public class ScribanTemplateLocalizer : IScriptCustomFunction +{ + private readonly IStringLocalizer _localizer; + + public ScribanTemplateLocalizer(IStringLocalizer localizer) + { + _localizer = localizer; + } + + public object Invoke(TemplateContext context, ScriptNode callerContext, ScriptArray arguments, + ScriptBlockStatement blockStatement) + { + return GetString(arguments); + } + + public ValueTask InvokeAsync(TemplateContext context, ScriptNode callerContext, ScriptArray arguments, + ScriptBlockStatement blockStatement) + { + return new ValueTask(GetString(arguments)); + } + + private string GetString(ScriptArray arguments) + { + if (arguments.IsNullOrEmpty()) + { + return string.Empty; + } + + var name = arguments[0]; + if (name == null || name.ToString().IsNullOrWhiteSpace()) + { + return string.Empty; + } + + var args = arguments.Skip(1).Where(x => x != null && !x.ToString().IsNullOrWhiteSpace()).ToArray(); + return args.Any() ? _localizer[name.ToString()!, args] : _localizer[name.ToString()!]; + } + + public int RequiredParameterCount => 1; + + public int ParameterCount => ScriptFunctionCall.MaximumParameterCount - 1; + + public ScriptVarParamKind VarParamKind => ScriptVarParamKind.Direct; + + public Type ReturnType => typeof(object); + + public ScriptParameterInfo GetParameterInfo(int index) + { + return index == 0 + ? new ScriptParameterInfo(typeof(string), "template_name") + : new ScriptParameterInfo(typeof(object), "value"); + } +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/LINGYUN/Abp/TextTemplating/Scriban/ScribanTemplateRenderingEngine.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/LINGYUN/Abp/TextTemplating/Scriban/ScribanTemplateRenderingEngine.cs new file mode 100644 index 000000000..6eb9a5c36 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/LINGYUN/Abp/TextTemplating/Scriban/ScribanTemplateRenderingEngine.cs @@ -0,0 +1,154 @@ +using JetBrains.Annotations; +using Microsoft.Extensions.Localization; +using Scriban; +using Scriban.Runtime; +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Localization; +using Volo.Abp.TextTemplating; + +namespace LINGYUN.Abp.TextTemplating.Scriban; +public class ScribanTemplateRenderingEngine : TemplateRenderingEngineBase, ITransientDependency +{ + public const string EngineName = "Scriban"; + public override string Name => EngineName; + + public ScribanTemplateRenderingEngine( + ITemplateDefinitionManager templateDefinitionManager, + ITemplateContentProvider templateContentProvider, + IStringLocalizerFactory stringLocalizerFactory) + : base(templateDefinitionManager, templateContentProvider, stringLocalizerFactory) + { + } + + public override async Task RenderAsync( + [NotNull] string templateName, + object? model = null, + string? cultureName = null, + Dictionary? globalContext = null) + { + Check.NotNullOrWhiteSpace(templateName, nameof(templateName)); + + if (globalContext == null) + { + globalContext = new Dictionary(); + } + + if (cultureName == null) + { + return await RenderInternalAsync( + templateName, + globalContext, + model + ); + } + else + { + using (CultureHelper.Use(cultureName)) + { + return await RenderInternalAsync( + templateName, + globalContext, + model + ); + } + } + } + + protected virtual async Task RenderInternalAsync( + string templateName, + Dictionary globalContext, + object? model = null) + { + var templateDefinition = await TemplateDefinitionManager.GetAsync(templateName); + + var renderedContent = await RenderSingleTemplateAsync( + templateDefinition, + globalContext, + model + ); + + if (templateDefinition.Layout != null) + { + globalContext["content"] = renderedContent; + renderedContent = await RenderInternalAsync( + templateDefinition.Layout, + globalContext + ); + } + + return renderedContent; + } + + protected virtual async Task RenderSingleTemplateAsync( + TemplateDefinition templateDefinition, + Dictionary globalContext, + object? model = null) + { + var rawTemplateContent = await GetContentOrNullAsync(templateDefinition); + + return await RenderTemplateContentWithScribanAsync( + templateDefinition, + rawTemplateContent!, + globalContext, + model + ); + } + + protected virtual async Task RenderTemplateContentWithScribanAsync( + TemplateDefinition templateDefinition, + string templateContent, + Dictionary globalContext, + object? model = null) + { + var context = await CreateScribanTemplateContextAsync( + templateDefinition, + globalContext, + model + ); + + return await Template + .Parse(templateContent) + .RenderAsync(context); + } + + protected async virtual Task CreateScribanTemplateContextAsync( + TemplateDefinition templateDefinition, + Dictionary globalContext, + object? model = null) + { + var context = new TemplateContext(); + + var scriptObject = new ScriptObject(); + + scriptObject.Import(globalContext); + + if (model != null) + { + scriptObject["model"] = model; + } + + var localizer = await GetLocalizerOrNullAsync(templateDefinition); + if (localizer != null) + { + scriptObject.SetValue("L", new ScribanTemplateLocalizer(localizer), true); + } + + context.PushGlobal(scriptObject); + context.PushCulture(System.Globalization.CultureInfo.CurrentCulture); + + return context; + } + + protected async virtual Task GetLocalizerOrNullAsync(TemplateDefinition templateDefinition) + { + if (templateDefinition.LocalizationResourceName != null) + { + return await StringLocalizerFactory.CreateByResourceNameOrNullAsync(templateDefinition.LocalizationResourceName); + } + + return StringLocalizerFactory.CreateDefaultOrNull(); + } +} diff --git a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.Configure.cs index d8ba743c0..f07e8e6cd 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.Configure.cs @@ -24,6 +24,7 @@ using System.Text.Encodings.Web; using System.Text.Unicode; using Volo.Abp; +using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.Auditing; using Volo.Abp.Authorization.Permissions; using Volo.Abp.Caching; @@ -158,7 +159,7 @@ private void ConfigurePermissionManagement() }); } - private void ConfigreExceptionHandling() + private void ConfigureExceptionHandling() { // 自定义需要处理的异常 Configure(options => @@ -243,6 +244,14 @@ private void ConfigureCaching(IConfiguration configuration) }); } + private void ConfigureMvc() + { + Configure(options => + { + options.ExposeIntegrationServices = true; + }); + } + private void ConfigureVirtualFileSystem() { Configure(options => diff --git a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.cs index 6e02cda48..95ed3ea11 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.cs @@ -80,10 +80,11 @@ public override void ConfigureServices(ServiceConfigurationContext context) var hostingEnvironment = context.Services.GetHostingEnvironment(); var configuration = context.Services.GetConfiguration(); + ConfigureMvc(); ConfigureIdentity(); ConfigureDbContext(); ConfigureLocalization(); - ConfigreExceptionHandling(); + ConfigureExceptionHandling(); ConfigureVirtualFileSystem(); ConfigureFeatureManagement(); ConfigurePermissionManagement(); diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.Configure.cs index 6e3331877..57b62e92d 100644 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.Configure.cs @@ -24,6 +24,7 @@ using System.Text.Encodings.Web; using System.Text.Unicode; using Volo.Abp; +using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.Auditing; using Volo.Abp.Authorization.Permissions; using Volo.Abp.Caching; @@ -237,6 +238,14 @@ private void ConfigureDistributedLocking(IServiceCollection services, IConfigura } } + private void ConfigureMvc() + { + Configure(options => + { + options.ExposeIntegrationServices = true; + }); + } + private void ConfigureVirtualFileSystem() { Configure(options => diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.cs index f72f6bed9..c99daa995 100644 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.cs @@ -1,4 +1,5 @@ -using LINGYUN.Abp.AspNetCore.HttpOverrides; +using LINGYUN.Abp.Aliyun.SettingManagement; +using LINGYUN.Abp.AspNetCore.HttpOverrides; using LINGYUN.Abp.AspNetCore.Mvc.Localization; using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; using LINGYUN.Abp.Auditing; @@ -16,6 +17,7 @@ using LINGYUN.Abp.Localization.CultureMap; using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; using LINGYUN.Abp.Logging.Serilog.Elasticsearch; +using LINGYUN.Abp.OssManagement.SettingManagement; using LINGYUN.Abp.PermissionManagement; using LINGYUN.Abp.PermissionManagement.HttpApi; using LINGYUN.Abp.PermissionManagement.OrganizationUnits; @@ -25,8 +27,12 @@ using LINGYUN.Abp.Serilog.Enrichers.UniqueId; using LINGYUN.Abp.SettingManagement; using LINGYUN.Abp.Sms.Aliyun; +using LINGYUN.Abp.Tencent.SettingManagement; using LINGYUN.Abp.TextTemplating; using LINGYUN.Abp.TextTemplating.EntityFrameworkCore; +using LINGYUN.Abp.TextTemplating.Scriban; +using LINGYUN.Abp.WeChat.SettingManagement; +using LINGYUN.Abp.WxPusher.SettingManagement; using LY.MicroService.BackendAdmin.EntityFrameworkCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -58,6 +64,14 @@ namespace LY.MicroService.BackendAdmin; typeof(AbpAuditLoggingElasticsearchModule), typeof(AbpAspNetCoreMvcUiMultiTenancyModule), typeof(AbpAspNetCoreMvcLocalizationModule), + + // 设置管理 + typeof(AbpAliyunSettingManagementModule), + typeof(AbpTencentCloudSettingManagementModule), + typeof(AbpWeChatSettingManagementModule), + typeof(AbpWxPusherSettingManagementModule), + typeof(AbpOssManagementSettingManagementModule), + typeof(AbpSettingManagementApplicationModule), typeof(AbpSettingManagementHttpApiModule), typeof(AbpPermissionManagementApplicationModule), @@ -88,6 +102,10 @@ namespace LY.MicroService.BackendAdmin; typeof(AbpFeatureManagementEntityFrameworkCoreModule), typeof(AbpLocalizationManagementEntityFrameworkCoreModule), typeof(AbpTextTemplatingEntityFrameworkCoreModule), + + // 重写模板引擎支持外部本地化 + typeof(AbpTextTemplatingScribanModule), + typeof(BackendAdminMigrationsEntityFrameworkCoreModule), typeof(AbpDataDbMigratorModule), typeof(AbpAspNetCoreAuthenticationJwtBearerModule), @@ -116,6 +134,7 @@ public override void ConfigureServices(ServiceConfigurationContext context) var hostingEnvironment = context.Services.GetHostingEnvironment(); var configuration = context.Services.GetConfiguration(); + ConfigureMvc(); ConfigureDbContext(); ConfigureLocalization(); ConfigureExceptionHandling(); diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/LY.MicroService.BackendAdmin.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/LY.MicroService.BackendAdmin.HttpApi.Host.csproj index 9dd530225..6cccd3b67 100644 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/LY.MicroService.BackendAdmin.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/LY.MicroService.BackendAdmin.HttpApi.Host.csproj @@ -51,6 +51,8 @@ + + @@ -65,6 +67,8 @@ + + @@ -80,6 +84,7 @@ + @@ -92,5 +97,6 @@ + diff --git a/aspnet-core/services/LY.MicroService.IdentityServer.HttpApi.Host/IdentityServerHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.IdentityServer.HttpApi.Host/IdentityServerHttpApiHostModule.Configure.cs index a7ce53367..99c1e0303 100644 --- a/aspnet-core/services/LY.MicroService.IdentityServer.HttpApi.Host/IdentityServerHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.IdentityServer.HttpApi.Host/IdentityServerHttpApiHostModule.Configure.cs @@ -44,6 +44,7 @@ using System.Collections.Generic; using IdentityModel; using System.Security.Claims; +using Volo.Abp.AspNetCore.Mvc; namespace LY.MicroService.IdentityServer; @@ -160,7 +161,7 @@ private void ConfigurePermissionManagement() }); } - private void ConfigreExceptionHandling() + private void ConfigureExceptionHandling() { // 自定义需要处理的异常 Configure(options => @@ -244,6 +245,14 @@ private void ConfigureCaching(IConfiguration configuration) }); } + private void ConfigureMvc() + { + Configure(options => + { + options.ExposeIntegrationServices = true; + }); + } + private void ConfigureVirtualFileSystem() { Configure(options => diff --git a/aspnet-core/services/LY.MicroService.IdentityServer.HttpApi.Host/IdentityServerHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.IdentityServer.HttpApi.Host/IdentityServerHttpApiHostModule.cs index 4eb83ce99..279e85052 100644 --- a/aspnet-core/services/LY.MicroService.IdentityServer.HttpApi.Host/IdentityServerHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.IdentityServer.HttpApi.Host/IdentityServerHttpApiHostModule.cs @@ -86,10 +86,11 @@ public override void ConfigureServices(ServiceConfigurationContext context) var hostingEnvironment = context.Services.GetHostingEnvironment(); var configuration = context.Services.GetConfiguration(); + ConfigureMvc(); ConfigureIdentity(); ConfigureDbContext(); ConfigureLocalization(); - ConfigreExceptionHandling(); + ConfigureExceptionHandling(); ConfigureVirtualFileSystem(); ConfigureFeatureManagement(); ConfigurePermissionManagement(); diff --git a/aspnet-core/services/LY.MicroService.IdentityServer/IdentityServerModule.Configure.cs b/aspnet-core/services/LY.MicroService.IdentityServer/IdentityServerModule.Configure.cs index d95c1163a..e36746784 100644 --- a/aspnet-core/services/LY.MicroService.IdentityServer/IdentityServerModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.IdentityServer/IdentityServerModule.Configure.cs @@ -2,6 +2,7 @@ using IdentityModel; using LINGYUN.Abp.Account; using LINGYUN.Abp.AspNetCore.HttpOverrides.Forwarded; +using LINGYUN.Abp.Authorization.OrganizationUnits; using LINGYUN.Abp.IdentityServer.IdentityResources; using LINGYUN.Abp.Localization.CultureMap; using LINGYUN.Abp.Serilog.Enrichers.Application; @@ -209,6 +210,14 @@ private void ConfigureIdentity(IConfiguration configuration) } }); + Configure(options => + { + options.RequestedClaims.AddRange(new[] + { + AbpOrganizationUnitClaimTypes.OrganizationUnit + }); + }); + Configure(options => { options.IsDynamicClaimsEnabled = true; diff --git a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.Configure.cs index 3ed64e8ff..fed8e5a10 100644 --- a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.Configure.cs @@ -23,6 +23,7 @@ using System.Text.Encodings.Web; using System.Text.Unicode; using Volo.Abp; +using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.Auditing; using Volo.Abp.Caching; using Volo.Abp.EntityFrameworkCore; @@ -133,7 +134,7 @@ private void ConfigureJsonSerializer(IConfiguration configuration) }); } - private void ConfigreExceptionHandling() + private void ConfigureExceptionHandling() { // 自定义需要处理的异常 Configure(options => @@ -195,6 +196,14 @@ private void ConfigureCaching(IConfiguration configuration) }); } + private void ConfigureMvc() + { + Configure(options => + { + options.ExposeIntegrationServices = true; + }); + } + private void ConfigureVirtualFileSystem() { Configure(options => diff --git a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.cs index 25e0ef848..2611a319b 100644 --- a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.cs @@ -74,9 +74,10 @@ public override void ConfigureServices(ServiceConfigurationContext context) var hostingEnvironment = context.Services.GetHostingEnvironment(); var configuration = context.Services.GetConfiguration(); + ConfigureMvc(); ConfigureDbContext(); ConfigureLocalization(); - ConfigreExceptionHandling(); + ConfigureExceptionHandling(); ConfigureVirtualFileSystem(); ConfigureFeatureManagement(); ConfigureCaching(configuration); diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.Configure.cs index 1b3d7e0d0..3059d60d0 100644 --- a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.Configure.cs @@ -27,6 +27,7 @@ using System.Text.Unicode; using System.Threading.Tasks; using Volo.Abp; +using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.Auditing; using Volo.Abp.BlobStoring; using Volo.Abp.BlobStoring.FileSystem; @@ -162,7 +163,7 @@ private void ConfigureBlobStoring() }); } - private void ConfigreExceptionHandling() + private void ConfigureExceptionHandling() { // 自定义需要处理的异常 Configure(options => @@ -232,6 +233,14 @@ private void ConfigureCaching(IConfiguration configuration) }); } + private void ConfigureMvc() + { + Configure(options => + { + options.ExposeIntegrationServices = true; + }); + } + private void ConfigureVirtualFileSystem() { Configure(options => diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.cs index 47f9b1742..4eff9c8ff 100644 --- a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.cs @@ -19,7 +19,6 @@ using LINGYUN.Abp.Serilog.Enrichers.Application; using LINGYUN.Abp.Serilog.Enrichers.UniqueId; using LINGYUN.Abp.UI.Navigation.VueVbenAdmin; -using LINGYUN.Abp.WeChat.Work; using LINGYUN.Platform; using LINGYUN.Platform.EntityFrameworkCore; using LINGYUN.Platform.HttpApi; @@ -109,11 +108,12 @@ public override void ConfigureServices(ServiceConfigurationContext context) var hostingEnvironment = context.Services.GetHostingEnvironment(); var configuration = context.Services.GetConfiguration(); + ConfigureMvc(); ConfigureDbContext(); ConfigureBlobStoring(); ConfigureLocalization(); ConfigureKestrelServer(); - ConfigreExceptionHandling(); + ConfigureExceptionHandling(); ConfigureVirtualFileSystem(); ConfigureFeatureManagement(); ConfigureCaching(configuration); diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj index 6f5bc4e4d..524256f3e 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj @@ -88,6 +88,7 @@ + diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs index 836f72a70..e162e65de 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs @@ -43,6 +43,8 @@ using LINGYUN.Abp.AspNetCore.HttpOverrides.Forwarded; using Microsoft.AspNetCore.HttpOverrides; using Volo.Abp.Security.Claims; +using Volo.Abp.AspNetCore.Mvc; +using LINGYUN.Abp.TextTemplating; namespace LY.MicroService.RealtimeMessage; @@ -159,6 +161,14 @@ private void ConfigureDbContext() }); } + private void ConfigureTextTemplating() + { + Configure(options => + { + options.IsDynamicTemplateDefinitionStoreEnabled = true; + }); + } + private void ConfigureFeatureManagement() { Configure(options => @@ -185,7 +195,7 @@ private void ConfigureJsonSerializer(IConfiguration configuration) }); } - private void ConfigreExceptionHandling() + private void ConfigureExceptionHandling() { // 自定义需要处理的异常 Configure(options => @@ -264,6 +274,14 @@ private void PreConfigureSignalR(IConfiguration configuration) }); } + private void ConfigureMvc() + { + Configure(options => + { + options.ExposeIntegrationServices = true; + }); + } + private void ConfigureVirtualFileSystem() { Configure(options => @@ -278,6 +296,7 @@ private void ConfigureNotifications() { // 宿主项目启用动态通知 options.IsDynamicNotificationsStoreEnabled = true; + options.SaveStaticNotificationsToDatabase = false; }); } diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs index 31e290b55..750acb61f 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs @@ -34,6 +34,7 @@ using LINGYUN.Abp.Serilog.Enrichers.UniqueId; using LINGYUN.Abp.TaskManagement.EntityFrameworkCore; using LINGYUN.Abp.TextTemplating.EntityFrameworkCore; +using LINGYUN.Abp.TextTemplating.Scriban; using LY.MicroService.RealtimeMessage.EntityFrameworkCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -50,7 +51,6 @@ using Volo.Abp.Modularity; using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore; -using Volo.Abp.TextTemplating.Scriban; namespace LY.MicroService.RealtimeMessage; @@ -95,7 +95,10 @@ namespace LY.MicroService.RealtimeMessage; typeof(AbpNotificationsWeChatMiniProgramModule), typeof(AbpNotificationsWeChatWorkModule), typeof(AbpNotificationsExceptionHandlingModule), + + // 重写模板引擎支持外部本地化 typeof(AbpTextTemplatingScribanModule), + typeof(AbpCAPEventBusModule), typeof(AbpFeaturesValidationRedisModule), typeof(AbpCachingStackExchangeRedisModule), @@ -126,11 +129,13 @@ public override void ConfigureServices(ServiceConfigurationContext context) var hostingEnvironment = context.Services.GetHostingEnvironment(); var configuration = context.Services.GetConfiguration(); + ConfigureMvc(); ConfigureDbContext(); ConfigureLocalization(); ConfigureNotifications(); + ConfigureTextTemplating(); ConfigureBackgroundTasks(); - ConfigreExceptionHandling(); + ConfigureExceptionHandling(); ConfigureVirtualFileSystem(); ConfigureFeatureManagement(); ConfigureCaching(configuration); diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.Configure.cs index 35f6ebffc..b70ad8910 100644 --- a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.Configure.cs @@ -24,6 +24,7 @@ using System.Text.Encodings.Web; using System.Text.Unicode; using Volo.Abp; +using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.Auditing; using Volo.Abp.Caching; using Volo.Abp.EntityFrameworkCore; @@ -235,6 +236,14 @@ private void ConfigureCaching(IConfiguration configuration) }); } + private void ConfigureMvc() + { + Configure(options => + { + options.ExposeIntegrationServices = true; + }); + } + private void ConfigureVirtualFileSystem() { Configure(options => diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.cs index b75dff455..73b9cdcb8 100644 --- a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.cs @@ -100,6 +100,7 @@ public override void ConfigureServices(ServiceConfigurationContext context) var hostingEnvironment = context.Services.GetHostingEnvironment(); var configuration = context.Services.GetConfiguration(); + ConfigureMvc(); ConfigureDbContext(); ConfigureLocalization(); ConfigureBackgroundTasks(); diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.Configure.cs index e3401f14b..291ebb8b4 100644 --- a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.Configure.cs @@ -32,6 +32,7 @@ using System.Text.Encodings.Web; using System.Text.Unicode; using Volo.Abp; +using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.Auditing; using Volo.Abp.Caching; using Volo.Abp.EntityFrameworkCore; @@ -297,6 +298,14 @@ private void ConfigureCaching(IConfiguration configuration) }); } + private void ConfigureMvc() + { + Configure(options => + { + options.ExposeIntegrationServices = true; + }); + } + private void ConfigureVirtualFileSystem() { Configure(options => diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.cs index 23999feb4..2b56b0911 100644 --- a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.cs @@ -98,6 +98,7 @@ public override void ConfigureServices(ServiceConfigurationContext context) var hostingEnvironment = context.Services.GetHostingEnvironment(); var configuration = context.Services.GetConfiguration(); + ConfigureMvc(); ConfigureWrapper(); ConfigureDbContext(); ConfigureLocalization(); diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.Configure.cs index 153e7e86c..4646403c8 100644 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.Configure.cs @@ -325,6 +325,14 @@ private void ConfigureCaching(IConfiguration configuration) }); } + private void ConfigureMvc() + { + Configure(options => + { + options.ExposeIntegrationServices = true; + }); + } + private void ConfigureVirtualFileSystem() { Configure(options => diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.cs index d03fae438..de1b01c22 100644 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.cs @@ -102,6 +102,7 @@ public override void ConfigureServices(ServiceConfigurationContext context) var hostingEnvironment = context.Services.GetHostingEnvironment(); var configuration = context.Services.GetConfiguration(); + ConfigureMvc(); ConfigureDbContext(); ConfigureLocalization(); ConfigureBackgroundTasks(); diff --git a/common.props b/common.props index 7424842cf..497231dad 100644 --- a/common.props +++ b/common.props @@ -1,12 +1,12 @@ latest - 8.1.1 + 8.1.2 colin $(NoWarn);CS1591;CS0436;CS8618;NU1803 https://github.com/colinin/abp-next-admin $(SolutionDir)LocalNuget - 8.1.1 + 8.1.2 MIT git https://github.com/colinin/abp-next-admin diff --git a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/LINGYUN.MicroService.Internal.ApiGateway.sln b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/LINGYUN.MicroService.Internal.ApiGateway.sln index ac91f4f88..8ca5fe154 100644 --- a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/LINGYUN.MicroService.Internal.ApiGateway.sln +++ b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/LINGYUN.MicroService.Internal.ApiGateway.sln @@ -40,6 +40,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "common", "common", "{EE01F3 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.IdGenerator", "..\..\..\aspnet-core\framework\common\LINGYUN.Abp.IdGenerator\LINGYUN.Abp.IdGenerator.csproj", "{30A639F6-08C2-4250-A79E-9D766600F7F0}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.MicroService.Internal.Gateway", "src\LINGYUN.MicroService.Internal.Gateway\LINGYUN.MicroService.Internal.Gateway.csproj", "{09D71EFB-D64F-4F30-BEDB-4802B6166447}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.AspNetCore.Mvc.Wrapper", "..\..\..\aspnet-core\framework\mvc\LINGYUN.Abp.AspNetCore.Mvc.Wrapper\LINGYUN.Abp.AspNetCore.Mvc.Wrapper.csproj", "{442966AC-97E8-4E08-9E6F-E75F0FD2BB69}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Wrapper", "..\..\..\aspnet-core\framework\common\LINGYUN.Abp.Wrapper\LINGYUN.Abp.Wrapper.csproj", "{007A5DE4-4F4C-4018-A304-8BD794D91A69}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.AspNetCore.Wrapper", "..\..\..\aspnet-core\framework\common\LINGYUN.Abp.AspNetCore.Wrapper\LINGYUN.Abp.AspNetCore.Wrapper.csproj", "{3F3CA517-8A22-4B85-A2E8-3BB90B99A158}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -78,6 +86,22 @@ Global {30A639F6-08C2-4250-A79E-9D766600F7F0}.Debug|Any CPU.Build.0 = Debug|Any CPU {30A639F6-08C2-4250-A79E-9D766600F7F0}.Release|Any CPU.ActiveCfg = Release|Any CPU {30A639F6-08C2-4250-A79E-9D766600F7F0}.Release|Any CPU.Build.0 = Release|Any CPU + {09D71EFB-D64F-4F30-BEDB-4802B6166447}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {09D71EFB-D64F-4F30-BEDB-4802B6166447}.Debug|Any CPU.Build.0 = Debug|Any CPU + {09D71EFB-D64F-4F30-BEDB-4802B6166447}.Release|Any CPU.ActiveCfg = Release|Any CPU + {09D71EFB-D64F-4F30-BEDB-4802B6166447}.Release|Any CPU.Build.0 = Release|Any CPU + {442966AC-97E8-4E08-9E6F-E75F0FD2BB69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {442966AC-97E8-4E08-9E6F-E75F0FD2BB69}.Debug|Any CPU.Build.0 = Debug|Any CPU + {442966AC-97E8-4E08-9E6F-E75F0FD2BB69}.Release|Any CPU.ActiveCfg = Release|Any CPU + {442966AC-97E8-4E08-9E6F-E75F0FD2BB69}.Release|Any CPU.Build.0 = Release|Any CPU + {007A5DE4-4F4C-4018-A304-8BD794D91A69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {007A5DE4-4F4C-4018-A304-8BD794D91A69}.Debug|Any CPU.Build.0 = Debug|Any CPU + {007A5DE4-4F4C-4018-A304-8BD794D91A69}.Release|Any CPU.ActiveCfg = Release|Any CPU + {007A5DE4-4F4C-4018-A304-8BD794D91A69}.Release|Any CPU.Build.0 = Release|Any CPU + {3F3CA517-8A22-4B85-A2E8-3BB90B99A158}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3F3CA517-8A22-4B85-A2E8-3BB90B99A158}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3F3CA517-8A22-4B85-A2E8-3BB90B99A158}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3F3CA517-8A22-4B85-A2E8-3BB90B99A158}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -96,6 +120,10 @@ Global {13EDA39A-A859-447A-A6A6-056181B66EDC} = {3B460BD3-26EE-4BAC-A8B8-CFDF5F108A63} {EE01F3C2-14D1-4089-8C02-00C8083D9795} = {80E45092-1181-456D-B88C-7DDCB7F16368} {30A639F6-08C2-4250-A79E-9D766600F7F0} = {EE01F3C2-14D1-4089-8C02-00C8083D9795} + {09D71EFB-D64F-4F30-BEDB-4802B6166447} = {E8067AED-2B6E-4134-AAF8-9101457D709A} + {442966AC-97E8-4E08-9E6F-E75F0FD2BB69} = {EE01F3C2-14D1-4089-8C02-00C8083D9795} + {007A5DE4-4F4C-4018-A304-8BD794D91A69} = {EE01F3C2-14D1-4089-8C02-00C8083D9795} + {3F3CA517-8A22-4B85-A2E8-3BB90B99A158} = {EE01F3C2-14D1-4089-8C02-00C8083D9795} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {972464AB-1B23-4D87-89A2-13271E1873B9} diff --git a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/Controllers/HomeController.cs b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/Controllers/HomeController.cs new file mode 100644 index 000000000..ecee25c08 --- /dev/null +++ b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/Controllers/HomeController.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc; + +namespace LINGYUN.MicroService.Internal.Gateway.Controllers; + +public class HomeController : AbpControllerBase +{ + public IActionResult Index() + { + return Redirect("/swagger/index.html"); + } +} diff --git a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/InternalGatewayModule.cs b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/InternalGatewayModule.cs new file mode 100644 index 000000000..acc12d6a3 --- /dev/null +++ b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/InternalGatewayModule.cs @@ -0,0 +1,175 @@ +using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; +using LINGYUN.Abp.Serilog.Enrichers.Application; +using LINGYUN.Abp.Serilog.Enrichers.UniqueId; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Cors; +using Microsoft.AspNetCore.Rewrite; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Microsoft.IdentityModel.Logging; +using Microsoft.OpenApi.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using Volo.Abp; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc.ApiExploring; +using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; +using Volo.Abp.AspNetCore.Serilog; +using Volo.Abp.Autofac; +using Volo.Abp.Data; +using Volo.Abp.Modularity; +using Volo.Abp.Swashbuckle; +using Yarp.ReverseProxy.Configuration; + +namespace LINGYUN.MicroService.Internal.Gateway; + +[DependsOn( + typeof(AbpSerilogEnrichersApplicationModule), + typeof(AbpSerilogEnrichersUniqueIdModule), + typeof(AbpAutofacModule), + typeof(AbpDataModule), + typeof(AbpSwashbuckleModule), + typeof(AbpAspNetCoreSerilogModule), + typeof(AbpAspNetCoreMvcWrapperModule) +)] +public class InternalGatewayModule : AbpModule +{ + protected const string ApplicationName = "Services.ApiGateWay"; + public override void PreConfigureServices(ServiceConfigurationContext context) + { + AbpSerilogEnrichersConsts.ApplicationName = ApplicationName; + + PreConfigure(options => + { + // 以开放端口区别 + options.SnowflakeIdOptions.WorkerId = 0; + options.SnowflakeIdOptions.WorkerIdBits = 5; + options.SnowflakeIdOptions.DatacenterId = 1; + }); + } + + public override void ConfigureServices(ServiceConfigurationContext context) + { + var configuration = context.Services.GetConfiguration(); + var hostingEnvironment = context.Services.GetHostingEnvironment(); + + var showPii = configuration.GetValue("App:ShowPii"); + IdentityModelEventSource.ShowPII = showPii; + + Configure(options => + { + options.ControllersToRemove.Add(typeof(AbpApiDefinitionController)); + options.ControllersToRemove.Add(typeof(AbpApplicationLocalizationController)); + options.ControllersToRemove.Add(typeof(AbpApplicationConfigurationController)); + options.ControllersToRemove.Add(typeof(AbpApplicationConfigurationScriptController)); + }); + + context.Services.AddAbpSwaggerGenWithOAuth( + authority: configuration["AuthServer:Authority"], + scopes: new Dictionary + { + {"Account", "Account API"}, + {"Identity", "Identity API"}, + {"IdentityServer", "Identity Server API"}, + {"BackendAdmin", "Backend Admin API"}, + {"Localization", "Localization API"}, + {"Platform", "Platform API"}, + {"RealtimeMessage", "RealtimeMessage API"}, + {"TaskManagement", "Task Management API"}, + {"Webhooks", "Webhooks API"}, + }, + options => + { + options.SwaggerDoc("v1", new OpenApiInfo { Title = "ApiGateway", Version = "v1" }); + options.DocInclusionPredicate((docName, description) => true); + options.CustomSchemaIds(type => type.FullName); + }); + + context.Services.AddCors(options => + { + options.AddDefaultPolicy(builder => + { + builder + .WithOrigins( + configuration["App:CorsOrigins"] + .Split(",", StringSplitOptions.RemoveEmptyEntries) + .Select(o => o.Trim().RemovePostFix("/")) + .ToArray() + ) + .WithAbpExposedHeaders() + .WithAbpWrapExposedHeaders() + .SetIsOriginAllowedToAllowWildcardSubdomains() + .AllowAnyHeader() + .AllowAnyMethod() + .AllowCredentials(); + }); + }); + + context.Services.AddHttpForwarder(); + context.Services + .AddReverseProxy() + .LoadFromConfig(configuration.GetSection("ReverseProxy")); + } + + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + var env = context.GetEnvironment(); + + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + app.UseCorrelationId(); + app.UseAbpSerilogEnrichers(); + app.UseCors(); + + app.UseSwagger(); + app.UseSwaggerUI(options => + { + options.SwaggerEndpoint("/swagger/v1/swagger.json", "Open API Document"); + + var configuration = context.ServiceProvider.GetRequiredService(); + var logger = context.ServiceProvider.GetRequiredService>(); + var proxyConfigProvider = context.ServiceProvider.GetRequiredService(); + var yarpConfig = proxyConfigProvider.GetConfig(); + + var routedClusters = yarpConfig.Clusters + .SelectMany(t => t.Destinations, + (clusterId, destination) => new { clusterId.ClusterId, destination.Value }); + + var groupedClusters = routedClusters + .GroupBy(q => q.Value.Address) + .Select(t => t.First()) + .Distinct() + .ToList(); + + foreach (var clusterGroup in groupedClusters) + { + var routeConfig = yarpConfig.Routes.FirstOrDefault(q => + q.ClusterId == clusterGroup.ClusterId); + if (routeConfig == null) + { + logger.LogWarning($"Swagger UI: Couldn't find route configuration for {clusterGroup.ClusterId}..."); + continue; + } + + options.SwaggerEndpoint($"{clusterGroup.Value.Address}/swagger/v1/swagger.json", $"{routeConfig.RouteId} API"); + options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); + options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); + } + }); + + app.UseRewriter(new RewriteOptions().AddRedirect("^(|\\|\\s+)$", "/swagger")); + + app.UseRouting(); + app.UseConfiguredEndpoints(endpoints => + { + endpoints.MapReverseProxy(options => + options.UseLoadBalancing()); + }); + } +} diff --git a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/LINGYUN.MicroService.Internal.Gateway.csproj b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/LINGYUN.MicroService.Internal.Gateway.csproj new file mode 100644 index 000000000..c7aa2e4da --- /dev/null +++ b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/LINGYUN.MicroService.Internal.Gateway.csproj @@ -0,0 +1,39 @@ + + + + + + + Exe + net8.0 + LINGYUN.MicroService.Internal.Gateway + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/Program.cs b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/Program.cs new file mode 100644 index 000000000..63a4a90a4 --- /dev/null +++ b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/Program.cs @@ -0,0 +1,55 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Serilog; +using System; +using System.Threading.Tasks; + +namespace LINGYUN.MicroService.Internal.Gateway; + +public class Program +{ + public static async Task Main(string[] args) + { + try + { + Log.Information("Starting Internal ApiGateway."); + var builder = WebApplication.CreateBuilder(args); + builder.Host.AddAppSettingsSecretsJson() + .UseAutofac() + .ConfigureAppConfiguration((context, config) => + { + var configuration = config.Build(); + var agileConfigEnabled = configuration["AgileConfig:IsEnabled"]; + if (agileConfigEnabled.IsNullOrEmpty() || bool.Parse(agileConfigEnabled)) + { + config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); + } + + config.AddJsonFile("yarp.json", true, true).AddEnvironmentVariables(); + }) + .UseSerilog((context, provider, config) => + { + config.ReadFrom.Configuration(context.Configuration); + }); + + await builder.AddApplicationAsync(); + var app = builder.Build(); + await app.InitializeApplicationAsync(); + await app.RunAsync(); + + return 0; + } + catch (Exception ex) + { + Log.Fatal(ex, "Starting Internal ApiGateway terminated unexpectedly!"); + return 1; + } + finally + { + Log.CloseAndFlush(); + } + } +} diff --git a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/Properties/launchSettings.json b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/Properties/launchSettings.json new file mode 100644 index 000000000..dd9c65d82 --- /dev/null +++ b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/Properties/launchSettings.json @@ -0,0 +1,13 @@ +{ + "profiles": { + "LINGYUN.MicroService.Internal.Gateway": { + "commandName": "Project", + "launchBrowser": false, + "dotnetRunMessages": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:30000;https://localhost:30443" + } + } +} \ No newline at end of file diff --git a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/appsettings.Development.json b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/appsettings.Development.json new file mode 100644 index 000000000..dc525b25e --- /dev/null +++ b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/appsettings.Development.json @@ -0,0 +1,74 @@ +{ + "AgileConfig": { + "IsEnabled": false, + "env": "DEV", + "appId": "LY.MicroService.Internal.Gateway", + "secret": "1q2w3E*", + "nodes": "http://127.0.0.1:5000", + "name": "BackendAdmin", + "tag": "BackendAdmin" + }, + "App": { + "CorsOrigins": "http://127.0.0.1:3100", + "ShowPii": true + }, + "ConnectionStrings": { + "Default": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpIdentity": "Server=127.0.0.1;Database=IdentityServer-v70;User Id=root;Password=123456", + "AbpIdentityServer": "Server=127.0.0.1;Database=IdentityServer-v70;User Id=root;Password=123456", + "AbpSaas": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpSettingManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpFeatureManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpPermissionManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "AbpTextTemplating": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456" + }, + "AuthServer": { + "Authority": "http://127.0.0.1:44385/", + "ApiName": "lingyun-abp-application" + }, + "Logging": { + "Serilog": { + "Elasticsearch": { + "IndexFormat": "abp.dev.logging-{0:yyyy.MM.dd}" + } + } + }, + "AuditLogging": { + "Elasticsearch": { + "IndexPrefix": "abp.dev.auditing" + } + }, + "Elasticsearch": { + "NodeUris": "http://127.0.0.1:9200" + }, + "Serilog": { + "MinimumLevel": { + "Default": "Information", + "Override": { + "System": "Warning", + "Microsoft": "Warning", + "DotNetCore": "Warning", + "Yarp.ReverseProxy": "Information" + } + }, + "WriteTo": [ + { + "Name": "Console", + "Args": { + "restrictedToMinimumLevel": "Debug", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "Elasticsearch", + "Args": { + "nodeUris": "http://127.0.0.1:9200", + "indexFormat": "abp.dev.logging-{0:yyyy.MM.dd}", + "autoRegisterTemplate": true, + "autoRegisterTemplateVersion": "ESv7" + } + } + ] + } +} diff --git a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/appsettings.json b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/appsettings.json new file mode 100644 index 000000000..d1667133d --- /dev/null +++ b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/appsettings.json @@ -0,0 +1,73 @@ +{ + "StringEncryption": { + "DefaultPassPhrase": "s46c5q55nxpeS8Ra", + "InitVectorBytes": "s83ng0abvd02js84", + "DefaultSalt": "sf&5)s3#" + }, + "Serilog": { + "MinimumLevel": { + "Default": "Debug", + "Override": { + "System": "Information", + "Microsoft": "Information", + "DotNetCore": "Information", + "Yarp.ReverseProxy": "Debug" + } + }, + "Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName", "WithApplicationName", "WithUniqueId" ], + "WriteTo": [ + { + "Name": "Console", + "Args": { + "restrictedToMinimumLevel": "Debug", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Debug-.log", + "restrictedToMinimumLevel": "Debug", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Info-.log", + "restrictedToMinimumLevel": "Information", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Warn-.log", + "restrictedToMinimumLevel": "Warning", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Error-.log", + "restrictedToMinimumLevel": "Error", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "Logs/Fatal-.log", + "restrictedToMinimumLevel": "Fatal", + "rollingInterval": "Day", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + } + ] + } +} diff --git a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/yarp.json b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/yarp.json new file mode 100644 index 000000000..c41622f3e --- /dev/null +++ b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.Gateway/yarp.json @@ -0,0 +1,156 @@ +{ + "ReverseProxy": { + "Routes": { + "abp-route": { + "ClusterId": "abpCluster", + "Match": { + "Path": "/api/abp/{**everything}" + } + }, + "token-route": { + "ClusterId": "tokenCluster", + "Match": { + "Path": "/connect/{**everything}" + }, + "Transforms": [ + { + "RequestHeaderOriginalHost": "true" + } + ] + }, + "account-route": { + "ClusterId": "accountCluster", + "Match": { + "Path": "/api/account/{**everything}" + } + }, + "identity-route": { + "ClusterId": "identityCluster", + "Match": { + "Path": "/api/identity/{**everything}" + } + }, + "identity-server-route": { + "ClusterId": "identityServerCluster", + "Match": { + "Path": "/api/identity-server/{**everything}" + } + }, + "feature-management-route": { + "ClusterId": "feature-management-cluster", + "Match": { + "Path": "/api/feature-management/{**everything}" + } + }, + "permission-management-route": { + "ClusterId": "permission-management-cluster", + "Match": { + "Path": "/api/permission-management/{**everything}" + } + }, + "setting-management-route": { + "ClusterId": "setting-management-cluster", + "Match": { + "Path": "/api/setting-management/{**everything}" + } + }, + "localization-management-route": { + "ClusterId": "localization-management-cluster", + "Match": { + "Path": "/api/localization/{**everything}" + } + }, + "im-route": { + "ClusterId": "im-cluster", + "Match": { + "Path": "/api/im/{**everything}" + } + }, + "notifications-route": { + "ClusterId": "notifications-cluster", + "Match": { + "Path": "/api/notifications/{**everything}" + } + } + }, + "Clusters": { + "abpCluster": { + "Destinations": { + "destination1": { + "Address": "http://127.0.0.1:30010" + } + } + }, + "tokenCluster": { + "Destinations": { + "destination1": { + "Address": "http://127.0.0.1:44385" + } + } + }, + "accountCluster": { + "Destinations": { + "destination1": { + "Address": "http://127.0.0.1:30015" + } + } + }, + "identityCluster": { + "Destinations": { + "destination1": { + "Address": "http://127.0.0.1:30015" + } + } + }, + "identityServerCluster": { + "Destinations": { + "destination1": { + "Address": "http://127.0.0.1:30015" + } + } + }, + "feature-management-cluster": { + "Destinations": { + "destination1": { + "Address": "https://127.0.0.1:30010" + } + } + }, + "permission-management-cluster": { + "Destinations": { + "destination1": { + "Address": "https://127.0.0.1:30010" + } + } + }, + "setting-management-cluster": { + "Destinations": { + "destination1": { + "Address": "https://127.0.0.1:30010" + } + } + }, + "localization-management-cluster": { + "Destinations": { + "destination1": { + "Address": "http://127.0.0.1:30030" + } + } + }, + "im-cluster": { + "Destinations": { + "destination1": { + "Address": "http://127.0.0.1:30020" + } + } + }, + "nnotifications-cluster": { + "Destinations": { + "destination1": { + "Address": "http://127.0.0.1:30020" + } + } + } + } + } +} \ No newline at end of file diff --git a/gateways/web/LY.MicroService.ApiGateway/InternalApiGatewayModule.cs b/gateways/web/LY.MicroService.ApiGateway/InternalApiGatewayModule.cs index 094282f84..269552936 100644 --- a/gateways/web/LY.MicroService.ApiGateway/InternalApiGatewayModule.cs +++ b/gateways/web/LY.MicroService.ApiGateway/InternalApiGatewayModule.cs @@ -30,6 +30,20 @@ namespace LY.MicroService.ApiGateway; )] public class InternalApiGatewayModule : AbpModule { + protected const string ApplicationName = "Services.ApiGateWay"; + public override void PreConfigureServices(ServiceConfigurationContext context) + { + AbpSerilogEnrichersConsts.ApplicationName = ApplicationName; + + PreConfigure(options => + { + // 以开放端口区别 + options.SnowflakeIdOptions.WorkerId = 19; + options.SnowflakeIdOptions.WorkerIdBits = 5; + options.SnowflakeIdOptions.DatacenterId = 1; + }); + } + public override void ConfigureServices(ServiceConfigurationContext context) { var configuration = context.Services.GetConfiguration(); diff --git a/gateways/web/LY.MicroService.ApiGateway/LY.MicroService.ApiGateway.csproj b/gateways/web/LY.MicroService.ApiGateway/LY.MicroService.ApiGateway.csproj index cf2e0f4e4..3c7b2615d 100644 --- a/gateways/web/LY.MicroService.ApiGateway/LY.MicroService.ApiGateway.csproj +++ b/gateways/web/LY.MicroService.ApiGateway/LY.MicroService.ApiGateway.csproj @@ -14,6 +14,8 @@ + +