From 6f5860cc4364689b56ccce78fc3e8447f0d04802 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Tue, 13 Dec 2022 10:04:59 +0800 Subject: [PATCH] Upgrade abp framework to 6.0.2 * Upgrade abp framework to 6.0.2. * Update dapr package. * Update agile-config package. * Update stack-exchange-redis package. * Remove versions manager. * Add packages manager. --- aspnet-core/Directory.Build.props | 10 +- aspnet-core/LINGYUN.MicroService.All.sln | 15 +- aspnet-core/common.props | 8 +- ...NGYUN.Abp.CachingManagement.HttpApi.csproj | 38 +- .../LINGYUN/Abp/Cli/Commands/CreateCommand.cs | 19 +- .../LINGYUN/Abp/Cli/Commands/CreateOptions.cs | 6 + .../Commands/LocalFileCreateProjectService.cs | 5 +- .../Abp/Cli/Commands/ProjectCreateArgs.cs | 5 +- .../Properties/launchSettings.json | 3 +- .../LINGYUN.Abp.Data.DbMigrator.csproj | 30 +- .../LINGYUN.Abp.EventBus.CAP.csproj | 40 +- ....Abp.Dapr.Actors.AspNetCore.Wrapper.csproj | 32 +- .../LINGYUN.Abp.Dapr.Actors.AspNetCore.csproj | 32 +- .../LINGYUN.Abp.Dapr.Actors.csproj | 30 +- .../LINGYUN.Abp.Dapr.Client.Wrapper.csproj | 32 +- .../Wrapper/AbpDaprClientWrapperModule.cs | 26 + .../LINGYUN.Abp.Dapr.Client.csproj | 38 +- .../AbpDaprClientProxyOptions.cs | 13 + .../ClientProxying/DaprClientProxyBase.cs | 13 + .../LINGYUN.Abp.Dapr/LINGYUN.Abp.Dapr.csproj | 32 +- ...LINGYUN.Abp.DistributedLocking.Dapr.csproj | 42 +- ....DataProtection.EntityFrameworkCore.csproj | 40 +- ...GYUN.Abp.IdentityServer.Application.csproj | 40 +- ...LINGYUN.Abp.IdentityServer.LinkUser.csproj | 46 +- ...LINGYUN.Abp.Localization.CultureMap.csproj | 30 +- ...ationManagement.EntityFrameworkCore.csproj | 38 +- ....Abp.LocalizationManagement.HttpApi.csproj | 32 +- .../Properties/launchSettings.json | 12 + .../Packages/Dto/PackageBlobDownloadInput.cs | 11 + .../Platform/Packages/Dto/PackageBlobDto.cs | 21 + .../Packages/Dto/PackageBlobRemoveDto.cs | 11 + .../Packages/Dto/PackageBlobUploadDto.cs | 36 + .../Platform/Packages/Dto/PackageCreateDto.cs | 19 + .../Packages/Dto/PackageCreateOrUpdateDto.cs | 28 + .../Platform/Packages/Dto/PackageDto.cs | 46 + .../Packages/Dto/PackageGetLatestInput.cs | 11 + .../Packages/Dto/PackageGetPagedListInput.cs | 26 + .../Platform/Packages/Dto/PackageUpdateDto.cs | 8 + .../Platform/Packages/IPackageAppService.cs | 29 + .../PlatformPermissionDefinitionProvider.cs | 15 +- .../Permissions/PlatformPermissions.cs | 15 +- .../Platform/Versions/Dto/VersionCreateDto.cs | 33 - .../Platform/Versions/Dto/VersionDeleteDto.cs | 13 - .../Platform/Versions/Dto/VersionDto.cs | 34 - .../Versions/Dto/VersionFileCreateDto.cs | 51 - .../Versions/Dto/VersionFileDeleteDto.cs | 15 - .../Platform/Versions/Dto/VersionFileDto.cs | 33 - .../Versions/Dto/VersionFileGetDto.cs | 24 - .../Versions/Dto/VersionGetByIdDto.cs | 9 - .../Versions/Dto/VersionGetByPagedDto.cs | 10 - .../Platform/Versions/IVersionAppService.cs | 27 - .../Platform/Packages/PackageAppService.cs | 187 ++++ .../PlatformApplicationMappingProfile.cs | 6 +- .../Platform/Versions/VersionAppService.cs | 103 -- .../Platform/Localization/Resources/en.json | 1 + .../Localization/Resources/zh-Hans.json | 1 + .../PlatformModuleExtensionConsts.cs | 2 +- .../PlatfromModuleExtensionConfiguration.cs | 4 +- .../Platform/Packages/PackageBlobConsts.cs | 11 + .../Platform/Packages/PackageConsts.cs | 10 + .../LINGYUN/Platform/Packages/PackageEto.cs | 24 + .../LINGYUN/Platform/Packages/PackageLevel.cs | 17 + .../LINGYUN/Platform/PlatformErrorCodes.cs | 4 + .../Platform/Versions/AppVersionConsts.cs | 14 - .../Platform/Versions/AppVersionEto.cs | 33 - .../LINGYUN/Platform/Versions/FileType.cs | 21 - .../Platform/Versions/IVersionFileManager.cs | 11 - .../Platform/Versions/ImportantLevel.cs | 22 - .../Platform/Versions/VersionFileConsts.cs | 13 - .../FileSystemPackageBlobNormalizer.cs | 20 + .../Platform/Packages/IPackageBlobManager.cs | 25 + .../Packages/IPackageBlobNormalizer.cs | 6 + .../Platform/Packages/IPackageRepository.cs | 32 + .../LINGYUN/Platform/Packages/Package.cs | 114 +++ .../LINGYUN/Platform/Packages/PackageBlob.cs | 64 ++ .../Platform/Packages/PackageBlobManager.cs | 94 ++ .../Platform/Packages/PackageContainer.cs | 8 + .../Platform/Packages/PackageFilter.cs | 36 + .../Platform/Packages/PackageSpecification.cs | 31 + .../Platform/PlatformDomainMappingProfile.cs | 6 +- .../LINGYUN/Platform/PlatformDomainModule.cs | 14 +- .../PlatformSettingDefinitionProvider.cs | 31 +- .../LINGYUN/Platform/Versions/AppVersion.cs | 116 --- .../Platform/Versions/IVersionRepository.cs | 21 - .../Platform/Versions/VersionContainer.cs | 9 - .../LINGYUN/Platform/Versions/VersionFile.cs | 102 -- .../Platform/Versions/VersionManager.cs | 153 --- .../Expressions/ExpressionFuncExtensions.cs | 32 + .../EntityFrameworkCore/IPlatformDbContext.cs | 4 +- .../EntityFrameworkCore/PlatformDbContext.cs | 5 +- ...PlatformDbContextModelBuilderExtensions.cs | 81 +- .../PlatformEfCoreQueryableExtensions.cs | 13 + .../PlatformEntityFrameworkCoreModule.cs | 11 +- .../Packages/EfCorePackageRepository.cs | 80 ++ .../Versions/EfCoreVersionRepository.cs | 68 -- .../Platform/Packages/PackageController.cs | 97 ++ .../Platform/Versions/VersionController.cs | 224 ----- .../Quartz/QuartzJobSimpleAdapter.cs | 2 +- .../Properties/launchSettings.json | 12 + ....TextTemplating.EntityFrameworkCore.csproj | 38 +- .../FodyWeavers.xml | 3 + ...LINGYUN.Abp.WeChat.Official.Senparc.csproj | 20 + .../Senparc/AbpWeChatOfficialSenparcModule.cs | 9 + .../Senparc/WeChatOfficialController.cs | 81 ++ .../Senparc/WeChatOfficialMessageContext.cs | 7 + .../Senparc/WeChatOfficialMessageHandler.cs | 30 + ...GYUN.Abp.WxPusher.SettingManagement.csproj | 58 +- ...ice.PlatformManagement.HttpApi.Host.csproj | 146 +-- ...1212081339_Add-Package-Manager.Designer.cs | 934 ++++++++++++++++++ .../20221212081339_Add-Package-Manager.cs | 110 +++ ...20221213005241_Remove-Versions.Designer.cs | 771 +++++++++++++++ .../20221213005241_Remove-Versions.cs | 118 +++ ...ApiHostMigrationsDbContextModelSnapshot.cs | 126 ++- .../Packages/PackageBlobOssManager.cs | 105 ++ .../PlatformManagementHttpApiHostModule.cs | 1 + ...ervice.RealtimeMessage.HttpApi.Host.csproj | 164 +-- ...INGYUN.Abp.BlobStoring.Aliyun.Tests.csproj | 38 +- ...bp.ExceptionHandling.Emailing.Tests.csproj | 36 +- ...eatures.LimitValidation.Redis.Tests.csproj | 46 +- ....Abp.Features.LimitValidation.Tests.csproj | 42 +- .../LINGYUN.Abp.Localization.Xml.Tests.csproj | 74 +- .../LINGYUN.Abp.Location.Baidu.Tests.csproj | 54 +- .../LINGYUN.Abp.Location.Tencent.Tests.csproj | 54 +- ...LINGYUN.Abp.Rules.RulesEngine.Tests.csproj | 72 +- 124 files changed, 4324 insertions(+), 2040 deletions(-) create mode 100644 aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Tencent/Properties/launchSettings.json create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageBlobDownloadInput.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageBlobDto.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageBlobRemoveDto.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageBlobUploadDto.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageCreateDto.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageCreateOrUpdateDto.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageDto.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageGetLatestInput.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageGetPagedListInput.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageUpdateDto.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/IPackageAppService.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionCreateDto.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionDeleteDto.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionDto.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileCreateDto.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileDeleteDto.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileDto.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileGetDto.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionGetByIdDto.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionGetByPagedDto.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/IVersionAppService.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Packages/PackageAppService.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Versions/VersionAppService.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Packages/PackageBlobConsts.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Packages/PackageConsts.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Packages/PackageEto.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Packages/PackageLevel.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/AppVersionConsts.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/AppVersionEto.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/FileType.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/IVersionFileManager.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/ImportantLevel.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/VersionFileConsts.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/FileSystemPackageBlobNormalizer.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/IPackageBlobManager.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/IPackageBlobNormalizer.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/IPackageRepository.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/Package.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/PackageBlob.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/PackageBlobManager.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/PackageContainer.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/PackageFilter.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/PackageSpecification.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/AppVersion.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/IVersionRepository.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/VersionContainer.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/VersionFile.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/VersionManager.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.Domain/System/Linq/Expressions/ExpressionFuncExtensions.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Packages/EfCorePackageRepository.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Versions/EfCoreVersionRepository.cs create mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Packages/PackageController.cs delete mode 100644 aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Versions/VersionController.cs create mode 100644 aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.Saas/Properties/launchSettings.json create mode 100644 aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/FodyWeavers.xml create mode 100644 aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/LINGYUN.Abp.WeChat.Official.Senparc.csproj create mode 100644 aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/LINGYUN/Abp/WeChat/Official/Senparc/AbpWeChatOfficialSenparcModule.cs create mode 100644 aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/LINGYUN/Abp/WeChat/Official/Senparc/WeChatOfficialController.cs create mode 100644 aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/LINGYUN/Abp/WeChat/Official/Senparc/WeChatOfficialMessageContext.cs create mode 100644 aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/LINGYUN/Abp/WeChat/Official/Senparc/WeChatOfficialMessageHandler.cs create mode 100644 aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20221212081339_Add-Package-Manager.Designer.cs create mode 100644 aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20221212081339_Add-Package-Manager.cs create mode 100644 aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20221213005241_Remove-Versions.Designer.cs create mode 100644 aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20221213005241_Remove-Versions.cs create mode 100644 aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Packages/PackageBlobOssManager.cs diff --git a/aspnet-core/Directory.Build.props b/aspnet-core/Directory.Build.props index ad9d6c2a7..eb08075eb 100644 --- a/aspnet-core/Directory.Build.props +++ b/aspnet-core/Directory.Build.props @@ -1,15 +1,15 @@  - 6.0.1 - 6.0.1 - 1.8.0 + 6.0.2 + 6.0.2 + 1.9.0 1.0.2 7.0.0 2.9.0 1.5.10 2.13.0 3.0.434 - 1.2.1.5 + 1.6.9 2.0.3 1.7.29 7.15.1 @@ -19,7 +19,7 @@ 1.0.0-rc8 1.0.0-beta2 3.3.3 - 2.0.593 + 2.2.4 2.10.0 5.0.0 2.2.0 diff --git a/aspnet-core/LINGYUN.MicroService.All.sln b/aspnet-core/LINGYUN.MicroService.All.sln index 8f7558a0a..6b5c73b1e 100644 --- a/aspnet-core/LINGYUN.MicroService.All.sln +++ b/aspnet-core/LINGYUN.MicroService.All.sln @@ -352,6 +352,9 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A76A4741-AF91-44EF-A7B6-8E7AF4961146}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig + common.props = common.props + configureawait.props = configureawait.props + Directory.Build.props = Directory.Build.props EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Tencent.SettingManagement", "modules\cloud-tencent\LINGYUN.Abp.Tencent.SettingManagement\LINGYUN.Abp.Tencent.SettingManagement.csproj", "{C7CF4193-6397-4450-AF42-3BACD7CF292E}" @@ -502,12 +505,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OpenIddict.WeCh EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.IdGenerator.Tests", "tests\LINGYUN.Abp.IdGenerator.Tests\LINGYUN.Abp.IdGenerator.Tests.csproj", "{2BFFE9C3-E022-4B57-9E4D-0A0408424B1A}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".Solution Items", ".Solution Items", "{7D604751-3FA4-4826-A93B-BBC10D73C861}" - ProjectSection(SolutionItems) = preProject - common.props = common.props - configureawait.props = configureawait.props - Directory.Build.props = Directory.Build.props - EndProjectSection +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.WeChat.Official.Senparc", "modules\wechat\LINGYUN.Abp.WeChat.Official.Senparc\LINGYUN.Abp.WeChat.Official.Senparc.csproj", "{CA8D7141-9520-46AC-83FD-6E034AD6EBDD}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -1307,6 +1305,10 @@ Global {2BFFE9C3-E022-4B57-9E4D-0A0408424B1A}.Debug|Any CPU.Build.0 = Debug|Any CPU {2BFFE9C3-E022-4B57-9E4D-0A0408424B1A}.Release|Any CPU.ActiveCfg = Release|Any CPU {2BFFE9C3-E022-4B57-9E4D-0A0408424B1A}.Release|Any CPU.Build.0 = Release|Any CPU + {CA8D7141-9520-46AC-83FD-6E034AD6EBDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CA8D7141-9520-46AC-83FD-6E034AD6EBDD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CA8D7141-9520-46AC-83FD-6E034AD6EBDD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CA8D7141-9520-46AC-83FD-6E034AD6EBDD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1553,6 +1555,7 @@ Global {74C13BCC-A5A5-40FA-81E8-83DCCF760148} = {83E698F6-F8CD-4604-AB80-01A203389501} {427382F6-3153-47A2-BBC4-88F6EA116A8F} = {83E698F6-F8CD-4604-AB80-01A203389501} {2BFFE9C3-E022-4B57-9E4D-0A0408424B1A} = {370D7CD5-1E17-4F3D-BBFA-03429F6D4F2F} + {CA8D7141-9520-46AC-83FD-6E034AD6EBDD} = {DD9BE9E7-F6BF-4869-BCD2-82F5072BDA21} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C95FDF91-16F2-4A8B-A4BE-0E62D1B66718} diff --git a/aspnet-core/common.props b/aspnet-core/common.props index 0bb3d80a6..879ddc1fc 100644 --- a/aspnet-core/common.props +++ b/aspnet-core/common.props @@ -1,7 +1,7 @@ latest - 6.0.1 + 6.0.2 colin $(NoWarn);CS1591;CS0436;CS8618;NU1803 https://github.com/colinin/abp-next-admin @@ -17,6 +17,12 @@ + + + + + + diff --git a/aspnet-core/modules/caching/LINGYUN.Abp.CachingManagement.HttpApi/LINGYUN.Abp.CachingManagement.HttpApi.csproj b/aspnet-core/modules/caching/LINGYUN.Abp.CachingManagement.HttpApi/LINGYUN.Abp.CachingManagement.HttpApi.csproj index f2f88139a..f481b084b 100644 --- a/aspnet-core/modules/caching/LINGYUN.Abp.CachingManagement.HttpApi/LINGYUN.Abp.CachingManagement.HttpApi.csproj +++ b/aspnet-core/modules/caching/LINGYUN.Abp.CachingManagement.HttpApi/LINGYUN.Abp.CachingManagement.HttpApi.csproj @@ -1,19 +1,19 @@ - - - - - - - net6.0 - - - - - - - - - - - - + + + + + + + net6.0 + + + + + + + + + + + + diff --git a/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN/Abp/Cli/Commands/CreateCommand.cs b/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN/Abp/Cli/Commands/CreateCommand.cs index e948aa07e..f8d79f2c9 100644 --- a/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN/Abp/Cli/Commands/CreateCommand.cs +++ b/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN/Abp/Cli/Commands/CreateCommand.cs @@ -114,6 +114,12 @@ namespace LINGYUN.Abp.Cli.Commands Logger.LogInformation("DBMS: " + databaseManagementSystem); } + var authenticationScheme = GetAuthenticationScheme(commandLineArgs); + if (!authenticationScheme.IsNullOrWhiteSpace()) + { + Logger.LogInformation("Authentication Scheme: " + authenticationScheme); + } + var randomPort = string.IsNullOrWhiteSpace( commandLineArgs.Options.GetOrNull(CreateOptions.NoRandomPort.Short, CreateOptions.NoRandomPort.Long)); var applicationPort = randomPort ? RandomHelper.GetRandom(5001, 65535).ToString() : "5000"; @@ -166,7 +172,8 @@ namespace LINGYUN.Abp.Cli.Commands commandLineArgs.Options, connectionString, applicationPort, - daprPort + daprPort, + authenticationScheme ); await CreateProjectService.CreateAsync(projectArgs); @@ -197,6 +204,7 @@ namespace LINGYUN.Abp.Cli.Commands sb.AppendLine("-csf|--create-solution-folder (default: true)"); sb.AppendLine("-cs|--connection-string (your database connection string)"); sb.AppendLine("--dbms (your database management system)"); + sb.AppendLine("--as (your identity authentication provider, optional: IdentityServer4、OpenIddict, default: IdentityServer4)"); sb.AppendLine("--no-random-port (Use template's default ports)"); sb.AppendLine(""); sb.AppendLine("Examples:"); @@ -209,6 +217,7 @@ namespace LINGYUN.Abp.Cli.Commands sb.AppendLine(" labp create Acme.BookStore -csf false"); sb.AppendLine(" labp create Acme.BookStore --local-framework-ref --abp-path \"D:\\github\\abp\""); sb.AppendLine(" labp create Acme.BookStore --dbms mysql"); + sb.AppendLine(" labp create Acme.BookStore --as openiddict"); sb.AppendLine(" labp create Acme.BookStore --connection-string \"Server=myServerName\\myInstanceName;Database=myDatabase;User Id=myUsername;Password=myPassword\""); sb.AppendLine(""); // TODO: 文档 @@ -223,6 +232,14 @@ namespace LINGYUN.Abp.Cli.Commands || commandLineArgs.Options.ContainsKey(NewCommand.Options.CreateSolutionFolder.Short); } + protected virtual string GetAuthenticationScheme(CommandLineArgs commandLineArgs) + { + var authScheme = commandLineArgs.Options.GetOrNull( + CreateOptions.AuthenticationScheme.Short, + CreateOptions.AuthenticationScheme.Long); + return string.IsNullOrWhiteSpace(authScheme) ? "IdentityServer4" : authScheme; + } + protected virtual DatabaseProvider GetDatabaseProvider(CommandLineArgs commandLineArgs) { var optionValue = commandLineArgs.Options.GetOrNull( diff --git a/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN/Abp/Cli/Commands/CreateOptions.cs b/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN/Abp/Cli/Commands/CreateOptions.cs index 93a3a1279..aced4560b 100644 --- a/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN/Abp/Cli/Commands/CreateOptions.cs +++ b/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN/Abp/Cli/Commands/CreateOptions.cs @@ -21,5 +21,11 @@ public const string Short = "nrp"; public const string Long = "no-random-port"; } + + public static class AuthenticationScheme + { + public const string Short = "as"; + public const string Long = "auth-scheme"; + } } } diff --git a/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN/Abp/Cli/Commands/LocalFileCreateProjectService.cs b/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN/Abp/Cli/Commands/LocalFileCreateProjectService.cs index d9f94a639..ef3227e97 100644 --- a/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN/Abp/Cli/Commands/LocalFileCreateProjectService.cs +++ b/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN/Abp/Cli/Commands/LocalFileCreateProjectService.cs @@ -63,6 +63,9 @@ namespace LINGYUN.Abp.Cli.Commands commandBuilder.AppendFormat(" -n {0}", createArgs.SolutionName.ProjectName); commandBuilder.AppendFormat(" -o {0}", createArgs.OutputFolder); commandBuilder.AppendFormat(" --DatabaseManagement {0}", dbm); + commandBuilder.AppendFormat(" --AuthenticationScheme {0}", createArgs.AuthenticationScheme); + + Logger.LogInformation("Execute command: " + commandBuilder.ToString()); var cmdError = CmdHelper.RunCmdAndGetOutput(commandBuilder.ToString(), out bool isSuccessful); if (!isSuccessful) @@ -71,7 +74,7 @@ namespace LINGYUN.Abp.Cli.Commands return; } - Logger.LogInformation("Execute command: " + cmdError); + Logger.LogInformation("Executed command: " + cmdError); var projectFiles = new List(); diff --git a/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN/Abp/Cli/Commands/ProjectCreateArgs.cs b/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN/Abp/Cli/Commands/ProjectCreateArgs.cs index b001e6388..2080caa03 100644 --- a/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN/Abp/Cli/Commands/ProjectCreateArgs.cs +++ b/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN/Abp/Cli/Commands/ProjectCreateArgs.cs @@ -9,6 +9,7 @@ namespace LINGYUN.Abp.Cli.Commands public string PackageName { get; } public string ApplicationPort { get; } public string DaprPort { get; } + public string AuthenticationScheme { get; } public ProjectCreateArgs( string packageName, SolutionName solutionName, @@ -26,7 +27,8 @@ namespace LINGYUN.Abp.Cli.Commands Dictionary extraProperties = null, string connectionString = null, string applicationPort = "5000", - string daprPort = "3500") + string daprPort = "3500", + string authenticationScheme = "IdentityServer4") : base( solutionName, templateName, @@ -46,6 +48,7 @@ namespace LINGYUN.Abp.Cli.Commands PackageName = packageName; ApplicationPort = applicationPort; DaprPort = daprPort; + AuthenticationScheme = authenticationScheme; } } } diff --git a/aspnet-core/modules/cli/LINGYUN.Abp.Cli/Properties/launchSettings.json b/aspnet-core/modules/cli/LINGYUN.Abp.Cli/Properties/launchSettings.json index 22dc9321e..b258200c5 100644 --- a/aspnet-core/modules/cli/LINGYUN.Abp.Cli/Properties/launchSettings.json +++ b/aspnet-core/modules/cli/LINGYUN.Abp.Cli/Properties/launchSettings.json @@ -1,7 +1,8 @@ { "profiles": { "LINGYUN.Abp.Cli": { - "commandName": "Project" + "commandName": "Project", + "commandLineArgs": "help create" } } } \ No newline at end of file diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Data.DbMigrator/LINGYUN.Abp.Data.DbMigrator.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Data.DbMigrator/LINGYUN.Abp.Data.DbMigrator.csproj index 5e407efef..314f386ec 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Data.DbMigrator/LINGYUN.Abp.Data.DbMigrator.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Data.DbMigrator/LINGYUN.Abp.Data.DbMigrator.csproj @@ -1,15 +1,15 @@ - - - - - - - net6.0 - - - - - - - - + + + + + + + net6.0 + + + + + + + + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.csproj b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.csproj index a767f4668..014be2cb4 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.csproj @@ -1,20 +1,20 @@ - - - - - - - net6.0 - - Cap分布式事件总线 - true - $(SolutionDir)modules\common\LINGYUN.Abp.EventBus.CAP\LINGYUN.Abp.EventBus.CAP.xml - - - - - - - - - + + + + + + + net6.0 + + Cap分布式事件总线 + true + $(SolutionDir)modules\common\LINGYUN.Abp.EventBus.CAP\LINGYUN.Abp.EventBus.CAP.xml + + + + + + + + + diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper.csproj b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper.csproj index c2ab11636..658e83ed0 100644 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper.csproj +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper.csproj @@ -1,16 +1,16 @@ - - - - - - - net6.0 - - - - - - - - - + + + + + + + net6.0 + + + + + + + + + diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore/LINGYUN.Abp.Dapr.Actors.AspNetCore.csproj b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore/LINGYUN.Abp.Dapr.Actors.AspNetCore.csproj index b965e7a6c..e3b5db94d 100644 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore/LINGYUN.Abp.Dapr.Actors.AspNetCore.csproj +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore/LINGYUN.Abp.Dapr.Actors.AspNetCore.csproj @@ -1,16 +1,16 @@ - - - - - - - net6.0 - - - - - - - - - + + + + + + + net6.0 + + + + + + + + + diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors/LINGYUN.Abp.Dapr.Actors.csproj b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors/LINGYUN.Abp.Dapr.Actors.csproj index 933136019..bf40da9e6 100644 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors/LINGYUN.Abp.Dapr.Actors.csproj +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Actors/LINGYUN.Abp.Dapr.Actors.csproj @@ -1,15 +1,15 @@ - - - - - - - net6.0 - - - - - - - - + + + + + + + net6.0 + + + + + + + + diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client.Wrapper/LINGYUN.Abp.Dapr.Client.Wrapper.csproj b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client.Wrapper/LINGYUN.Abp.Dapr.Client.Wrapper.csproj index 3d1444b92..a1eaeaf19 100644 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client.Wrapper/LINGYUN.Abp.Dapr.Client.Wrapper.csproj +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client.Wrapper/LINGYUN.Abp.Dapr.Client.Wrapper.csproj @@ -1,16 +1,16 @@ - - - - - - - net6.0 - - - - - - - - - + + + + + + + net6.0 + + + + + + + + + diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client.Wrapper/LINGYUN/Abp/Dapr/Client/Wrapper/AbpDaprClientWrapperModule.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client.Wrapper/LINGYUN/Abp/Dapr/Client/Wrapper/AbpDaprClientWrapperModule.cs index 2766623bb..3d14a0910 100644 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client.Wrapper/LINGYUN/Abp/Dapr/Client/Wrapper/AbpDaprClientWrapperModule.cs +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client.Wrapper/LINGYUN/Abp/Dapr/Client/Wrapper/AbpDaprClientWrapperModule.cs @@ -58,6 +58,32 @@ namespace LINGYUN.Abp.Dapr.Client.Wrapper return stringContent; }); + options.OnError(async (response, serviceProvider) => + { + if (response.Headers.Contains(AbpHttpWrapConsts.AbpWrapResult)) + { + try + { + var jsonSerializer = serviceProvider.LazyGetRequiredService(); + var result = jsonSerializer.Deserialize( + await response.Content.ReadAsStringAsync()); + + return new RemoteServiceErrorInfo( + result.Message, + result.Details, + result.Code); + } + catch + { + return new RemoteServiceErrorInfo + { + Message = response.ReasonPhrase, + Code = response.StatusCode.ToString() + }; + } + } + return null; + }); }); } } diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN.Abp.Dapr.Client.csproj b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN.Abp.Dapr.Client.csproj index 6219fe71d..d65383c68 100644 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN.Abp.Dapr.Client.csproj +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN.Abp.Dapr.Client.csproj @@ -1,19 +1,19 @@ - - - - - - - net6.0 - - - - - - - - - - - - + + + + + + + net6.0 + + + + + + + + + + + + diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/ClientProxying/AbpDaprClientProxyOptions.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/ClientProxying/AbpDaprClientProxyOptions.cs index d359469c9..23410a129 100644 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/ClientProxying/AbpDaprClientProxyOptions.cs +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/ClientProxying/AbpDaprClientProxyOptions.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Net.Http; using System.Threading.Tasks; using Volo.Abp.DependencyInjection; +using Volo.Abp.Http; namespace LINGYUN.Abp.Dapr.Client.ClientProxying { @@ -20,6 +21,10 @@ namespace LINGYUN.Abp.Dapr.Client.ClientProxying /// 对响应进行处理,返回响应内容 /// public Func> ProxyResponseContent { get; private set; } + /// + /// 格式化错误 + /// + public Func> ProxyErrorFormat { get; private set; } public AbpDaprClientProxyOptions() { DaprClientProxies = new Dictionary(); @@ -38,5 +43,13 @@ namespace LINGYUN.Abp.Dapr.Client.ClientProxying { ProxyResponseContent = func; } + /// + /// 处理服务间调用错误消息 + /// + /// + public void OnError(Func> func) + { + ProxyErrorFormat = func; + } } } diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/ClientProxying/DaprClientProxyBase.cs b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/ClientProxying/DaprClientProxyBase.cs index dca292e43..8a946e4ad 100644 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/ClientProxying/DaprClientProxyBase.cs +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr.Client/LINGYUN/Abp/Dapr/Client/ClientProxying/DaprClientProxyBase.cs @@ -6,6 +6,8 @@ using System.Net.Http; using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Content; +using Volo.Abp.Http.Client; +using Volo.Abp.Http; using Volo.Abp.Http.Client.Authentication; using Volo.Abp.Http.Client.ClientProxying; @@ -115,6 +117,17 @@ namespace LINGYUN.Abp.Dapr.Client.ClientProxying if (!response.IsSuccessStatusCode) { + if (DaprClientProxyOptions.Value.ProxyErrorFormat != null) + { + var errorInfo = await DaprClientProxyOptions.Value.ProxyErrorFormat(response, LazyServiceProvider); + if (errorInfo != null) + { + throw new AbpRemoteCallException(errorInfo) + { + HttpStatusCode = (int)response.StatusCode + }; + } + } await ThrowExceptionForResponseAsync(response); } diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr/LINGYUN.Abp.Dapr.csproj b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr/LINGYUN.Abp.Dapr.csproj index 1641159ee..754b51ba4 100644 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr/LINGYUN.Abp.Dapr.csproj +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.Dapr/LINGYUN.Abp.Dapr.csproj @@ -1,16 +1,16 @@ - - - - - - - net6.0 - - - - - - - - - + + + + + + + net6.0 + + + + + + + + + diff --git a/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN.Abp.DistributedLocking.Dapr.csproj b/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN.Abp.DistributedLocking.Dapr.csproj index be2e66567..6af99b359 100644 --- a/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN.Abp.DistributedLocking.Dapr.csproj +++ b/aspnet-core/modules/dapr/LINGYUN.Abp.DistributedLocking.Dapr/LINGYUN.Abp.DistributedLocking.Dapr.csproj @@ -1,21 +1,21 @@ - - - - - - - net6.0 - - - - - - - - - - - - - - + + + + + + + net6.0 + + + + + + + + + + + + + + diff --git a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN.Abp.DataProtection.EntityFrameworkCore.csproj b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN.Abp.DataProtection.EntityFrameworkCore.csproj index fe4482ff0..89c8c06d8 100644 --- a/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN.Abp.DataProtection.EntityFrameworkCore.csproj +++ b/aspnet-core/modules/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN.Abp.DataProtection.EntityFrameworkCore.csproj @@ -1,20 +1,20 @@ - - - - - - - net6.0 - 9.0 - - - - - - - - - - - - + + + + + + + net6.0 + 9.0 + + + + + + + + + + + + diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application/LINGYUN.Abp.IdentityServer.Application.csproj b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application/LINGYUN.Abp.IdentityServer.Application.csproj index 012299114..a79ea30d2 100644 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application/LINGYUN.Abp.IdentityServer.Application.csproj +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application/LINGYUN.Abp.IdentityServer.Application.csproj @@ -1,20 +1,20 @@ - - - - - - - net6.0 - - - - - - - - - - - - - + + + + + + + net6.0 + + + + + + + + + + + + + diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.LinkUser/LINGYUN.Abp.IdentityServer.LinkUser.csproj b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.LinkUser/LINGYUN.Abp.IdentityServer.LinkUser.csproj index f9cbcd2cc..6d8982839 100644 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.LinkUser/LINGYUN.Abp.IdentityServer.LinkUser.csproj +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.LinkUser/LINGYUN.Abp.IdentityServer.LinkUser.csproj @@ -1,23 +1,23 @@ - - - - - - - net6.0 - - - - - - - - - - - - - - - - + + + + + + + net6.0 + + + + + + + + + + + + + + + + diff --git a/aspnet-core/modules/localization/LINGYUN.Abp.Localization.CultureMap/LINGYUN.Abp.Localization.CultureMap.csproj b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.CultureMap/LINGYUN.Abp.Localization.CultureMap.csproj index 2d8b5450a..c21a3091e 100644 --- a/aspnet-core/modules/localization/LINGYUN.Abp.Localization.CultureMap/LINGYUN.Abp.Localization.CultureMap.csproj +++ b/aspnet-core/modules/localization/LINGYUN.Abp.Localization.CultureMap/LINGYUN.Abp.Localization.CultureMap.csproj @@ -1,15 +1,15 @@ - - - - - - - net6.0 - - - - - - - - + + + + + + + net6.0 + + + + + + + + diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore.csproj b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore.csproj index 490917ee6..1c34300a6 100644 --- a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore.csproj +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore.csproj @@ -1,19 +1,19 @@ - - - - - - - net6.0 - - - - - - - - - - - - + + + + + + + net6.0 + + + + + + + + + + + + diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.HttpApi/LINGYUN.Abp.LocalizationManagement.HttpApi.csproj b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.HttpApi/LINGYUN.Abp.LocalizationManagement.HttpApi.csproj index 2c5a6ee68..82453cf7f 100644 --- a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.HttpApi/LINGYUN.Abp.LocalizationManagement.HttpApi.csproj +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.HttpApi/LINGYUN.Abp.LocalizationManagement.HttpApi.csproj @@ -1,16 +1,16 @@ - - - - - - - net6.0 - - - - - - - - - + + + + + + + net6.0 + + + + + + + + + diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Tencent/Properties/launchSettings.json b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Tencent/Properties/launchSettings.json new file mode 100644 index 000000000..5cb98d623 --- /dev/null +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Tencent/Properties/launchSettings.json @@ -0,0 +1,12 @@ +{ + "profiles": { + "LINGYUN.Abp.OssManagement.Tencent": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:58740;http://localhost:58741" + } + } +} \ No newline at end of file diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageBlobDownloadInput.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageBlobDownloadInput.cs new file mode 100644 index 000000000..0c26c9d1b --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageBlobDownloadInput.cs @@ -0,0 +1,11 @@ +using System.ComponentModel.DataAnnotations; +using Volo.Abp.Validation; + +namespace LINGYUN.Platform.Packages; + +public class PackageBlobDownloadInput +{ + [Required] + [DynamicMaxLength(typeof(PackageBlobConsts), nameof(PackageBlobConsts.MaxNameLength))] + public string Name { get; set; } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageBlobDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageBlobDto.cs new file mode 100644 index 000000000..2904d1983 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageBlobDto.cs @@ -0,0 +1,21 @@ +using System; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Data; + +namespace LINGYUN.Platform.Packages; + +public class PackageBlobDto : CreationAuditedEntityDto, IHasExtraProperties +{ + public string Name { get; set; } + public string Url { get; set; } + public long? Size { get; set; } + public string Summary { get; set; } + public DateTime CreatedAt { get; set; } + public DateTime? UpdatedAt { get; set; } + public string License { get; set; } + public string Authors { get; set; } + public string SHA256 { get; set; } + public string ContentType { get; set; } + public int DownloadCount { get; set; } + public ExtraPropertyDictionary ExtraProperties { get; set; } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageBlobRemoveDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageBlobRemoveDto.cs new file mode 100644 index 000000000..a9f7c80db --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageBlobRemoveDto.cs @@ -0,0 +1,11 @@ +using System.ComponentModel.DataAnnotations; +using Volo.Abp.Validation; + +namespace LINGYUN.Platform.Packages; + +public class PackageBlobRemoveDto +{ + [Required] + [DynamicMaxLength(typeof(PackageBlobConsts), nameof(PackageBlobConsts.MaxNameLength))] + public string Name { get; set; } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageBlobUploadDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageBlobUploadDto.cs new file mode 100644 index 000000000..4d3205caa --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageBlobUploadDto.cs @@ -0,0 +1,36 @@ +using System; +using System.ComponentModel.DataAnnotations; +using Volo.Abp.Auditing; +using Volo.Abp.Content; +using Volo.Abp.Validation; + +namespace LINGYUN.Platform.Packages; + +public class PackageBlobUploadDto +{ + [Required] + [DynamicMaxLength(typeof(PackageBlobConsts), nameof(PackageBlobConsts.MaxNameLength))] + public string Name { get; set; } + + public long? Size { get; set; } + + [DynamicMaxLength(typeof(PackageBlobConsts), nameof(PackageBlobConsts.MaxSummaryLength))] + public string Summary { get; set; } + + [DynamicMaxLength(typeof(PackageBlobConsts), nameof(PackageBlobConsts.MaxContentTypeLength))] + public string ContentType { get; set; } + + public DateTime CreatedAt { get; set; } + + public DateTime? UpdatedAt { get; set; } + + [DynamicMaxLength(typeof(PackageBlobConsts), nameof(PackageBlobConsts.MaxLicenseLength))] + public string License { get; set; } + + [DynamicMaxLength(typeof(PackageBlobConsts), nameof(PackageBlobConsts.MaxAuthorsLength))] + public string Authors { get; set; } + + [Required] + [DisableAuditing] + public IRemoteStreamContent File { get; set; } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageCreateDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageCreateDto.cs new file mode 100644 index 000000000..e6c6f6adc --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageCreateDto.cs @@ -0,0 +1,19 @@ +using System.ComponentModel.DataAnnotations; +using Volo.Abp.Validation; + +namespace LINGYUN.Platform.Packages; +public class PackageCreateDto : PackageCreateOrUpdateDto +{ + /// + /// 名称 + /// + [Required] + [DynamicMaxLength(typeof(PackageConsts), nameof(PackageConsts.MaxNameLength))] + public string Name { get; set; } + /// + /// 版本 + /// + [Required] + [DynamicMaxLength(typeof(PackageConsts), nameof(PackageConsts.MaxVersionLength))] + public string Version { get; set; } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageCreateOrUpdateDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageCreateOrUpdateDto.cs new file mode 100644 index 000000000..a3c271ce4 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageCreateOrUpdateDto.cs @@ -0,0 +1,28 @@ +using System.ComponentModel.DataAnnotations; +using Volo.Abp.Validation; + +namespace LINGYUN.Platform.Packages; + +public abstract class PackageCreateOrUpdateDto +{ + /// + /// 版本说明 + /// + [Required] + [DynamicMaxLength(typeof(PackageConsts), nameof(PackageConsts.MaxNoteLength))] + public string Note { get; set; } + /// + /// 描述 + /// + [DynamicMaxLength(typeof(PackageConsts), nameof(PackageConsts.MaxDescriptionLength))] + public string Description { get; set; } + /// + /// 强制更新 + /// + public bool ForceUpdate { get; set; } + + [DynamicMaxLength(typeof(PackageConsts), nameof(PackageConsts.MaxAuthorsLength))] + public string Authors { get; set; } + + public PackageLevel Level { get; set; } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageDto.cs new file mode 100644 index 000000000..33224e143 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageDto.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Domain.Entities; + +namespace LINGYUN.Platform.Packages; + +public class PackageDto : ExtensibleAuditedEntityDto, IHasConcurrencyStamp +{ + public string ConcurrencyStamp { get; set; } + /// + /// 名称 + /// + public string Name { get; set; } + /// + /// 版本说明 + /// + public string Note { get; set; } + /// + /// 版本 + /// + public string Version { get; set; } + /// + /// 描述 + /// + public string Description { get; set; } + /// + /// 强制更新 + /// + public bool ForceUpdate { get; set; } + + public string Authors { get; set; } + + public PackageLevel Level { get; set; } + + public List Blobs { get; set; } = new List(); + + public static PackageDto None() + { + return new PackageDto + { + Level = PackageLevel.None, + Blobs = new List() + }; + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageGetLatestInput.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageGetLatestInput.cs new file mode 100644 index 000000000..2c779cafd --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageGetLatestInput.cs @@ -0,0 +1,11 @@ +using System.ComponentModel.DataAnnotations; +using Volo.Abp.Validation; + +namespace LINGYUN.Platform.Packages; + +public class PackageGetLatestInput +{ + [Required] + [DynamicMaxLength(typeof(PackageBlobConsts), nameof(PackageBlobConsts.MaxNameLength))] + public string Name { get; set; } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageGetPagedListInput.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageGetPagedListInput.cs new file mode 100644 index 000000000..92c81bbc6 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageGetPagedListInput.cs @@ -0,0 +1,26 @@ +using Volo.Abp.Application.Dtos; +using Volo.Abp.Validation; + +namespace LINGYUN.Platform.Packages; + +public class PackageGetPagedListInput : PagedAndSortedResultRequestDto +{ + public string Filter { get; set; } + + [DynamicMaxLength(typeof(PackageConsts), nameof(PackageConsts.MaxNameLength))] + public string Name { get; set; } + + [DynamicMaxLength(typeof(PackageConsts), nameof(PackageConsts.MaxNoteLength))] + public string Note { get; set; } + + [DynamicMaxLength(typeof(PackageConsts), nameof(PackageConsts.MaxVersionLength))] + public string Version { get; set; } + + [DynamicMaxLength(typeof(PackageConsts), nameof(PackageConsts.MaxDescriptionLength))] + public string Description { get; set; } + + public bool? ForceUpdate { get; set; } + + [DynamicMaxLength(typeof(PackageConsts), nameof(PackageConsts.MaxAuthorsLength))] + public string Authors { get; set; } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageUpdateDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageUpdateDto.cs new file mode 100644 index 000000000..beea3bfee --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/Dto/PackageUpdateDto.cs @@ -0,0 +1,8 @@ +using Volo.Abp.Domain.Entities; + +namespace LINGYUN.Platform.Packages; + +public class PackageUpdateDto : PackageCreateOrUpdateDto, IHasConcurrencyStamp +{ + public string ConcurrencyStamp { get; set; } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/IPackageAppService.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/IPackageAppService.cs new file mode 100644 index 000000000..6a8e6bc6a --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Packages/IPackageAppService.cs @@ -0,0 +1,29 @@ +using System; +using System.Threading.Tasks; +using Volo.Abp.Application.Services; +using Volo.Abp.Content; + +namespace LINGYUN.Platform.Packages; + +public interface IPackageAppService : + ICrudAppService< + PackageDto, + Guid, + PackageGetPagedListInput, + PackageCreateDto, + PackageUpdateDto> +{ + Task GetLatestAsync(PackageGetLatestInput input); + + Task UploadBlobAsync( + Guid id, + PackageBlobUploadDto input); + + Task RemoveBlobAsync( + Guid id, + PackageBlobRemoveDto input); + + Task DownloadBlobAsync( + Guid id, + PackageBlobDownloadInput input); +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Permissions/PlatformPermissionDefinitionProvider.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Permissions/PlatformPermissionDefinitionProvider.cs index 719bf2240..d9397a3bb 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Permissions/PlatformPermissionDefinitionProvider.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Permissions/PlatformPermissionDefinitionProvider.cs @@ -10,15 +10,6 @@ namespace LINGYUN.Platform.Permissions { var platform = context.AddGroup(PlatformPermissions.GroupName, L("Permission:Platform")); - var appVersion = platform.AddPermission(PlatformPermissions.AppVersion.Default, L("Permission:AppVersion")); - appVersion.AddChild(PlatformPermissions.AppVersion.Create, L("Permission:CreateVersion")); - appVersion.AddChild(PlatformPermissions.AppVersion.Delete, L("Permission:DeleteVersion")); - - var versionFile = appVersion.AddChild(PlatformPermissions.AppVersion.FileManager.Default, L("Permission:FileManager")); - versionFile.AddChild(PlatformPermissions.AppVersion.FileManager.Create, L("Permission:AppendFile")); - versionFile.AddChild(PlatformPermissions.AppVersion.FileManager.Delete, L("Permission:DeleteFile")); - versionFile.AddChild(PlatformPermissions.AppVersion.FileManager.Download, L("Permission:DownloadFile")); - var dataDictionary = platform.AddPermission(PlatformPermissions.DataDictionary.Default, L("Permission:DataDictionary")); dataDictionary.AddChild(PlatformPermissions.DataDictionary.Create, L("Permission:Create")); dataDictionary.AddChild(PlatformPermissions.DataDictionary.Update, L("Permission:Update")); @@ -38,6 +29,12 @@ namespace LINGYUN.Platform.Permissions menu.AddChild(PlatformPermissions.Menu.ManageRoles, L("Permission:ManageRoleMenus")); menu.AddChild(PlatformPermissions.Menu.ManageUsers, L("Permission:ManageUserMenus")); menu.AddChild(PlatformPermissions.Menu.ManageUserFavorites, L("Permission:ManageUserFavoriteMenus")); + + var package = platform.AddPermission(PlatformPermissions.Package.Default, L("Permission:Package")); + package.AddChild(PlatformPermissions.Package.Create, L("Permission:Create")); + package.AddChild(PlatformPermissions.Package.Update, L("Permission:Update")); + package.AddChild(PlatformPermissions.Package.Delete, L("Permission:Delete")); + package.AddChild(PlatformPermissions.Package.ManageBlobs, L("Permission:ManageBlobs")); } private static LocalizableString L(string name) diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Permissions/PlatformPermissions.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Permissions/PlatformPermissions.cs index 6e38b5dda..e15d43430 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Permissions/PlatformPermissions.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Permissions/PlatformPermissions.cs @@ -85,24 +85,17 @@ namespace LINGYUN.Platform.Permissions } } - public class AppVersion + public class Package { - public const string Default = GroupName + ".AppVersion"; + public const string Default = GroupName + ".Package"; public const string Create = Default + ".Create"; public const string Delete = Default + ".Delete"; - public class FileManager - { - public const string Default = AppVersion.Default + ".FileManager"; - - public const string Create = Default + ".Create"; - - public const string Delete = Default + ".Delete"; + public const string Update = Default + ".Update"; - public const string Download = Default + ".Download"; - } + public const string ManageBlobs = Default + ".ManageBlobs"; } public static string[] GetAll() diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionCreateDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionCreateDto.cs deleted file mode 100644 index e3daff5ce..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionCreateDto.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace LINGYUN.Platform.Versions -{ - public class VersionCreateDto - { - /// - /// 标题 - /// - [Required] - [StringLength(AppVersionConsts.MaxTitleLength)] - public string Title { get; set; } - /// - /// 版本号 - /// - [Required] - [StringLength(AppVersionConsts.MaxVersionLength)] - public string Version { get; set; } - /// - /// 描述 - /// - [StringLength(AppVersionConsts.MaxDescriptionLength)] - public string Description { get; set; } - /// - /// 适应平台 - /// - public PlatformType PlatformType { get; set; } = PlatformType.None; - /// - /// 重要级别 - /// - public ImportantLevel Level { get; set; } = ImportantLevel.Low; - } -} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionDeleteDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionDeleteDto.cs deleted file mode 100644 index 6385684f2..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionDeleteDto.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace LINGYUN.Platform.Versions -{ - public class VersionDeleteDto - { - [Required] - [StringLength(AppVersionConsts.MaxVersionLength)] - public string Version { get; set; } - - public PlatformType PlatformType { get; set; } - } -} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionDto.cs deleted file mode 100644 index 2b06d44a5..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionDto.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using Volo.Abp.Application.Dtos; - -namespace LINGYUN.Platform.Versions -{ - public class VersionDto : EntityDto - { - /// - /// 创建日期 - /// - public DateTime CreationTime { get; set; } - /// - /// 标题 - /// - public string Title { get; set; } - /// - /// 版本号 - /// - public string Version { get; set; } - /// - /// 描述 - /// - public string Description { get; set; } - /// - /// 重要级别 - /// - public ImportantLevel Level { get; set; } - /// - /// 文件列表 - /// - public List Files { get; set; } = new List(); - } -} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileCreateDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileCreateDto.cs deleted file mode 100644 index cc9bdb714..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileCreateDto.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Newtonsoft.Json; -using System; -using System.ComponentModel.DataAnnotations; - -namespace LINGYUN.Platform.Versions -{ - public class VersionFileCreateDto - { - [Required] - public Guid VersionId { get; set; } - - [Required] - [StringLength(AppVersionConsts.MaxVersionLength)] - public string Version { get; set; } - /// - /// 文件路径 - /// - [StringLength(VersionFileConsts.MaxPathLength)] - public string FilePath { get; set; } - /// - /// 文件名称 - /// - [Required] - [StringLength(VersionFileConsts.MaxNameLength)] - public string FileName { get; set; } - /// - /// 文件版本 - /// - [Required] - [StringLength(VersionFileConsts.MaxVersionLength)] - public string FileVersion { get; set; } - /// - /// 当前字节数 - /// - [Required] - public int CurrentByte { get; set; } - /// - /// 最大字节数 - /// - [Required] - public int TotalByte { get; set; } - /// - /// 文件类型 - /// - public FileType FileType { get; set; } - /// - /// 文件指纹 - /// - public string SHA256 { get; set; } - } -} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileDeleteDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileDeleteDto.cs deleted file mode 100644 index 9d6ed39f9..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileDeleteDto.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations; - -namespace LINGYUN.Platform.Versions -{ - public class VersionFileDeleteDto - { - [Required] - public Guid VersionId { get; set; } - - [Required] - [StringLength(VersionFileConsts.MaxNameLength)] - public string FileName { get; set; } - } -} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileDto.cs deleted file mode 100644 index 3bb440a1b..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileDto.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Newtonsoft.Json; - -namespace LINGYUN.Platform.Versions -{ - public class VersionFileDto - { - /// - /// 文件路径 - /// - public string Path { get; set; } - /// - /// 文件名称 - /// - public string Name { get; set; } - /// - /// 文件版本 - /// - public string Version { get; set; } - /// - /// 文件SHA256编码 - /// - public string SHA256 { get; set; } - /// - /// 文件大小 - /// 单位b - /// - public long Size { get; set; } - /// - /// 文件类型 - /// - public FileType FileType { get; set; } - } -} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileGetDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileGetDto.cs deleted file mode 100644 index 35a57ffb5..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileGetDto.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace LINGYUN.Platform.Versions -{ - public class VersionFileGetDto - { - public PlatformType PlatformType { get; set; } = PlatformType.None; - - [Required] - [StringLength(AppVersionConsts.MaxVersionLength)] - public string Version { get; set; } - - [StringLength(VersionFileConsts.MaxPathLength)] - public string FilePath { get; set; } - - [Required] - [StringLength(VersionFileConsts.MaxNameLength)] - public string FileName { get; set; } - - [Required] - [StringLength(VersionFileConsts.MaxVersionLength)] - public string FileVersion { get; set; } - } -} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionGetByIdDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionGetByIdDto.cs deleted file mode 100644 index 2b4d24ebf..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionGetByIdDto.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; -using Volo.Abp.Application.Dtos; - -namespace LINGYUN.Platform.Versions -{ - public class VersionGetByIdDto : EntityDto - { - } -} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionGetByPagedDto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionGetByPagedDto.cs deleted file mode 100644 index affb65e1a..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionGetByPagedDto.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Volo.Abp.Application.Dtos; - -namespace LINGYUN.Platform.Versions -{ - public class VersionGetByPagedDto : PagedAndSortedResultRequestDto - { - public string Filter { get; set; } - public PlatformType PlatformType { get; set; } = PlatformType.None; - } -} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/IVersionAppService.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/IVersionAppService.cs deleted file mode 100644 index 7b6f066cb..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/IVersionAppService.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Threading.Tasks; -using Volo.Abp.Application.Dtos; -using Volo.Abp.Application.Services; - -namespace LINGYUN.Platform.Versions -{ - public interface IVersionAppService : IApplicationService - { - Task GetLastestAsync(PlatformType platformType); - - Task> GetAsync(VersionGetByPagedDto versionGetByPaged); - - Task GetAsync(VersionGetByIdDto versionGetById); - - Task CreateAsync(VersionCreateDto versionCreate); - - Task DeleteAsync(VersionDeleteDto versionDelete); - - Task AppendFileAsync(VersionFileCreateDto versionFileCreate); - - Task RemoveFileAsync(VersionFileDeleteDto versionFileDelete); - - Task RemoveAllFileAsync(VersionGetByIdDto versionGetById); - - Task DownloadFileAsync(VersionFileGetDto versionFileGet); - } -} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Packages/PackageAppService.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Packages/PackageAppService.cs new file mode 100644 index 000000000..0c65bec58 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Packages/PackageAppService.cs @@ -0,0 +1,187 @@ +using LINGYUN.Platform.Permissions; +using Microsoft.AspNetCore.Authorization; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Content; +using Volo.Abp.Data; + +namespace LINGYUN.Platform.Packages; + +public class PackageAppService : PlatformApplicationServiceBase, IPackageAppService +{ + private readonly IPackageBlobManager _blobManager; + private readonly IPackageRepository _packageRepository; + + public PackageAppService( + IPackageBlobManager blobManager, + IPackageRepository packageRepository) + { + _blobManager = blobManager; + _packageRepository = packageRepository; + } + + public async virtual Task GetLatestAsync(PackageGetLatestInput input) + { + var package = await _packageRepository.FindLatestAsync(input.Name); + + return package == null ? PackageDto.None() : ObjectMapper.Map(package); + } + + [Authorize(PlatformPermissions.Package.Create)] + public async virtual Task CreateAsync(PackageCreateDto input) + { + var package = await _packageRepository.FindLatestAsync(input.Name); + if (package != null) + { + if (string.Compare(input.Version, package.Version, StringComparison.CurrentCultureIgnoreCase) <= 0) + { + throw new BusinessException(PlatformErrorCodes.PackageVersionDegraded) + .WithData(nameof(Package.Name), input.Name) + .WithData(nameof(Package.Version), input.Version); + } + } + + package = new Package( + GuidGenerator.Create(), + input.Name, + input.Note, + input.Version, + input.Description, + CurrentTenant.Id); + + UpdateByInput(package, input); + + package = await _packageRepository.InsertAsync(package); + + await CurrentUnitOfWork.SaveChangesAsync(); + + return ObjectMapper.Map(package); + } + + [Authorize(PlatformPermissions.Package.Delete)] + public async virtual Task DeleteAsync(Guid id) + { + await _packageRepository.DeleteAsync(id); + + await CurrentUnitOfWork.SaveChangesAsync(); + } + + [Authorize(PlatformPermissions.Package.ManageBlobs)] + public async virtual Task UploadBlobAsync( + Guid id, + PackageBlobUploadDto input) + { + var package = await _packageRepository.GetAsync(id); + + var packageBlob = package.FindBlob(input.Name); + + if (packageBlob == null) + { + packageBlob = package.CreateBlob( + input.Name, + input.CreatedAt, + input.UpdatedAt, + input.Size ?? input.File.ContentLength, + input.Summary); + + await _blobManager.SaveBlobAsync(package, packageBlob, input.File.GetStream()); + } + + await _packageRepository.UpdateAsync(package); + + await CurrentUnitOfWork.SaveChangesAsync(); + + return ObjectMapper.Map(packageBlob); + } + + [Authorize(PlatformPermissions.Package.ManageBlobs)] + public async virtual Task RemoveBlobAsync( + Guid id, + PackageBlobRemoveDto input) + { + var package = await _packageRepository.GetAsync(id); + + var packageBlob = package.FindBlob(input.Name); + + await _blobManager.RemoveBlobAsync(package, packageBlob); + + package.RemoveBlob(input.Name); + + await CurrentUnitOfWork.SaveChangesAsync(); + } + + public async virtual Task DownloadBlobAsync(Guid id, PackageBlobDownloadInput input) + { + var package = await _packageRepository.GetAsync(id); + var packageBlob = package.FindBlob(input.Name); + + var stream = await _blobManager.DownloadBlobAsync(package, packageBlob); + + return new RemoteStreamContent(stream, packageBlob.Name, packageBlob.ContentType); + } + + public async virtual Task GetAsync(Guid id) + { + var package = await _packageRepository.GetAsync(id); + + return ObjectMapper.Map(package); + } + + [Authorize(PlatformPermissions.Package.Default)] + public async virtual Task> GetListAsync(PackageGetPagedListInput input) + { + var filter = new PackageFilter( + input.Filter, input.Name, input.Note, input.Version, + input.Description, input.ForceUpdate, input.Authors); + + var specification = new PackageSpecification(filter); + + var totalCount = await _packageRepository.GetCountAsync(specification); + var entities = await _packageRepository.GetListAsync(specification); + + return new PagedResultDto( + totalCount, + ObjectMapper.Map, List>(entities)); + } + + [Authorize(PlatformPermissions.Package.Update)] + public async virtual Task UpdateAsync(Guid id, PackageUpdateDto input) + { + var package = await _packageRepository.GetAsync(id); + + UpdateByInput(package, input); + + package.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp); + + package = await _packageRepository.UpdateAsync(package); + + await CurrentUnitOfWork.SaveChangesAsync(); + + return ObjectMapper.Map(package); + } + + protected virtual void UpdateByInput(Package entity, PackageCreateOrUpdateDto input) + { + if (!string.Equals(entity.Note, input.Note, StringComparison.CurrentCultureIgnoreCase)) + { + entity.SetNote(input.Note); + } + + if (!string.Equals(entity.Authors, input.Authors, StringComparison.CurrentCultureIgnoreCase)) + { + entity.Authors = Check.Length(input.Authors, nameof(Package.Authors), PackageConsts.MaxAuthorsLength); + } + + if (!string.Equals(entity.Description, input.Description, StringComparison.CurrentCultureIgnoreCase)) + { + entity.Description = Check.Length(input.Description, nameof(Package.Description), PackageConsts.MaxDescriptionLength); + } + + entity.ForceUpdate = input.ForceUpdate; + entity.Level = input.Level; + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationMappingProfile.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationMappingProfile.cs index f39293e4e..76935198b 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationMappingProfile.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationMappingProfile.cs @@ -2,7 +2,7 @@ using LINGYUN.Platform.Datas; using LINGYUN.Platform.Layouts; using LINGYUN.Platform.Menus; -using LINGYUN.Platform.Versions; +using LINGYUN.Platform.Packages; namespace LINGYUN.Platform { @@ -10,8 +10,8 @@ namespace LINGYUN.Platform { public PlatformApplicationMappingProfile() { - CreateMap(); - CreateMap(); + CreateMap(); + CreateMap(); CreateMap(); CreateMap(); diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Versions/VersionAppService.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Versions/VersionAppService.cs deleted file mode 100644 index 46d77d447..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Versions/VersionAppService.cs +++ /dev/null @@ -1,103 +0,0 @@ -using LINGYUN.Platform.Permissions; -using Microsoft.AspNetCore.Authorization; -using System.Collections.Generic; -using System.Threading.Tasks; -using Volo.Abp; -using Volo.Abp.Application.Dtos; - -namespace LINGYUN.Platform.Versions -{ - [Authorize(PlatformPermissions.AppVersion.Default)] - public class VersionAppService : PlatformApplicationServiceBase, IVersionAppService - { - private readonly VersionManager _versionManager; - public VersionAppService( - VersionManager versionManager) - { - _versionManager = versionManager; - } - - [Authorize(PlatformPermissions.AppVersion.FileManager.Create)] - public async virtual Task AppendFileAsync(VersionFileCreateDto versionFileCreate) - { - await _versionManager.AppendFileAsync(versionFileCreate.VersionId, - versionFileCreate.SHA256, versionFileCreate.FileName, versionFileCreate.FileVersion, - versionFileCreate.TotalByte, versionFileCreate.FilePath, versionFileCreate.FileType); - } - - [Authorize(PlatformPermissions.AppVersion.Create)] - public async virtual Task CreateAsync(VersionCreateDto versionCreate) - { - if (await _versionManager.ExistsAsync(versionCreate.PlatformType,versionCreate.Version)) - { - throw new UserFriendlyException("VersionAlreadyExists"); - } - var version = new AppVersion(GuidGenerator.Create(), versionCreate.Title, - versionCreate.Version, versionCreate.PlatformType, CurrentTenant.Id) - { - Description = versionCreate.Description, - Level = versionCreate.Level - }; - - await _versionManager.CreateAsync(version); - - return ObjectMapper.Map(version); - } - - [Authorize(PlatformPermissions.AppVersion.Delete)] - public async virtual Task DeleteAsync(VersionDeleteDto versionDelete) - { - var version = await _versionManager.GetByVersionAsync(versionDelete.PlatformType, versionDelete.Version); - if (version != null) - { - await _versionManager.DeleteAsync(version.Id); - } - } - - - public async virtual Task> GetAsync(VersionGetByPagedDto versionGetByPaged) - { - var versionCount = await _versionManager.GetCountAsync(versionGetByPaged.PlatformType, versionGetByPaged.Filter); - var versions = await _versionManager.GetPagedListAsync(versionGetByPaged.PlatformType, versionGetByPaged.Filter, - versionGetByPaged.Sorting, true, - versionGetByPaged.SkipCount, versionGetByPaged.MaxResultCount); - - return new PagedResultDto(versionCount, - ObjectMapper.Map, List>(versions)); - } - - - public async virtual Task GetAsync(VersionGetByIdDto versionGetById) - { - var version = await _versionManager.GetByIdAsync(versionGetById.Id); - - return ObjectMapper.Map(version); - } - - public async virtual Task GetLastestAsync(PlatformType platformType) - { - var version = await _versionManager.GetLatestAsync(platformType); - - return ObjectMapper.Map(version); - } - - [Authorize(PlatformPermissions.AppVersion.FileManager.Delete)] - public async virtual Task RemoveAllFileAsync(VersionGetByIdDto versionGetById) - { - await _versionManager.RemoveAllFileAsync(versionGetById.Id); - } - - [Authorize(PlatformPermissions.AppVersion.FileManager.Delete)] - public async virtual Task RemoveFileAsync(VersionFileDeleteDto versionFileDelete) - { - await _versionManager.RemoveFileAsync(versionFileDelete.VersionId, versionFileDelete.FileName); - } - - public virtual Task DownloadFileAsync(VersionFileGetDto versionFileGet) - { - // TODO: 是否需要定义此接口用于 abp-definition-api ? - // overrided implement HttpContext.Response.Body.Write(Stream fileStream) - return Task.CompletedTask; - } - } -} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/en.json b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/en.json index 949faa44f..8416935cb 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/en.json +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/en.json @@ -1,6 +1,7 @@ { "culture": "en", "texts": { + "Platform:01403": "Package {Name} Version {Version} cannot be degraded!", "Platform:01404": "File not found, name: {FileName}, version:{FileVersion}!", "Platform:02001": "The same menu exists in the sibling directory: {Name}!", "Platform:02002": "You are not allowed to delete menu nodes when there are other submenus!", diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/zh-Hans.json b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/zh-Hans.json index 4e03b0e83..bdba3e823 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/zh-Hans.json +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/zh-Hans.json @@ -1,6 +1,7 @@ { "culture": "zh-Hans", "texts": { + "Platform:01403": "包 {Name} 版本 {Version} 不能降级!", "Platform:01404": "文件: {FileName}, 版本号: {FileVersion} 不存在!", "Platform:02001": "同级目录下存在相同的菜单: {Name}!", "Platform:02002": "在有其他子菜单的情况下,不允许删除菜单节点!", diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/ObjectExtending/PlatformModuleExtensionConsts.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/ObjectExtending/PlatformModuleExtensionConsts.cs index b7b7a46b8..8b366e4d5 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/ObjectExtending/PlatformModuleExtensionConsts.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/ObjectExtending/PlatformModuleExtensionConsts.cs @@ -8,7 +8,7 @@ { public const string Route = "Route"; - public const string AppVersion = "AppVersion"; + public const string Package = "Package"; } } } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/ObjectExtending/PlatfromModuleExtensionConfiguration.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/ObjectExtending/PlatfromModuleExtensionConfiguration.cs index 808bb168b..d0d16e06f 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/ObjectExtending/PlatfromModuleExtensionConfiguration.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/ObjectExtending/PlatfromModuleExtensionConfiguration.cs @@ -14,11 +14,11 @@ namespace LINGYUN.Platform.ObjectExtending ); } - public PlatfromModuleExtensionConfiguration ConfigureAppVersion( + public PlatfromModuleExtensionConfiguration ConfigurePackage( Action configureAction) { return this.ConfigureEntity( - PlatformModuleExtensionConsts.EntityNames.AppVersion, + PlatformModuleExtensionConsts.EntityNames.Package, configureAction ); } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Packages/PackageBlobConsts.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Packages/PackageBlobConsts.cs new file mode 100644 index 000000000..ec09e1305 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Packages/PackageBlobConsts.cs @@ -0,0 +1,11 @@ +namespace LINGYUN.Platform.Packages; +public static class PackageBlobConsts +{ + public static int MaxNameLength { get; set; } = 255; + public static int MaxUrlLength { get; set; } = 512; + public static int MaxContentTypeLength { get; set; } = 256; + public static int MaxSummaryLength { get; set; } = 1024; + public static int MaxLicenseLength { get; set; } = 1024; + public static int MaxAuthorsLength { get; set; } = 100; + public static int MaxSHA256Length { get; set; } = 256; +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Packages/PackageConsts.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Packages/PackageConsts.cs new file mode 100644 index 000000000..95be72e3e --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Packages/PackageConsts.cs @@ -0,0 +1,10 @@ +namespace LINGYUN.Platform.Packages; +public static class PackageConsts +{ + public static int MaxNameLength { get; set; } = 255; + public static int MaxNoteLength { get; set; } = 1024; + public static int MaxVersionLength { get; set; } = 30; + public static int MaxDescriptionLength { get; set; } = 255; + public static int MaxPlatformLength { get; set; } = 20; + public static int MaxAuthorsLength { get; set; } = 100; +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Packages/PackageEto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Packages/PackageEto.cs new file mode 100644 index 000000000..caf756db7 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Packages/PackageEto.cs @@ -0,0 +1,24 @@ +using System; +using Volo.Abp.EventBus; +using Volo.Abp.MultiTenancy; + +namespace LINGYUN.Platform.Packages; + +[EventName("platform.packages")] +public class PackageEto : IMultiTenant +{ + public Guid? TenantId { get; set; } + /// + /// 名称 + /// + public string Name { get; set; } + /// + /// 版本 + /// + public string Version { get; set; } + /// + /// 强制更新 + /// + public bool ForceUpdate { get; set; } + public PackageLevel Level { get; set; } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Packages/PackageLevel.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Packages/PackageLevel.cs new file mode 100644 index 000000000..e37873572 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Packages/PackageLevel.cs @@ -0,0 +1,17 @@ +namespace LINGYUN.Platform.Packages; + +public enum PackageLevel +{ + /// + /// 无需更新 + /// + None = -1, + /// + /// 资源 + /// + Resource = 0, + /// + /// 整体 + /// + Full = 1 +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/PlatformErrorCodes.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/PlatformErrorCodes.cs index 3c1e2cb01..42d92cf09 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/PlatformErrorCodes.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/PlatformErrorCodes.cs @@ -5,6 +5,10 @@ private const string Namespace = "Platform"; public const string VersionFileNotFound = Namespace + ":01404"; + /// + /// 包版本不能降级 + /// + public const string PackageVersionDegraded = Namespace + ":01403"; /// /// 同级菜单已经存在 /// diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/AppVersionConsts.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/AppVersionConsts.cs deleted file mode 100644 index 59b6a26e3..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/AppVersionConsts.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace LINGYUN.Platform.Versions -{ - public static class AppVersionConsts - { - public const int MaxTitleLength = 50; - - public const int MaxVersionLength = 20; - - public const int MaxDescriptionLength = 2048; - - public const int DefaultVersionFileLimitLength = 200; - public const string DefaultAllowVersionFileExtensions = "dll,zip,rar,txt,log,xml,config,json,jpeg,jpg,png,bmp,ico,xlsx,xltx,xls,xlt,docs,dots,doc,dot,pptx,potx,ppt,pot,chm"; - } -} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/AppVersionEto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/AppVersionEto.cs deleted file mode 100644 index aa82205e8..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/AppVersionEto.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using Volo.Abp.MultiTenancy; - -namespace LINGYUN.Platform.Versions -{ - public class AppVersionEto : IMultiTenant - { - /// - /// 租户标识 - /// - public Guid? TenantId { get; set; } - /// - /// 标题 - /// - public string Title { get; set; } - /// - /// 版本号 - /// - public string Version { get; set; } - /// - /// 描述 - /// - public string Description { get; set; } - /// - /// 重要级别 - /// - public ImportantLevel Level { get; set; } - /// - /// 文件数量 - /// - public int FileCount { get; set; } - } -} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/FileType.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/FileType.cs deleted file mode 100644 index 195eb3f90..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/FileType.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace LINGYUN.Platform.Versions -{ - /// - /// 文件类型 - /// - public enum FileType - { - /// - /// 普通文件流 - /// - Stream = 0, - /// - /// 压缩文件 - /// - Zip = 1, - /// - /// 脚本文件 - /// - Scripts = 2 - } -} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/IVersionFileManager.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/IVersionFileManager.cs deleted file mode 100644 index ce3490eca..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/IVersionFileManager.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.IO; -using System.Threading.Tasks; - -namespace LINGYUN.Platform.Versions -{ - public interface IVersionFileManager - { - Task SaveFileAsync(string version, string filePath, string fileName, string fileVersion, byte[] data); - Task DownloadFileAsync(PlatformType platformType, string version, string filePath, string fileName, string fileVersion); - } -} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/ImportantLevel.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/ImportantLevel.cs deleted file mode 100644 index 72db7a119..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/ImportantLevel.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace LINGYUN.Platform.Versions -{ - public enum ImportantLevel - { - /// - /// 未定义 - /// - None = -1, - /// - /// 低 - /// - Low = 0, - /// - /// 高 - /// - High = 1, - /// - /// 重要 - /// - Matter - } -} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/VersionFileConsts.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/VersionFileConsts.cs deleted file mode 100644 index 13cdf3528..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/VersionFileConsts.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace LINGYUN.Platform.Versions -{ - public static class VersionFileConsts - { - public const int MaxNameLength = 255; - - public const int MaxPathLength = 255; - - public const int MaxVersionLength = 20; - - public const int MaxSHA256Length = 65; - } -} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/FileSystemPackageBlobNormalizer.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/FileSystemPackageBlobNormalizer.cs new file mode 100644 index 000000000..b2f0fef6c --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/FileSystemPackageBlobNormalizer.cs @@ -0,0 +1,20 @@ +using System.IO; +using Volo.Abp.DependencyInjection; + +namespace LINGYUN.Platform.Packages; + +public class FileSystemPackageBlobNormalizer : IPackageBlobNormalizer, ISingletonDependency +{ + public FileSystemPackageBlobNormalizer() + { + + } + + public string Normalize(Package package, PackageBlob blob) + { + var pk = package.Name; + var pv = package.Version; + + return Path.Combine(pk, "v" + pv, "blobs", blob.Name); + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/IPackageBlobManager.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/IPackageBlobManager.cs new file mode 100644 index 000000000..081cd7f48 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/IPackageBlobManager.cs @@ -0,0 +1,25 @@ +using System.IO; +using System.Threading; +using System.Threading.Tasks; + +namespace LINGYUN.Platform.Packages; + +public interface IPackageBlobManager +{ + Task RemoveBlobAsync( + Package package, + PackageBlob packageBlob, + CancellationToken cancellationToken = default); + + Task SaveBlobAsync( + Package package, + PackageBlob packageBlob, + Stream stream, + bool overrideExisting = true, + CancellationToken cancellationToken = default); + + Task DownloadBlobAsync( + Package package, + PackageBlob packageBlob, + CancellationToken cancellationToken = default); +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/IPackageBlobNormalizer.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/IPackageBlobNormalizer.cs new file mode 100644 index 000000000..fd12a57fa --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/IPackageBlobNormalizer.cs @@ -0,0 +1,6 @@ +namespace LINGYUN.Platform.Packages; + +public interface IPackageBlobNormalizer +{ + string Normalize(Package package, PackageBlob blob); +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/IPackageRepository.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/IPackageRepository.cs new file mode 100644 index 000000000..6acce015b --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/IPackageRepository.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.Specifications; + +namespace LINGYUN.Platform.Packages; + +public interface IPackageRepository : IBasicRepository +{ + Task FindByNameAsync( + string name, + bool includeDetails = true, + CancellationToken cancellationToken = default); + + Task FindLatestAsync( + string name, + bool includeDetails = true, + CancellationToken cancellationToken = default); + + Task GetCountAsync( + Specification specification, + CancellationToken cancellationToken = default); + + Task> GetListAsync( + Specification specification, + string sorting = $"{nameof(Package.Version)} DESC", + int skipCount = 0, + int maxResultCount = 10, + CancellationToken cancellationToken = default); +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/Package.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/Package.cs new file mode 100644 index 000000000..d9e732ea7 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/Package.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Reflection.Emit; +using Volo.Abp; +using Volo.Abp.Data; +using Volo.Abp.Domain.Entities.Auditing; +using Volo.Abp.MultiTenancy; + +namespace LINGYUN.Platform.Packages; + +public class Package : FullAuditedAggregateRoot, IMultiTenant +{ + public virtual Guid? TenantId { get; protected set; } + /// + /// 名称 + /// + public virtual string Name { get; protected set; } + /// + /// 版本说明 + /// + public virtual string Note { get; protected set; } + /// + /// 版本 + /// + public virtual string Version { get; protected set; } + /// + /// 描述 + /// + public virtual string Description { get; set; } + /// + /// 强制更新 + /// + public virtual bool ForceUpdate { get; set; } + + public virtual string Authors { get; set; } + + public virtual PackageLevel Level { get; set; } + + public virtual ICollection Blobs { get; protected set; } + + protected Package() + { + Blobs = new Collection(); + ExtraProperties = new ExtraPropertyDictionary(); + this.SetDefaultsForExtraProperties(); + } + + public Package( + Guid id, + string name, + string note, + string version, + string description = null, + Guid? tenantId = null) + : base(id) + { + Name = Check.NotNullOrWhiteSpace(name, nameof(name), PackageConsts.MaxNameLength); + Note = Check.NotNullOrWhiteSpace(note, nameof(note), PackageConsts.MaxNoteLength); + Version = Check.NotNullOrWhiteSpace(version, nameof(version), PackageConsts.MaxVersionLength); + + Description = Check.Length(description, nameof(description), PackageConsts.MaxDescriptionLength); + TenantId = tenantId; + + Level = PackageLevel.None; + Blobs = new Collection(); + ExtraProperties = new ExtraPropertyDictionary(); + this.SetDefaultsForExtraProperties(); + } + + public void SetNote(string note) + { + Note = Check.NotNullOrWhiteSpace(note, nameof(note), PackageConsts.MaxNoteLength); + } + + public PackageBlob CreateBlob( + string name, + DateTime createdAt, + DateTime? updatedAt = null, + long? size = null, + string summary = null) + { + var findBlob = FindBlob(name); + if (findBlob == null) + { + findBlob = new PackageBlob( + Id, + name, + createdAt, + updatedAt, + size, + summary, + TenantId); + Blobs.Add(findBlob); + } + return findBlob; + } + + public PackageBlob FindBlob(string name) + { + return Blobs.FirstOrDefault(x => x.Name == name); + } + + public void RemoveBlob(string name) + { + Blobs.RemoveAll(x => x.Name == name); + } + + public void ClearBlob() + { + Blobs.Clear(); + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/PackageBlob.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/PackageBlob.cs new file mode 100644 index 000000000..be13d93fd --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/PackageBlob.cs @@ -0,0 +1,64 @@ +using System; +using Volo.Abp; +using Volo.Abp.Data; +using Volo.Abp.Domain.Entities.Auditing; +using Volo.Abp.MultiTenancy; + +namespace LINGYUN.Platform.Packages; + +public class PackageBlob : CreationAuditedEntity, IMultiTenant, IHasExtraProperties +{ + public virtual Guid? TenantId { get; protected set; } + public virtual Guid PackageId { get; private set; } + public virtual Package Package { get; private set; } + public virtual string Name { get; protected set; } + public virtual string Url { get; protected set; } + public virtual long? Size { get; protected set; } + public virtual string Summary { get; protected set; } + public virtual DateTime CreatedAt { get; protected set; } + public virtual DateTime? UpdatedAt { get; protected set; } + public virtual string License { get; set; } + public virtual string Authors { get; set; } + public virtual string ContentType { get; set; } + public virtual string SHA256 { get; set; } + public virtual int DownloadCount { get; protected set; } + public virtual ExtraPropertyDictionary ExtraProperties { get; set; } + + protected PackageBlob() + { + ExtraProperties = new ExtraPropertyDictionary(); + this.SetDefaultsForExtraProperties(); + } + + internal PackageBlob( + Guid packageId, + string name, + DateTime createdAt, + DateTime? updatedAt = null, + long? size = null, + string summary = null, + Guid? tenantId = null) + { + PackageId = packageId; + Name = Check.NotNullOrWhiteSpace(name, nameof(name), PackageBlobConsts.MaxNameLength); + CreatedAt = createdAt; + UpdatedAt = updatedAt; + Size = size; + Summary = Check.Length(summary, nameof(summary), PackageBlobConsts.MaxSummaryLength); + TenantId = tenantId; + DownloadCount = 0; + + ExtraProperties = new ExtraPropertyDictionary(); + this.SetDefaultsForExtraProperties(); + } + + public void SetUrl(string url) + { + Url = Check.NotNullOrWhiteSpace(url, nameof(url), PackageBlobConsts.MaxUrlLength); + } + + public void Download() + { + DownloadCount += 1; + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/PackageBlobManager.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/PackageBlobManager.cs new file mode 100644 index 000000000..8fe7a2c54 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/PackageBlobManager.cs @@ -0,0 +1,94 @@ +using System; +using System.IO; +using System.Security.Cryptography; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.BlobStoring; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Domain.Services; + +namespace LINGYUN.Platform.Packages; + +[Dependency(TryRegister = true)] +public class PackageBlobManager : DomainService, IPackageBlobManager, ITransientDependency +{ + protected IPackageBlobNormalizer BlobNormalizer { get; } + protected IBlobContainer PackageContainer { get; } + + public PackageBlobManager( + IPackageBlobNormalizer blobNormalizer, + IBlobContainer packageContainer) + { + BlobNormalizer = blobNormalizer; + PackageContainer = packageContainer; + } + + public async virtual Task RemoveBlobAsync( + Package package, + PackageBlob packageBlob, + CancellationToken cancellationToken = default) + { + var blobName = BlobNormalizer.Normalize(package, packageBlob); + + await RemoveBlobAsync(blobName); + } + + public async virtual Task DownloadBlobAsync( + Package package, + PackageBlob packageBlob, + CancellationToken cancellationToken = default) + { + packageBlob.Download(); + + return await DownloadFromBlobAsync(package, packageBlob); + } + + public async virtual Task SaveBlobAsync( + Package package, + PackageBlob packageBlob, + Stream stream, + bool overrideExisting = true, + CancellationToken cancellationToken = default) + { + var blobName = BlobNormalizer.Normalize(package, packageBlob); + + await SaveToBlobAsync(blobName, stream, overrideExisting, cancellationToken); + + stream.Seek(0, SeekOrigin.Begin); + packageBlob.SHA256 = ComputeHash(stream); + packageBlob.SetUrl($"api/platform/packages/{packageBlob.PackageId}/blob/{packageBlob.Name}"); + } + + protected async virtual Task DownloadFromBlobAsync( + Package package, + PackageBlob packageBlob, + CancellationToken cancellationToken = default) + { + var blobName = BlobNormalizer.Normalize(package, packageBlob); + + return await PackageContainer.GetAsync(blobName); + } + + protected async virtual Task SaveToBlobAsync( + string blobName, + Stream stream, + bool overrideExisting = true, + CancellationToken cancellationToken = default) + { + await PackageContainer.SaveAsync(blobName, stream, overrideExisting, cancellationToken); + } + + protected async virtual Task RemoveBlobAsync( + string blobName, + CancellationToken cancellationToken = default) + { + await PackageContainer.DeleteAsync(blobName, cancellationToken); + } + + protected virtual string ComputeHash(Stream stream) + { + using var sha256 = SHA256.Create(); + var checkHash = sha256.ComputeHash(stream); + return BitConverter.ToString(checkHash).Replace("-", string.Empty); + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/PackageContainer.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/PackageContainer.cs new file mode 100644 index 000000000..8caa50be2 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/PackageContainer.cs @@ -0,0 +1,8 @@ +using Volo.Abp.BlobStoring; + +namespace LINGYUN.Platform.Packages; + +[BlobContainerName("packages")] +public class PackageContainer +{ +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/PackageFilter.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/PackageFilter.cs new file mode 100644 index 000000000..fd05d0678 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/PackageFilter.cs @@ -0,0 +1,36 @@ +namespace LINGYUN.Platform.Packages; + +public class PackageFilter +{ + public string Filter { get; set; } + + public string Name { get; set; } + + public string Note { get; set; } + + public string Version { get; set; } + + public string Description { get; set; } + + public bool? ForceUpdate { get; set; } + + public string Authors { get; set; } + + public PackageFilter( + string filter = null, + string name = null, + string note = null, + string version = null, + string description = null, + bool? forceUpdate = null, + string authors = null) + { + Filter = filter; + Name = name; + Note = note; + Version = version; + Description = description; + ForceUpdate = forceUpdate; + Authors = authors; + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/PackageSpecification.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/PackageSpecification.cs new file mode 100644 index 000000000..30acae3a3 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Packages/PackageSpecification.cs @@ -0,0 +1,31 @@ +using System; +using System.Linq.Expressions; +using Volo.Abp.Specifications; + +namespace LINGYUN.Platform.Packages; + +public class PackageSpecification : Specification +{ + protected PackageFilter Filter { get; } + + public PackageSpecification(PackageFilter filter) + { + Filter = filter; + } + + public override Expression> ToExpression() + { + Expression> expression = (p) => true; + + return expression + .AndIf(!Filter.Name.IsNullOrWhiteSpace(), x => x.Name == Filter.Name) + .AndIf(!Filter.Note.IsNullOrWhiteSpace(), x => x.Note == Filter.Note) + .AndIf(!Filter.Version.IsNullOrWhiteSpace(), x => x.Version == Filter.Version) + .AndIf(!Filter.Description.IsNullOrWhiteSpace(), x => x.Description == Filter.Description) + .AndIf(!Filter.Authors.IsNullOrWhiteSpace(), x => x.Authors == Filter.Authors) + .AndIf(Filter.ForceUpdate.HasValue, x => x.ForceUpdate == Filter.ForceUpdate) + .AndIf(!Filter.Filter.IsNullOrWhiteSpace(), x => x.Name.Contains(Filter.Filter) || + x.Note.Contains(Filter.Filter) || x.Version.Contains(Filter.Filter) || + x.Description.Contains(Filter.Filter) || x.Authors.Contains(Filter.Filter)); + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/PlatformDomainMappingProfile.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/PlatformDomainMappingProfile.cs index 31949f32f..9c5bb86a2 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/PlatformDomainMappingProfile.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/PlatformDomainMappingProfile.cs @@ -1,8 +1,7 @@ using AutoMapper; using LINGYUN.Platform.Layouts; using LINGYUN.Platform.Menus; -using LINGYUN.Platform.Routes; -using LINGYUN.Platform.Versions; +using LINGYUN.Platform.Packages; namespace LINGYUN.Platform { @@ -16,8 +15,7 @@ namespace LINGYUN.Platform CreateMap(); CreateMap(); - CreateMap() - .ForMember(eto => eto.FileCount, map => map.MapFrom(src => src.Files.Count)); + CreateMap(); } } } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/PlatformDomainModule.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/PlatformDomainModule.cs index 71825dd44..664a8aa32 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/PlatformDomainModule.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/PlatformDomainModule.cs @@ -2,8 +2,8 @@ using LINGYUN.Platform.Layouts; using LINGYUN.Platform.Menus; using LINGYUN.Platform.ObjectExtending; +using LINGYUN.Platform.Packages; using LINGYUN.Platform.Routes; -using LINGYUN.Platform.Versions; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.AutoMapper; using Volo.Abp.BlobStoring; @@ -36,7 +36,7 @@ namespace LINGYUN.Platform Configure(options => { - options.Containers.Configure(containerConfiguration => + options.Containers.Configure(containerConfiguration => { containerConfiguration.IsMultiTenant = true; }); @@ -48,9 +48,9 @@ namespace LINGYUN.Platform options.EtoMappings.Add(typeof(PlatformDomainModule)); options.EtoMappings.Add(typeof(PlatformDomainModule)); - options.EtoMappings.Add(typeof(PlatformDomainModule)); - - options.EtoMappings.Add(typeof(PlatformDomainModule)); + options.EtoMappings.Add(typeof(PlatformDomainModule)); + + options.EtoMappings.Add(typeof(PlatformDomainModule)); }); } public override void PostConfigureServices(ServiceConfigurationContext context) @@ -62,8 +62,8 @@ namespace LINGYUN.Platform ); ModuleExtensionConfigurationHelper.ApplyEntityConfigurationToEntity( PlatformModuleExtensionConsts.ModuleName, - PlatformModuleExtensionConsts.EntityNames.AppVersion, - typeof(AppVersion) + PlatformModuleExtensionConsts.EntityNames.Package, + typeof(Package) ); } } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Settings/PlatformSettingDefinitionProvider.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Settings/PlatformSettingDefinitionProvider.cs index b061be178..d83fa45b9 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Settings/PlatformSettingDefinitionProvider.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Settings/PlatformSettingDefinitionProvider.cs @@ -1,5 +1,4 @@ using LINGYUN.Platform.Localization; -using LINGYUN.Platform.Versions; using Volo.Abp.Localization; using Volo.Abp.Settings; @@ -9,36 +8,12 @@ namespace LINGYUN.Platform.Settings { public override void Define(ISettingDefinitionContext context) { - context.Add(CreateAppVersionSettings()); + context.Add(CreateDefaultSettings()); } - protected SettingDefinition[] CreateAppVersionSettings() + protected SettingDefinition[] CreateDefaultSettings() { - return new SettingDefinition[] - { - new SettingDefinition( - name: PlatformSettingNames.AppVersion.VersionFileLimitLength, - defaultValue: AppVersionConsts.DefaultVersionFileLimitLength.ToString(), - displayName: L("DisplayName:VersionFileLimitLength"), - description: L("Description:VersionFileLimitLength"), - isVisibleToClients: true) - .WithProviders( - DefaultValueSettingValueProvider.ProviderName, - ConfigurationSettingValueProvider.ProviderName, - GlobalSettingValueProvider.ProviderName, - TenantSettingValueProvider.ProviderName), - new SettingDefinition( - name: PlatformSettingNames.AppVersion.AllowVersionFileExtensions, - defaultValue: AppVersionConsts.DefaultAllowVersionFileExtensions, - displayName: L("DisplayName:AllowVersionFileExtensions"), - description: L("Description:AllowVersionFileExtensions"), - isVisibleToClients: true) - .WithProviders( - DefaultValueSettingValueProvider.ProviderName, - ConfigurationSettingValueProvider.ProviderName, - GlobalSettingValueProvider.ProviderName, - TenantSettingValueProvider.ProviderName), - }; + return new SettingDefinition[0]; } protected LocalizableString L(string name) diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/AppVersion.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/AppVersion.cs deleted file mode 100644 index 82827fdc6..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/AppVersion.cs +++ /dev/null @@ -1,116 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Volo.Abp.Domain.Entities.Auditing; -using Volo.Abp.MultiTenancy; - -namespace LINGYUN.Platform.Versions -{ - /// - /// 应用版本号 - /// - public class AppVersion : FullAuditedAggregateRoot, IMultiTenant - { - /// - /// 租户标识 - /// - public virtual Guid? TenantId { get; protected set; } - /// - /// 标题 - /// - public virtual string Title { get; protected set; } - /// - /// 版本号 - /// - public virtual string Version { get; protected set; } - /// - /// 描述 - /// - public virtual string Description { get; set; } - /// - /// 重要级别 - /// - public virtual ImportantLevel Level { get; set; } - /// - /// 适应平台 - /// - public virtual PlatformType PlatformType { get; protected set; } - /// - /// 版本文件列表 - /// - public virtual ICollection Files { get; protected set; } - - protected AppVersion() - { - Files = new List(); - } - - public AppVersion(Guid id, string title, string version, PlatformType platformType = PlatformType.None, Guid? tenantId = null) - { - Id = id; - Title = title; - Version = version; - TenantId = tenantId; - PlatformType = platformType; - Level = ImportantLevel.Low; - } - - public void AppendFile(string name, string version, long size, string sha256, - string filePath = "", FileType fileType = FileType.Stream) - { - if (!FileExists(name)) - { - var versionFile = new VersionFile(name, version, size, sha256, fileType, TenantId) - { - Path = filePath - }; - Files.Add(versionFile); - } - } - - public void RemoveFile(string name) - { - Files.RemoveAll(x => x.Name.Equals(name)); - } - - public void RemoveAllFile() - { - Files.Clear(); - } - - public void ChangeFileVersion(string name, string version, long size, string sha256) - { - if (FileExists(name)) - { - var file = FindFile(name); - file.ChangeVersion(version, size, sha256); - } - } - - public VersionFile FindFile(string name) - { - return Files.Where(x => x.Name.Equals(name)).FirstOrDefault(); - } - - public VersionFile FindFile(string path, string name) - { - return Files.Where(x => x.Path.Equals(path) && x.Name.Equals(name)).FirstOrDefault(); - } - - public VersionFile FindFile(string path, string name, string version) - { - return Files.Where(x => x.Path.Equals(path) && x.Name.Equals(name) && x.Version.Equals(version)) - .FirstOrDefault(); - } - - public bool FileExists(string name) - { - // TODO: Windows file system ? - //if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - //{ - // return Files.Any(x => x.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase)); - //} - return Files.Any(x => x.Name.Equals(name)); - } - } -} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/IVersionRepository.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/IVersionRepository.cs deleted file mode 100644 index 19c847bbf..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/IVersionRepository.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using Volo.Abp.Domain.Repositories; - -namespace LINGYUN.Platform.Versions -{ - public interface IVersionRepository : IBasicRepository - { - Task ExistsAsync(PlatformType platformType, string version, CancellationToken cancellationToken = default); - - Task GetByVersionAsync(PlatformType platformType, string version, CancellationToken cancellationToken = default); - - Task GetCountAsync(PlatformType platformType, string filter = "", CancellationToken cancellationToken = default); - - Task> GetPagedListAsync(PlatformType platformType, string filter = "", string soring = nameof(AppVersion.CreationTime), bool includeDetails = true, int skipCount = 1, int maxResultCount = 10, CancellationToken cancellationToken = default); - - Task GetLatestVersionAsync(PlatformType platformType, CancellationToken cancellationToken = default); - } -} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/VersionContainer.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/VersionContainer.cs deleted file mode 100644 index 214fe1c3c..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/VersionContainer.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Volo.Abp.BlobStoring; - -namespace LINGYUN.Platform.Versions -{ - [BlobContainerName("app-platform-version")] - public class VersionContainer - { - } -} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/VersionFile.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/VersionFile.cs deleted file mode 100644 index a118b7110..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/VersionFile.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System; -using Volo.Abp.Domain.Entities.Auditing; -using Volo.Abp.IO; -using Volo.Abp.MultiTenancy; - -namespace LINGYUN.Platform.Versions -{ - public class VersionFile : AuditedEntity, IMultiTenant - { - /// - /// 租户标识 - /// - public virtual Guid? TenantId { get; protected set; } - /// - /// 文件路径 - /// - public virtual string Path { get; set; } - /// - /// 文件名称 - /// - public virtual string Name { get; protected set; } - /// - /// 文件版本 - /// - public virtual string Version { get; protected set; } - /// - /// 文件大小 - /// 单位b - /// - public virtual long Size { get; protected set; } - /// - /// 文件类型 - /// - public virtual FileType FileType { get; protected set; } - /// - /// 文件SHA256编码 - /// - public virtual string SHA256 { get; protected set; } - /// - /// 下载次数 - /// - public virtual int DownloadCount { get; protected set; } - /// - /// 应用版本标识 - /// - public virtual Guid AppVersionId { get; protected set; } - /// - /// 所属应用版本号 - /// - public virtual AppVersion AppVersion { get; protected set; } - protected VersionFile() - { - - } - - public VersionFile(string name, string version, long size, string sha256, FileType fileType = FileType.Stream, Guid? tenantId = null) - { - Name = name; - FileType = fileType; - TenantId = tenantId; - ChangeVersion(version, size, sha256); - } - - public void ChangeVersion(string version, long size, string sha256) - { - Size = size; - SHA256 = sha256; - Version = version; - } - - public void Download() - { - DownloadCount += 1; - } - - public static string NormalizeBlobName(string appVersion, string fileName, string fileVersion, - string filePath = "") - { - var fileNameWithNotExten = fileName; - // 取出文件扩展名 - var fileExten = FileHelper.GetExtension(fileName); - if (!fileExten.IsNullOrWhiteSpace()) - { - // 取出不带扩展名的文件名 - fileNameWithNotExten = fileName.Replace(fileExten, ""); - // 去掉最后一位扩展名符号 - fileNameWithNotExten = fileNameWithNotExten.Remove(fileNameWithNotExten.Length - 1); - } - // 转换不受支持的符号 - fileNameWithNotExten = fileNameWithNotExten.Replace(".", "-"); - - //路径存储模式 如果传递了绝对路径,需要计算短路径 - if (!filePath.IsNullOrWhiteSpace()) - { - return $"{appVersion}/{filePath.Md5()}/{fileNameWithNotExten}/{fileVersion}/{fileName}"; - } - // 最终文件名为 应用版本号/文件名(不带扩展名)/文件版本/文件名 - // 例: 1.0.0.0/test-upload-text-file/1.0.0.0/test-upload-text-file.text - return $"{appVersion}/{fileNameWithNotExten}/{fileVersion}/{fileName}"; - } - } -} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/VersionManager.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/VersionManager.cs deleted file mode 100644 index 104814e2a..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/VersionManager.cs +++ /dev/null @@ -1,153 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Security.Cryptography; -using System.Threading.Tasks; -using Volo.Abp; -using Volo.Abp.BlobStoring; -using Volo.Abp.DependencyInjection; -using Volo.Abp.Domain.Services; -using Volo.Abp.Uow; - -namespace LINGYUN.Platform.Versions -{ - [Dependency(Microsoft.Extensions.DependencyInjection.ServiceLifetime.Transient)] - [ExposeServices(typeof(IVersionFileManager), typeof(VersionManager))] - public class VersionManager : DomainService, IVersionFileManager - { - protected IVersionRepository VersionRepository { get; } - protected IBlobContainer VersionBlobContainer { get; } - - public VersionManager( - IBlobContainer container, - IVersionRepository versionRepository) - { - VersionBlobContainer = container; - VersionRepository = versionRepository; - } - - public async virtual Task ExistsAsync(PlatformType platformType, string version) - { - return await VersionRepository.ExistsAsync(platformType, version); - } - - public async virtual Task GetByIdAsync(Guid id) - { - return await VersionRepository.GetAsync(id); - } - - public async virtual Task GetByVersionAsync(PlatformType platformType, string version) - { - return await VersionRepository.GetByVersionAsync(platformType, version); - } - - public async virtual Task GetCountAsync(PlatformType platformType, string filter) - { - return await VersionRepository.GetCountAsync(platformType, filter); - } - - public async virtual Task> GetPagedListAsync(PlatformType platformType, string filter = "", string soring = nameof(AppVersion.CreationTime), bool includeDetails = true, int skipCount = 1, int maxResultCount = 10) - { - return await VersionRepository.GetPagedListAsync(platformType, filter, soring, includeDetails, skipCount, maxResultCount); - } - - [UnitOfWork] - public async virtual Task CreateAsync(AppVersion version) - { - await VersionRepository.InsertAsync(version); - } - - - [UnitOfWork] - public async virtual Task UpdateAsync(AppVersion version) - { - await VersionRepository.UpdateAsync(version); - } - - [UnitOfWork] - public async virtual Task DeleteAsync(Guid id) - { - await RemoveAllFileAsync(id); - await VersionRepository.DeleteAsync(id); - } - - public async virtual Task GetLatestAsync(PlatformType platformType) - { - return await VersionRepository.GetLatestVersionAsync(platformType); - } - - public async virtual Task DownloadFileAsync(PlatformType platformType, string version, string filePath, string fileName, string fileVersion) - { - var appVersion = await GetByVersionAsync(platformType, version); - var versionFile = appVersion.FindFile(filePath, fileName, fileVersion); - if (versionFile == null) - { - throw new BusinessException(PlatformErrorCodes.VersionFileNotFound) - .WithData("FileName", fileName) - .WithData("FileVersion", fileVersion); - } - versionFile.Download(); - return await VersionBlobContainer.GetAsync( - VersionFile.NormalizeBlobName(version, versionFile.Name, versionFile.Version, versionFile.Path)); - } - - public async virtual Task GetFileAsync(VersionFile versionFile) - { - versionFile.Download(); - return await VersionBlobContainer.GetAsync( - VersionFile.NormalizeBlobName(versionFile.AppVersion.Version, versionFile.Name, versionFile.Version, versionFile.Path)); - } - - public async virtual Task SaveFileAsync(string version, string filePath, string fileName, string fileVersion, byte[] data) - { - // 计算指纹 - var sha256 = SHA256.Create(); - var checkHash = sha256.ComputeHash(data); - var sha256Hash = BitConverter.ToString(checkHash).Replace("-", string.Empty); - - await VersionBlobContainer - .SaveAsync(VersionFile.NormalizeBlobName(version, fileName, fileVersion, filePath), data, true); - - return sha256Hash; - } - - [UnitOfWork] - public async virtual Task AppendFileAsync(Guid versionId, string fileSha256, - string fileName, string fileVersion, - long fileSize, string filePath = "", - FileType fileType = FileType.Stream) - { - var appVersion = await VersionRepository.GetAsync(versionId); - if (appVersion.FileExists(fileName)) - { - appVersion.RemoveFile(fileName); - } - appVersion.AppendFile(fileName, fileVersion, fileSize, fileSha256, filePath, fileType); - } - - [UnitOfWork] - public async virtual Task RemoveFileAsync(Guid versionId, string fileName) - { - var appVersion = await VersionRepository.GetAsync(versionId); - var versionFile = appVersion.FindFile(fileName); - if (versionFile != null) - { - await VersionBlobContainer - .DeleteAsync(VersionFile.NormalizeBlobName(appVersion.Version, versionFile.Name, versionFile.Version)); - appVersion.RemoveFile(fileName); - } - } - - [UnitOfWork] - public async virtual Task RemoveAllFileAsync(Guid versionId) - { - var appVersion = await VersionRepository.GetAsync(versionId); - foreach (var versionFile in appVersion.Files) - { - await VersionBlobContainer - .DeleteAsync(VersionFile.NormalizeBlobName(appVersion.Version, versionFile.Name, versionFile.Version)); - } - appVersion.RemoveAllFile(); - } - } -} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/System/Linq/Expressions/ExpressionFuncExtensions.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/System/Linq/Expressions/ExpressionFuncExtensions.cs new file mode 100644 index 000000000..74e3c828a --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/System/Linq/Expressions/ExpressionFuncExtensions.cs @@ -0,0 +1,32 @@ +using Volo.Abp.Specifications; + +namespace System.Linq.Expressions; + +internal static class ExpressionFuncExtensions +{ + public static Expression> AndIf( + this Expression> first, + bool condition, + Expression> second) + { + if (condition) + { + return ExpressionFuncExtender.And(first, second); + } + + return first; + } + + public static Expression> OrIf( + this Expression> first, + bool condition, + Expression> second) + { + if (condition) + { + return ExpressionFuncExtender.Or(first, second); + } + + return first; + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/IPlatformDbContext.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/IPlatformDbContext.cs index e2b00534b..675f3eb06 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/IPlatformDbContext.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/IPlatformDbContext.cs @@ -1,7 +1,7 @@ using LINGYUN.Platform.Datas; using LINGYUN.Platform.Layouts; using LINGYUN.Platform.Menus; -using LINGYUN.Platform.Versions; +using LINGYUN.Platform.Packages; using Microsoft.EntityFrameworkCore; using Volo.Abp.Data; using Volo.Abp.EntityFrameworkCore; @@ -14,6 +14,6 @@ namespace LINGYUN.Platform.EntityFrameworkCore DbSet Menus { get; set; } DbSet Layouts { get; set; } DbSet Datas { get; set; } - DbSet AppVersions { get; set; } + DbSet Packages { get; set; } } } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContext.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContext.cs index 9bba7f23b..db9aa5b5c 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContext.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContext.cs @@ -1,7 +1,7 @@ using LINGYUN.Platform.Datas; using LINGYUN.Platform.Layouts; using LINGYUN.Platform.Menus; -using LINGYUN.Platform.Versions; +using LINGYUN.Platform.Packages; using Microsoft.EntityFrameworkCore; using Volo.Abp.Data; using Volo.Abp.EntityFrameworkCore; @@ -14,8 +14,7 @@ namespace LINGYUN.Platform.EntityFrameworkCore public DbSet Menus { get; set; } public DbSet Layouts { get; set; } public DbSet Datas { get; set; } - - public DbSet AppVersions { get; set; } + public DbSet Packages { get; set; } public PlatformDbContext(DbContextOptions options) : base(options) diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContextModelBuilderExtensions.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContextModelBuilderExtensions.cs index d4de4b1db..b83cd932b 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContextModelBuilderExtensions.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContextModelBuilderExtensions.cs @@ -2,8 +2,8 @@ using LINGYUN.Platform.Datas; using LINGYUN.Platform.Layouts; using LINGYUN.Platform.Menus; +using LINGYUN.Platform.Packages; using LINGYUN.Platform.Routes; -using LINGYUN.Platform.Versions; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using System; @@ -174,61 +174,72 @@ namespace LINGYUN.Platform.EntityFrameworkCore x.HasIndex(i => new { i.Name }); }); - - builder.Entity(x => + builder.Entity(x => { - x.ToTable(options.TablePrefix + "Version", options.Schema); + x.ToTable(options.TablePrefix + "Packages", options.Schema); - x.Property(p => p.Title) + x.Property(p => p.Name) .IsRequired() - .HasColumnName(nameof(AppVersion.Title)) - .HasMaxLength(AppVersionConsts.MaxTitleLength); - x.Property(p => p.Version) + .HasColumnName(nameof(Package.Name)) + .HasMaxLength(PackageConsts.MaxNameLength); + x.Property(p => p.Note) .IsRequired() - .HasColumnName(nameof(AppVersion.Version)) - .HasMaxLength(AppVersionConsts.MaxVersionLength); + .HasColumnName(nameof(Package.Note)) + .HasMaxLength(PackageConsts.MaxNoteLength); + x.Property(p => p.Version) + .IsRequired() + .HasColumnName(nameof(Package.Version)) + .HasMaxLength(PackageConsts.MaxVersionLength); x.Property(p => p.Description) - .HasColumnName(nameof(AppVersion.Description)) - .HasMaxLength(AppVersionConsts.MaxDescriptionLength); + .HasColumnName(nameof(Package.Description)) + .HasMaxLength(PackageConsts.MaxDescriptionLength); + x.Property(p => p.Authors) + .HasColumnName(nameof(Package.Authors)) + .HasMaxLength(PackageConsts.MaxAuthorsLength); x.ConfigureByConvention(); - x.HasIndex(i => i.Version); + x.HasIndex(i => new { i.Name, i.Version }); - x.HasMany(p => p.Files) - .WithOne(q => q.AppVersion) + x.HasMany(p => p.Blobs) + .WithOne(q => q.Package) .HasPrincipalKey(pk => pk.Id) - .HasForeignKey(fk => fk.AppVersionId) + .HasForeignKey(fk => fk.PackageId) .OnDelete(DeleteBehavior.Cascade); }); - builder.Entity(x => + builder.Entity(x => { - x.ToTable(options.TablePrefix + "VersionFile", options.Schema); + x.ToTable(options.TablePrefix + "PackageBlobs", options.Schema); x.Property(p => p.Name) .IsRequired() - .HasColumnName(nameof(VersionFile.Name)) - .HasMaxLength(VersionFileConsts.MaxNameLength); - x.Property(p => p.SHA256) - .IsRequired() - .HasColumnName(nameof(VersionFile.SHA256)) - .HasMaxLength(VersionFileConsts.MaxSHA256Length); - x.Property(p => p.Version) - .IsRequired() - .HasColumnName(nameof(VersionFile.Version)) - .HasMaxLength(VersionFileConsts.MaxVersionLength); + .HasColumnName(nameof(PackageBlob.Name)) + .HasMaxLength(PackageBlobConsts.MaxNameLength); - x.Property(p => p.Path) - .HasColumnName(nameof(VersionFile.Path)) - .HasMaxLength(VersionFileConsts.MaxPathLength); + x.Property(p => p.SHA256) + .HasColumnName(nameof(PackageBlob.SHA256)) + .HasMaxLength(PackageBlobConsts.MaxSHA256Length); + x.Property(p => p.Url) + .HasColumnName(nameof(PackageBlob.Url)) + .HasMaxLength(PackageBlobConsts.MaxUrlLength); + x.Property(p => p.Summary) + .HasColumnName(nameof(PackageBlob.Summary)) + .HasMaxLength(PackageBlobConsts.MaxSummaryLength); + x.Property(p => p.Authors) + .HasColumnName(nameof(PackageBlob.Authors)) + .HasMaxLength(PackageBlobConsts.MaxAuthorsLength); + x.Property(p => p.License) + .HasColumnName(nameof(PackageBlob.License)) + .HasMaxLength(PackageBlobConsts.MaxLicenseLength); + x.Property(p => p.ContentType) + .HasColumnName(nameof(PackageBlob.ContentType)) + .HasMaxLength(PackageBlobConsts.MaxContentTypeLength); - x.ConfigureAudited(); - x.ConfigureMultiTenant(); + x.ConfigureByConvention(); - x.HasIndex(i => new { i.Path, i.Name, i.Version }).IsUnique(); - + x.HasIndex(i => new { i.PackageId, i.Name }); }); } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformEfCoreQueryableExtensions.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformEfCoreQueryableExtensions.cs index f57290c53..2321e91ac 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformEfCoreQueryableExtensions.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformEfCoreQueryableExtensions.cs @@ -1,6 +1,7 @@ using LINGYUN.Platform.Datas; using LINGYUN.Platform.Layouts; using LINGYUN.Platform.Menus; +using LINGYUN.Platform.Packages; using Microsoft.EntityFrameworkCore; using System.Linq; @@ -40,5 +41,17 @@ namespace LINGYUN.Platform.EntityFrameworkCore .AsSplitQuery() .Include(x => x.Items); } + + public static IQueryable IncludeDetails(this IQueryable queryable, bool include = true) + { + if (!include) + { + return queryable; + } + + return queryable + .AsSplitQuery() + .Include(x => x.Blobs); + } } } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformEntityFrameworkCoreModule.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformEntityFrameworkCoreModule.cs index 7990b233b..8f94a1f62 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformEntityFrameworkCoreModule.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformEntityFrameworkCoreModule.cs @@ -1,8 +1,7 @@ using LINGYUN.Platform.Datas; using LINGYUN.Platform.Layouts; using LINGYUN.Platform.Menus; -using LINGYUN.Platform.Versions; -using Microsoft.EntityFrameworkCore; +using LINGYUN.Platform.Packages; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.EntityFrameworkCore; using Volo.Abp.Modularity; @@ -24,15 +23,9 @@ namespace LINGYUN.Platform.EntityFrameworkCore options.AddRepository(); options.AddRepository(); options.AddRepository(); - options.AddRepository(); + options.AddRepository(); options.AddDefaultRepositories(includeAllEntities: true); - - options.Entity(appVersion => - { - appVersion.DefaultWithDetailsFunc = (x) => - x.Include(q => q.Files); - }); }); } } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Packages/EfCorePackageRepository.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Packages/EfCorePackageRepository.cs new file mode 100644 index 000000000..d4dbf51c6 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Packages/EfCorePackageRepository.cs @@ -0,0 +1,80 @@ +using LINGYUN.Platform.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Dynamic.Core; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.Specifications; + +namespace LINGYUN.Platform.Packages; +public class EfCorePackageRepository : + EfCoreRepository, + IPackageRepository +{ + public EfCorePackageRepository( + IDbContextProvider dbContextProvider) + : base(dbContextProvider) + { + } + + public async virtual Task FindByNameAsync( + string name, + bool includeDetails = true, + CancellationToken cancellationToken = default) + { + return await (await GetDbSetAsync()) + .IncludeDetails(includeDetails) + .Where(x => x.Name == name) + .OrderByDescending(x => x.Version) + .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); + } + + public async virtual Task FindLatestAsync( + string name, + bool includeDetails = true, + CancellationToken cancellationToken = default) + { + return await (await GetDbSetAsync()) + .IncludeDetails(includeDetails) + .Where(x => x.Name == name) + .OrderByDescending(x => x.Version) + .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); + } + + public async virtual Task GetCountAsync( + Specification specification, + CancellationToken cancellationToken = default) + { + return await (await GetDbSetAsync()) + .Where(specification.ToExpression()) + .CountAsync(GetCancellationToken(cancellationToken)); + } + + public async virtual Task> GetListAsync( + Specification specification, + string sorting = $"{nameof(Package.Version)} DESC", + int skipCount = 0, + int maxResultCount = 10, + CancellationToken cancellationToken = default) + { + if (sorting.IsNullOrWhiteSpace()) + { + sorting = $"{nameof(Package.Version)} DESC"; + } + + return await (await GetDbSetAsync()) + .Where(specification.ToExpression()) + .OrderBy(sorting) + .PageBy(skipCount, maxResultCount) + .ToListAsync(GetCancellationToken(cancellationToken)); + } + + public async override Task> WithDetailsAsync() + { + return (await GetQueryableAsync()).IncludeDetails(); + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Versions/EfCoreVersionRepository.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Versions/EfCoreVersionRepository.cs deleted file mode 100644 index 29f0c52e6..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Versions/EfCoreVersionRepository.cs +++ /dev/null @@ -1,68 +0,0 @@ -using LINGYUN.Platform.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Linq.Dynamic.Core; -using System.Threading; -using System.Threading.Tasks; -using Volo.Abp.DependencyInjection; -using Volo.Abp.Domain.Repositories.EntityFrameworkCore; -using Volo.Abp.EntityFrameworkCore; - -namespace LINGYUN.Platform.Versions -{ - public class EfCoreVersionRepository : EfCoreRepository, IVersionRepository, ITransientDependency - { - public EfCoreVersionRepository( - IDbContextProvider dbContextProvider) - : base(dbContextProvider) - { - } - - public async virtual Task GetCountAsync(PlatformType platformType, string filter = "", CancellationToken cancellationToken = default) - { - return await (await GetDbSetAsync()) - .Where(x => (platformType | x.PlatformType) == x.PlatformType) - .WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Version.Contains(filter) || x.Title.Contains(filter)) - .LongCountAsync(GetCancellationToken(cancellationToken)); - } - - public async virtual Task> GetPagedListAsync(PlatformType platformType, string filter = "", string soring = nameof(AppVersion.CreationTime), bool includeDetails = true, int skipCount = 1, int maxResultCount = 10, CancellationToken cancellationToken = default) - { - return await (await GetDbSetAsync()) - .IncludeIf(includeDetails, x => x.Files) - .Where(x => (platformType | x.PlatformType) == x.PlatformType) - .WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Version.Contains(filter) || x.Title.Contains(filter)) - .OrderBy($"{nameof(AppVersion.CreationTime)} DESC") - .ThenBy(soring ?? nameof(AppVersion.Version)) - .PageBy(skipCount, maxResultCount) - .ToListAsync(GetCancellationToken(cancellationToken)); - } - - - public async virtual Task ExistsAsync(PlatformType platformType, string version, CancellationToken cancellationToken = default) - { - return await (await GetDbSetAsync()) - .AnyAsync(x => (platformType | x.PlatformType) == x.PlatformType && x.Version.Equals(version), GetCancellationToken(cancellationToken)); - } - - public async virtual Task GetByVersionAsync(PlatformType platformType, string version, CancellationToken cancellationToken = default) - { - return await (await GetDbSetAsync()) - .Include(x => x.Files) - .Where(x => (platformType | x.PlatformType) == x.PlatformType && x.Version.Equals(version)) - .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); - } - - public async virtual Task GetLatestVersionAsync(PlatformType platformType, CancellationToken cancellationToken = default) - { - return await (await GetDbSetAsync()) - .Include(x => x.Files) - .Where(x => (platformType | x.PlatformType) == x.PlatformType) - .OrderBy($"{nameof(AppVersion.CreationTime)} DESC") - .ThenBy(nameof(AppVersion.Version)) - .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); - } - } -} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Packages/PackageController.cs b/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Packages/PackageController.cs new file mode 100644 index 000000000..43919c6a2 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Packages/PackageController.cs @@ -0,0 +1,97 @@ +using LINGYUN.Platform.Permissions; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Content; + +namespace LINGYUN.Platform.Packages; + +[RemoteService(Name = PlatformRemoteServiceConsts.RemoteServiceName)] +[Area("platform")] +[Route("api/platform/packages")] +public class PackageController : PlatformControllerBase, IPackageAppService +{ + private readonly IPackageAppService _service; + + public PackageController(IPackageAppService service) + { + _service = service; + } + + [HttpPost] + [Authorize(PlatformPermissions.Package.Create)] + public virtual Task CreateAsync(PackageCreateDto input) + { + return _service.CreateAsync(input); + } + + [HttpDelete] + [Route("{id}")] + [Authorize(PlatformPermissions.Package.Delete)] + public virtual Task DeleteAsync(Guid id) + { + return _service.DeleteAsync(id); + } + + [HttpPost] + [Route("{id}/blob")] + [Authorize(PlatformPermissions.Package.ManageBlobs)] + public virtual Task UploadBlobAsync( + Guid id, + [FromForm] PackageBlobUploadDto input) + { + return _service.UploadBlobAsync(id, input); + } + + [HttpDelete] + [Route("{id}/blob/{Name}")] + [Authorize(PlatformPermissions.Package.ManageBlobs)] + public virtual Task RemoveBlobAsync( + Guid id, + PackageBlobRemoveDto input) + { + return _service.RemoveBlobAsync(id, input); + } + + [HttpGet] + [Route("{id}/blob/{Name}")] + [AllowAnonymous] + public virtual Task DownloadBlobAsync(Guid id, PackageBlobDownloadInput input) + { + return _service.DownloadBlobAsync(id, input); + } + + [HttpGet] + [Route("{id}")] + [AllowAnonymous] + public virtual Task GetAsync(Guid id) + { + return _service.GetAsync(id); + } + + [HttpGet] + [Route("{Name}/latest")] + [AllowAnonymous] + public virtual Task GetLatestAsync(PackageGetLatestInput input) + { + return _service.GetLatestAsync(input); + } + + [HttpGet] + [Authorize(PlatformPermissions.Package.Default)] + public virtual Task> GetListAsync(PackageGetPagedListInput input) + { + return _service.GetListAsync(input); + } + + [HttpPut] + [Route("{id}")] + [Authorize(PlatformPermissions.Package.Update)] + public virtual Task UpdateAsync(Guid id, PackageUpdateDto input) + { + return _service.UpdateAsync(id, input); + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Versions/VersionController.cs b/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Versions/VersionController.cs deleted file mode 100644 index cea6bcc5f..000000000 --- a/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Versions/VersionController.cs +++ /dev/null @@ -1,224 +0,0 @@ -using LINGYUN.Platform.Permissions; -using LINGYUN.Platform.Settings; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.StaticFiles; -using System; -using System.ComponentModel.DataAnnotations; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using Volo.Abp; -using Volo.Abp.Application.Dtos; -using Volo.Abp.IO; -using Volo.Abp.Settings; - -namespace LINGYUN.Platform.Versions -{ - [RemoteService(Name = PlatformRemoteServiceConsts.RemoteServiceName)] - [Area("platform")] - [Route("api/platform/version")] - public class VersionController : PlatformControllerBase, IVersionAppService - { - private readonly IVersionFileManager _versionFileManager; - private readonly IVersionAppService _versionAppService; - - public VersionController( - IVersionAppService versionAppService, - IVersionFileManager versionFileManager) - { - _versionAppService = versionAppService; - _versionFileManager = versionFileManager; - } - - [HttpPost] - [Route("file/append")] - [RequestSizeLimit(200_000_000)] - public async virtual Task AppendFileAsync([FromQuery] VersionFileCreateDto versionFileCreate) - { - // 检查文件大小 - var fileSizeLimited = await SettingProvider - .GetAsync(PlatformSettingNames.AppVersion.VersionFileLimitLength, AppVersionConsts.DefaultVersionFileLimitLength); - if (fileSizeLimited * 1024 * 1024 < versionFileCreate.TotalByte) - { - throw new UserFriendlyException(L["UploadFileSizeBeyondLimit", fileSizeLimited]); - } - // 采用分块模式上传文件 - - // 保存分块到临时目录 - var fileName = versionFileCreate.FileName; - // 文件扩展名 - var fileExtensionName = FileHelper.GetExtension(fileName); - var fileAllowExtension = await SettingProvider - .GetOrNullAsync(PlatformSettingNames.AppVersion.AllowVersionFileExtensions); - if (fileAllowExtension.IsNullOrWhiteSpace()) - { - fileAllowExtension = AppVersionConsts.DefaultAllowVersionFileExtensions; - } - // 检查文件扩展名 - if (!fileAllowExtension.Split(',').Any(fe => fe.Equals(fileExtensionName, StringComparison.CurrentCultureIgnoreCase))) - { - throw new UserFriendlyException(L["NotAllowedFileExtensionName", fileExtensionName]); - } - // 当前计算机临时目录 - var tempFilePath = Environment.GetFolderPath(Environment.SpecialFolder.Templates); - // 以上传的文件名创建一个临时目录 - tempFilePath = Path.Combine(tempFilePath, "lingyun-platform", Path.GetFileNameWithoutExtension(fileName)); - // 以上传的分片索引创建临时文件 - var tempSavedFile = Path.Combine(tempFilePath, $"{versionFileCreate.CurrentByte}.{fileExtensionName}"); - if (!Directory.Exists(tempFilePath)) - { - // 临时目录不存在则创建 - Directory.CreateDirectory(tempFilePath); - } - try - { - if (HttpContext.RequestAborted.IsCancellationRequested) - { - // 如果取消请求,删除临时目录 - Directory.Delete(tempFilePath, true); - return; - } - // 保存临时文件 - using (var fs = new FileStream(tempSavedFile, FileMode.Create, FileAccess.Write)) - { - // 写入当前分片文件 - await Request.Body.CopyToAsync(fs); - } - - if (versionFileCreate.CurrentByte == versionFileCreate.TotalByte) - { - // 合并文件 - var mergeSavedFile = Path.Combine(tempFilePath, $"{fileName}"); - // 获取并排序所有分片文件 - var mergeFiles = Directory.GetFiles(tempFilePath).OrderBy(f => f.Length).ThenBy(f => f); - // 创建临时合并文件 - using (var mergeSavedFileStream = new FileStream(mergeSavedFile, FileMode.Create)) - { - foreach (var mergeFile in mergeFiles) - { - // 读取当前文件字节 - var mergeFileBytes = await FileHelper.ReadAllBytesAsync(mergeFile); - // 写入到合并文件流 - await mergeSavedFileStream.WriteAsync(mergeFileBytes,0, mergeFileBytes.Length); - // 删除已参与合并的临时文件分片 - FileHelper.DeleteIfExists(mergeFile); - } - // 上传最终合并的文件并取得SHA256指纹 - var fileData = await mergeSavedFileStream.GetAllBytesAsync(); - versionFileCreate.SHA256 = await _versionFileManager.SaveFileAsync(versionFileCreate.Version, - versionFileCreate.FilePath, versionFileCreate.FileName, versionFileCreate.FileVersion, fileData); - } - // 添加到版本信息 - await _versionAppService.AppendFileAsync(versionFileCreate); - // 文件保存之后删除临时文件目录 - Directory.Delete(tempFilePath, true); - } - } - catch - { - // 发生异常删除临时文件目录 - Directory.Delete(tempFilePath, true); - throw; - } - } - - [HttpPost] - public async virtual Task CreateAsync(VersionCreateDto versionCreate) - { - return await _versionAppService.CreateAsync(versionCreate); - } - - [HttpDelete] - public async virtual Task DeleteAsync(VersionDeleteDto versionDelete) - { - await _versionAppService.DeleteAsync(versionDelete); - } - - [HttpGet] - public async virtual Task> GetAsync(VersionGetByPagedDto versionGetByPaged) - { - return await _versionAppService.GetAsync(versionGetByPaged); - } - - [HttpGet] - [Route("{Id}")] - public async virtual Task GetAsync(VersionGetByIdDto versionGetById) - { - return await _versionAppService.GetAsync(versionGetById); - } - - [HttpGet] - [Route("lastest")] - public async virtual Task GetLastestAsync([Required] PlatformType platformType) - { - return await _versionAppService.GetLastestAsync(platformType); - } - - [HttpDelete] - [Route("file/clean")] - public async virtual Task RemoveAllFileAsync(VersionGetByIdDto versionGetById) - { - await _versionAppService.RemoveAllFileAsync(versionGetById); - } - - [HttpDelete] - [Route("file/remove")] - public async virtual Task RemoveFileAsync(VersionFileDeleteDto versionFileDelete) - { - await _versionAppService.RemoveFileAsync(versionFileDelete); - } - - [HttpGet] - [Route("file/download")] - [Authorize(PlatformPermissions.AppVersion.FileManager.Download)] - public async virtual Task DownloadFileAsync(VersionFileGetDto versionFileGet) - { - // 分块模式下载文件 - - // 得到文件流 - var fileStream = await _versionFileManager.DownloadFileAsync( - versionFileGet.PlatformType, versionFileGet.Version, versionFileGet.FilePath, - versionFileGet.FileName, versionFileGet.FileVersion); - // 得到文件扩展名 - var fileExt = Path.GetExtension(versionFileGet.FileName); - var provider = new FileExtensionContentTypeProvider(); - // Http响应标头的文件类型 - string memi = provider.Mappings[fileExt]; - using (Response.Body) - { - // Http响应标头的文件类型 - Response.ContentType = memi; - // 文件大小 - byte[] contentBytes = await fileStream.GetAllBytesAsync(); - long contentLength = contentBytes.Length; - // 指定响应内容大小 - Response.ContentLength = contentLength; - // 单个分块大小 2MB - int bufferSize = 2 * 1024 * 1024; - // 分块总数 - int contentByteCount = Math.DivRem(contentBytes.Length, bufferSize, out int modResult); - for (int index = 0; index < contentByteCount; index++) - { - // 当前分页传输字节 - byte[] currentTransferBytes = new byte[bufferSize]; - if (index == contentByteCount - 1) - { - // 最后一个分块和余数大小一起传输 - if (modResult > 0) - { - currentTransferBytes = new byte[bufferSize + modResult]; - } - } - // 复制文件流中的当前分块区段 - Array.Copy(contentBytes, index * bufferSize, currentTransferBytes, 0, currentTransferBytes.Length); - // 写入响应流 - await Response.Body.WriteAsync(currentTransferBytes, 0, currentTransferBytes.Length); - // 清空缓冲区 - await Response.Body.FlushAsync(); - } - } - } - } -} diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Quartz/LINGYUN/Abp/BackgroundTasks/Quartz/QuartzJobSimpleAdapter.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Quartz/LINGYUN/Abp/BackgroundTasks/Quartz/QuartzJobSimpleAdapter.cs index 00eb45c3c..dca926eda 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Quartz/LINGYUN/Abp/BackgroundTasks/Quartz/QuartzJobSimpleAdapter.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Quartz/LINGYUN/Abp/BackgroundTasks/Quartz/QuartzJobSimpleAdapter.cs @@ -25,7 +25,7 @@ public class QuartzJobSimpleAdapter : IJob typeof(TJobRunnable), scope.ServiceProvider, context.MergedJobDataMap.ToImmutableDictionary(), - getCache: (key) => context.Get(key), + getCache: context.Get, setCache: context.Put, cancellationToken: context.CancellationToken); diff --git a/aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.Saas/Properties/launchSettings.json b/aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.Saas/Properties/launchSettings.json new file mode 100644 index 000000000..9959c3f46 --- /dev/null +++ b/aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.Saas/Properties/launchSettings.json @@ -0,0 +1,12 @@ +{ + "profiles": { + "LINGYUN.Abp.MultiTenancy.Saas": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:58776;http://localhost:58777" + } + } +} \ No newline at end of file diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN.Abp.TextTemplating.EntityFrameworkCore.csproj b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN.Abp.TextTemplating.EntityFrameworkCore.csproj index c4657dd38..025f36a6d 100644 --- a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN.Abp.TextTemplating.EntityFrameworkCore.csproj +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN.Abp.TextTemplating.EntityFrameworkCore.csproj @@ -1,19 +1,19 @@ - - - - - - - net6.0 - - - - - - - - - - - - + + + + + + + net6.0 + + + + + + + + + + + + diff --git a/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/FodyWeavers.xml b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/FodyWeavers.xml new file mode 100644 index 000000000..1715698cc --- /dev/null +++ b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/LINGYUN.Abp.WeChat.Official.Senparc.csproj b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/LINGYUN.Abp.WeChat.Official.Senparc.csproj new file mode 100644 index 000000000..0c4e72aba --- /dev/null +++ b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/LINGYUN.Abp.WeChat.Official.Senparc.csproj @@ -0,0 +1,20 @@ + + + + + + + net6.0 + + + + + + + + + + + + + diff --git a/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/LINGYUN/Abp/WeChat/Official/Senparc/AbpWeChatOfficialSenparcModule.cs b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/LINGYUN/Abp/WeChat/Official/Senparc/AbpWeChatOfficialSenparcModule.cs new file mode 100644 index 000000000..971f60d5d --- /dev/null +++ b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/LINGYUN/Abp/WeChat/Official/Senparc/AbpWeChatOfficialSenparcModule.cs @@ -0,0 +1,9 @@ +using Volo.Abp.Modularity; + +namespace LINGYUN.Abp.WeChat.Official.Senparc; + +[DependsOn(typeof(AbpWeChatOfficialModule))] +public class AbpWeChatOfficialSenparcModule : AbpModule +{ + +} diff --git a/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/LINGYUN/Abp/WeChat/Official/Senparc/WeChatOfficialController.cs b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/LINGYUN/Abp/WeChat/Official/Senparc/WeChatOfficialController.cs new file mode 100644 index 000000000..876854803 --- /dev/null +++ b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/LINGYUN/Abp/WeChat/Official/Senparc/WeChatOfficialController.cs @@ -0,0 +1,81 @@ +using Microsoft.AspNetCore.Mvc; +using Senparc.NeuChar.MessageHandlers; +using Senparc.Weixin.MP; +using Senparc.Weixin.MP.Entities.Request; +using System.Threading.Tasks; +using Volo.Abp.AspNetCore.Mvc; + +namespace LINGYUN.Abp.WeChat.Official.Senparc; + +[Area("wechat-official")] +[Route("api/wechat/official")] +public class WeChatOfficialController : AbpControllerBase +{ + private readonly AbpWeChatOfficialOptionsFactory _optionsFactory; + + public WeChatOfficialController(AbpWeChatOfficialOptionsFactory optionsFactory) + { + _optionsFactory = optionsFactory; + } + + + + /// + /// 微信后台验证地址(使用Get),微信后台的“接口配置信息”的Url填写如:http://weixin.senparc.com/weixin + /// + [HttpGet] + public async Task Get(PostModel postModel, string echostr) + { + var options = await _optionsFactory.CreateAsync(); + if (CheckSignature.Check(postModel.Signature, postModel.Timestamp, postModel.Nonce, options.Token)) + { + return Content(echostr); //返回随机字符串则表示验证通过 + } + else + { + return Content( + "failed:" + postModel.Signature + "," + + CheckSignature.GetSignature(postModel.Timestamp, postModel.Nonce, options.Token) + "。" + + "如果你在浏览器中看到这句话,说明此地址可以被作为微信公众账号后台的Url,请注意保持Token一致。"); + } + } + + /// + /// 用户发送消息后,微信平台自动Post一个请求到这里,并等待响应XML。 + /// + [HttpPost] + public async Task Post(PostModel postModel) + { + var options = await _optionsFactory.CreateAsync(); + if (!CheckSignature.Check(postModel.Signature, postModel.Timestamp, postModel.Nonce, options.Token)) + { + return Content("参数错误!"); + } + + postModel.Token = options.Token;//根据自己后台的设置保持一致 + postModel.EncodingAESKey = options.EncodingAESKey;//根据自己后台的设置保持一致 + postModel.AppId = options.AppId;//根据自己后台的设置保持一致 + + //自定义MessageHandler,对微信请求的详细判断操作都在这里面。 + var messageHandler = new WeChatOfficialMessageHandler(Request.Body, postModel);//接收消息 + + #region 设置消息去重设置 + 优先调用同步、异步方法设置 + + /* 如果需要添加消息去重功能,只需打开OmitRepeatedMessage功能,SDK会自动处理。 + * 收到重复消息通常是因为微信服务器没有及时收到响应,会持续发送2-5条不等的相同内容的 RequestMessage */ + messageHandler.OmitRepeatedMessage = true;//默认已经是开启状态,此处仅作为演示,也可以设置为 false 在本次请求中停用此功能 + + //当同步方法被重写,且异步方法未被重写时,尝试调用同步方法 + messageHandler.DefaultMessageHandlerAsyncEvent = DefaultMessageHandlerAsyncEvent.SelfSynicMethod; + + #endregion + + messageHandler.SaveRequestMessageLog();//记录 Request 日志(可选) + + await messageHandler.ExecuteAsync(HttpContext.RequestAborted);//执行微信处理过程(关键,第二步) + + messageHandler.SaveResponseMessageLog();//记录 Response 日志(可选) + + return Ok(); + } +} diff --git a/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/LINGYUN/Abp/WeChat/Official/Senparc/WeChatOfficialMessageContext.cs b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/LINGYUN/Abp/WeChat/Official/Senparc/WeChatOfficialMessageContext.cs new file mode 100644 index 000000000..1a24443b7 --- /dev/null +++ b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/LINGYUN/Abp/WeChat/Official/Senparc/WeChatOfficialMessageContext.cs @@ -0,0 +1,7 @@ +using Senparc.Weixin.MP.MessageContexts; + +namespace LINGYUN.Abp.WeChat.Official.Senparc; + +public class WeChatOfficialMessageContext : DefaultMpMessageContext +{ +} diff --git a/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/LINGYUN/Abp/WeChat/Official/Senparc/WeChatOfficialMessageHandler.cs b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/LINGYUN/Abp/WeChat/Official/Senparc/WeChatOfficialMessageHandler.cs new file mode 100644 index 000000000..c5159b23b --- /dev/null +++ b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.Official.Senparc/LINGYUN/Abp/WeChat/Official/Senparc/WeChatOfficialMessageHandler.cs @@ -0,0 +1,30 @@ +using Senparc.NeuChar.App.AppStore; +using Senparc.NeuChar.Entities; +using Senparc.Weixin.MP.Entities; +using Senparc.Weixin.MP.Entities.Request; +using Senparc.Weixin.MP.MessageHandlers; +using System; +using System.IO; + +namespace LINGYUN.Abp.WeChat.Official.Senparc; + +public class WeChatOfficialMessageHandler : MessageHandler +{ + public WeChatOfficialMessageHandler( + Stream inputStream, + PostModel postModel, + int maxRecordCount = 0, + bool onlyAllowEncryptMessage = false, + DeveloperInfo developerInfo = null, + IServiceProvider serviceProvider = null) + : base(inputStream, postModel, maxRecordCount, onlyAllowEncryptMessage, developerInfo, serviceProvider) + { + } + + public override IResponseMessageBase DefaultResponseMessage(IRequestMessageBase requestMessage) + { + var responseMessage = base.CreateResponseMessage(); + responseMessage.Content = $"这条消息来自DefaultResponseMessage。\r\n您收到这条消息,表明该公众号没有对【{requestMessage.MsgType}】类型做处理。"; + return responseMessage; + } +} diff --git a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN.Abp.WxPusher.SettingManagement.csproj b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN.Abp.WxPusher.SettingManagement.csproj index 24ac4881b..2c43def64 100644 --- a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN.Abp.WxPusher.SettingManagement.csproj +++ b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN.Abp.WxPusher.SettingManagement.csproj @@ -1,29 +1,29 @@ - - - - - - - net6.0 - - - - - - - - - - - - - - - - - - - - - - + + + + + + + net6.0 + + + + + + + + + + + + + + + + + + + + + + diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/LY.MicroService.PlatformManagement.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/LY.MicroService.PlatformManagement.HttpApi.Host.csproj index f46347452..d0aa518d2 100644 --- a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/LY.MicroService.PlatformManagement.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/LY.MicroService.PlatformManagement.HttpApi.Host.csproj @@ -1,73 +1,73 @@ - - - - net6.0 - LY.MicroService.PlatformManagement - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + net6.0 + LY.MicroService.PlatformManagement + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20221212081339_Add-Package-Manager.Designer.cs b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20221212081339_Add-Package-Manager.Designer.cs new file mode 100644 index 000000000..1053d32ed --- /dev/null +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20221212081339_Add-Package-Manager.Designer.cs @@ -0,0 +1,934 @@ +// +using System; +using LY.MicroService.PlatformManagement.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.PlatformManagement.Migrations +{ + [DbContext(typeof(PlatformManagementMigrationsDbContext))] + [Migration("20221212081339_Add-Package-Manager")] + partial class AddPackageManager + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "6.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Platform.Datas.Data", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Code"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .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("Description") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Description"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Name"); + + b.Property("ParentId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("AppPlatformDatas", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Datas.DataItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AllowBeNull") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(true); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .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("DataId") + .HasColumnType("char(36)"); + + b.Property("DefaultValue") + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DefaultValue"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Description"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Name"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("ValueType") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("DataId"); + + b.HasIndex("Name"); + + b.ToTable("AppPlatformDataItems", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Layouts.Layout", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .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("DataId") + .HasColumnType("char(36)"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Framework") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Framework"); + + 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)") + .HasColumnName("Name"); + + b.Property("Path") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Path"); + + b.Property("Redirect") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Redirect"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.ToTable("AppPlatformLayouts", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.Menu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(23) + .HasColumnType("varchar(23)") + .HasColumnName("Code"); + + b.Property("Component") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Component"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .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("Description") + .HasColumnType("longtext"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Framework") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Framework"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsPublic") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("LayoutId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Name"); + + b.Property("ParentId") + .HasColumnType("char(36)"); + + b.Property("Path") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Path"); + + b.Property("Redirect") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Redirect"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.ToTable("AppPlatformMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.RoleMenu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("MenuId") + .HasColumnType("char(36)"); + + b.Property("RoleName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("RoleName"); + + b.Property("Startup") + .HasColumnType("tinyint(1)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("RoleName", "MenuId"); + + b.ToTable("AppPlatformRoleMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.UserFavoriteMenu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AliasName") + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("AliasName"); + + b.Property("Color") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Color"); + + 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("Framework") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Framework"); + + b.Property("Icon") + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("Icon"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("MenuId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Name"); + + b.Property("Path") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Path"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId", "MenuId"); + + b.ToTable("AppPlatformUserFavoriteMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.UserMenu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("MenuId") + .HasColumnType("char(36)"); + + b.Property("Startup") + .HasColumnType("tinyint(1)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId", "MenuId"); + + b.ToTable("AppPlatformUserMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Packages.Package", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Authors") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("Authors"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .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("Description") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Description"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("ForceUpdate") + .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("Level") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Name"); + + b.Property("Note") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Note"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Version") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Version"); + + b.HasKey("Id"); + + b.HasIndex("Name", "Version"); + + b.ToTable("AppPlatformPackages", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Packages.PackageBlob", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Authors") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("Authors"); + + b.Property("ContentType") + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("ContentType"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DownloadCount") + .HasColumnType("int"); + + b.Property("License") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("License"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Name"); + + b.Property("PackageId") + .HasColumnType("char(36)"); + + b.Property("SHA256") + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("SHA256"); + + b.Property("Size") + .HasColumnType("bigint"); + + b.Property("Summary") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Summary"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Url") + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("Url"); + + b.HasKey("Id"); + + b.HasIndex("PackageId", "Name"); + + b.ToTable("AppPlatformPackageBlobs", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Versions.AppVersion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .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("Description") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)") + .HasColumnName("Description"); + + b.Property("ExtraProperties") + .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.Property("Level") + .HasColumnType("int"); + + b.Property("PlatformType") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnName("Title"); + + b.Property("Version") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasColumnName("Version"); + + b.HasKey("Id"); + + b.HasIndex("Version"); + + b.ToTable("AppPlatformVersion", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Versions.VersionFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AppVersionId") + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DownloadCount") + .HasColumnType("int"); + + b.Property("FileType") + .HasColumnType("int"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Name"); + + b.Property("Path") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Path"); + + b.Property("SHA256") + .IsRequired() + .HasMaxLength(65) + .HasColumnType("varchar(65)") + .HasColumnName("SHA256"); + + b.Property("Size") + .HasColumnType("bigint"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Version") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)") + .HasColumnName("Version"); + + b.HasKey("Id"); + + b.HasIndex("AppVersionId"); + + b.HasIndex("Path", "Name", "Version") + .IsUnique(); + + b.ToTable("AppPlatformVersionFile", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Datas.DataItem", b => + { + b.HasOne("LINGYUN.Platform.Datas.Data", null) + .WithMany("Items") + .HasForeignKey("DataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LINGYUN.Platform.Packages.PackageBlob", b => + { + b.HasOne("LINGYUN.Platform.Packages.Package", "Package") + .WithMany("Blobs") + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Package"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Versions.VersionFile", b => + { + b.HasOne("LINGYUN.Platform.Versions.AppVersion", "AppVersion") + .WithMany("Files") + .HasForeignKey("AppVersionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AppVersion"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Datas.Data", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Packages.Package", b => + { + b.Navigation("Blobs"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Versions.AppVersion", b => + { + b.Navigation("Files"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20221212081339_Add-Package-Manager.cs b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20221212081339_Add-Package-Manager.cs new file mode 100644 index 000000000..f042cdee0 --- /dev/null +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20221212081339_Add-Package-Manager.cs @@ -0,0 +1,110 @@ +using System; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LY.MicroService.PlatformManagement.Migrations +{ + public partial class AddPackageManager : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "AppPlatformPackages", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(255)", maxLength: 255, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Note = table.Column(type: "varchar(1024)", maxLength: 1024, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Version = table.Column(type: "varchar(30)", maxLength: 30, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "varchar(255)", maxLength: 255, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ForceUpdate = table.Column(type: "tinyint(1)", nullable: false), + Authors = table.Column(type: "varchar(100)", maxLength: 100, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Level = table.Column(type: "int", nullable: false), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + DeletionTime = table.Column(type: "datetime(6)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AppPlatformPackages", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AppPlatformPackageBlobs", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + PackageId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(255)", maxLength: 255, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Url = table.Column(type: "varchar(512)", maxLength: 512, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Size = table.Column(type: "bigint", nullable: true), + Summary = table.Column(type: "varchar(1024)", maxLength: 1024, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreatedAt = table.Column(type: "datetime(6)", nullable: false), + UpdatedAt = table.Column(type: "datetime(6)", nullable: true), + License = table.Column(type: "varchar(1024)", maxLength: 1024, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Authors = table.Column(type: "varchar(100)", maxLength: 100, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ContentType = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + SHA256 = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + DownloadCount = table.Column(type: "int", nullable: false), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AppPlatformPackageBlobs", x => x.Id); + table.ForeignKey( + name: "FK_AppPlatformPackageBlobs_AppPlatformPackages_PackageId", + column: x => x.PackageId, + principalTable: "AppPlatformPackages", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_AppPlatformPackageBlobs_PackageId_Name", + table: "AppPlatformPackageBlobs", + columns: new[] { "PackageId", "Name" }); + + migrationBuilder.CreateIndex( + name: "IX_AppPlatformPackages_Name_Version", + table: "AppPlatformPackages", + columns: new[] { "Name", "Version" }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AppPlatformPackageBlobs"); + + migrationBuilder.DropTable( + name: "AppPlatformPackages"); + } + } +} diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20221213005241_Remove-Versions.Designer.cs b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20221213005241_Remove-Versions.Designer.cs new file mode 100644 index 000000000..225b0b6dc --- /dev/null +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20221213005241_Remove-Versions.Designer.cs @@ -0,0 +1,771 @@ +// +using System; +using LY.MicroService.PlatformManagement.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.PlatformManagement.Migrations +{ + [DbContext(typeof(PlatformManagementMigrationsDbContext))] + [Migration("20221213005241_Remove-Versions")] + partial class RemoveVersions + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "6.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Platform.Datas.Data", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Code"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .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("Description") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Description"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Name"); + + b.Property("ParentId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("AppPlatformDatas", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Datas.DataItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AllowBeNull") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(true); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .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("DataId") + .HasColumnType("char(36)"); + + b.Property("DefaultValue") + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DefaultValue"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Description"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Name"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("ValueType") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("DataId"); + + b.HasIndex("Name"); + + b.ToTable("AppPlatformDataItems", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Layouts.Layout", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .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("DataId") + .HasColumnType("char(36)"); + + b.Property("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Framework") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Framework"); + + 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)") + .HasColumnName("Name"); + + b.Property("Path") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Path"); + + b.Property("Redirect") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Redirect"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.ToTable("AppPlatformLayouts", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.Menu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(23) + .HasColumnType("varchar(23)") + .HasColumnName("Code"); + + b.Property("Component") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Component"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .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("Description") + .HasColumnType("longtext"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("DisplayName"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Framework") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Framework"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsPublic") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("LayoutId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Name"); + + b.Property("ParentId") + .HasColumnType("char(36)"); + + b.Property("Path") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Path"); + + b.Property("Redirect") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Redirect"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.ToTable("AppPlatformMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.RoleMenu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("MenuId") + .HasColumnType("char(36)"); + + b.Property("RoleName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("RoleName"); + + b.Property("Startup") + .HasColumnType("tinyint(1)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("RoleName", "MenuId"); + + b.ToTable("AppPlatformRoleMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.UserFavoriteMenu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AliasName") + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("AliasName"); + + b.Property("Color") + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Color"); + + 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("Framework") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Framework"); + + b.Property("Icon") + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("Icon"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("MenuId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Name"); + + b.Property("Path") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Path"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId", "MenuId"); + + b.ToTable("AppPlatformUserFavoriteMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Menus.UserMenu", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("MenuId") + .HasColumnType("char(36)"); + + b.Property("Startup") + .HasColumnType("tinyint(1)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId", "MenuId"); + + b.ToTable("AppPlatformUserMenus", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Packages.Package", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Authors") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("Authors"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .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("Description") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Description"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("ForceUpdate") + .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("Level") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Name"); + + b.Property("Note") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Note"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Version") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)") + .HasColumnName("Version"); + + b.HasKey("Id"); + + b.HasIndex("Name", "Version"); + + b.ToTable("AppPlatformPackages", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Packages.PackageBlob", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Authors") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("Authors"); + + b.Property("ContentType") + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("ContentType"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("DownloadCount") + .HasColumnType("int"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("License") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("License"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Name"); + + b.Property("PackageId") + .HasColumnType("char(36)"); + + b.Property("SHA256") + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("SHA256"); + + b.Property("Size") + .HasColumnType("bigint"); + + b.Property("Summary") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Summary"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Url") + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("Url"); + + b.HasKey("Id"); + + b.HasIndex("PackageId", "Name"); + + b.ToTable("AppPlatformPackageBlobs", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Platform.Datas.DataItem", b => + { + b.HasOne("LINGYUN.Platform.Datas.Data", null) + .WithMany("Items") + .HasForeignKey("DataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LINGYUN.Platform.Packages.PackageBlob", b => + { + b.HasOne("LINGYUN.Platform.Packages.Package", "Package") + .WithMany("Blobs") + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Package"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Datas.Data", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Packages.Package", b => + { + b.Navigation("Blobs"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20221213005241_Remove-Versions.cs b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20221213005241_Remove-Versions.cs new file mode 100644 index 000000000..71f455199 --- /dev/null +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/20221213005241_Remove-Versions.cs @@ -0,0 +1,118 @@ +using System; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LY.MicroService.PlatformManagement.Migrations +{ + public partial class RemoveVersions : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AppPlatformVersionFile"); + + migrationBuilder.DropTable( + name: "AppPlatformVersion"); + + migrationBuilder.AddColumn( + name: "ExtraProperties", + table: "AppPlatformPackageBlobs", + type: "longtext", + nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ExtraProperties", + table: "AppPlatformPackageBlobs"); + + migrationBuilder.CreateTable( + name: "AppPlatformVersion", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ConcurrencyStamp = table.Column(type: "varchar(40)", maxLength: 40, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + DeleterId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + DeletionTime = table.Column(type: "datetime(6)", nullable: true), + Description = table.Column(type: "varchar(2048)", maxLength: 2048, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ExtraProperties = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + Level = table.Column(type: "int", nullable: false), + PlatformType = table.Column(type: "int", nullable: false), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + Title = table.Column(type: "varchar(50)", maxLength: 50, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Version = table.Column(type: "varchar(20)", maxLength: 20, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AppPlatformVersion", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "AppPlatformVersionFile", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + AppVersionId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + DownloadCount = table.Column(type: "int", nullable: false), + FileType = table.Column(type: "int", nullable: false), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(255)", maxLength: 255, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Path = table.Column(type: "varchar(255)", maxLength: 255, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + SHA256 = table.Column(type: "varchar(65)", maxLength: 65, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Size = table.Column(type: "bigint", nullable: false), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + Version = table.Column(type: "varchar(20)", maxLength: 20, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_AppPlatformVersionFile", x => x.Id); + table.ForeignKey( + name: "FK_AppPlatformVersionFile_AppPlatformVersion_AppVersionId", + column: x => x.AppVersionId, + principalTable: "AppPlatformVersion", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_AppPlatformVersion_Version", + table: "AppPlatformVersion", + column: "Version"); + + migrationBuilder.CreateIndex( + name: "IX_AppPlatformVersionFile_AppVersionId", + table: "AppPlatformVersionFile", + column: "AppVersionId"); + + migrationBuilder.CreateIndex( + name: "IX_AppPlatformVersionFile_Path_Name_Version", + table: "AppPlatformVersionFile", + columns: new[] { "Path", "Name", "Version" }, + unique: true); + } + } +} diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/PlatformHttpApiHostMigrationsDbContextModelSnapshot.cs b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/PlatformHttpApiHostMigrationsDbContextModelSnapshot.cs index ceaa9ce46..a34a07e67 100644 --- a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/PlatformHttpApiHostMigrationsDbContextModelSnapshot.cs +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Migrations/PlatformHttpApiHostMigrationsDbContextModelSnapshot.cs @@ -18,7 +18,7 @@ namespace LY.MicroService.PlatformManagement.Migrations #pragma warning disable 612, 618 modelBuilder .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) - .HasAnnotation("ProductVersion", "6.0.9") + .HasAnnotation("ProductVersion", "6.0.11") .HasAnnotation("Relational:MaxIdentifierLength", 64); modelBuilder.Entity("LINGYUN.Platform.Datas.Data", b => @@ -563,12 +563,17 @@ namespace LY.MicroService.PlatformManagement.Migrations b.ToTable("AppPlatformUserMenus", (string)null); }); - modelBuilder.Entity("LINGYUN.Platform.Versions.AppVersion", b => + modelBuilder.Entity("LINGYUN.Platform.Packages.Package", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("char(36)"); + b.Property("Authors") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("Authors"); + b.Property("ConcurrencyStamp") .IsConcurrencyToken() .HasMaxLength(40) @@ -592,14 +597,17 @@ namespace LY.MicroService.PlatformManagement.Migrations .HasColumnName("DeletionTime"); b.Property("Description") - .HasMaxLength(2048) - .HasColumnType("varchar(2048)") + .HasMaxLength(255) + .HasColumnType("varchar(255)") .HasColumnName("Description"); b.Property("ExtraProperties") .HasColumnType("longtext") .HasColumnName("ExtraProperties"); + b.Property("ForceUpdate") + .HasColumnType("tinyint(1)"); + b.Property("IsDeleted") .ValueGeneratedOnAdd() .HasColumnType("tinyint(1)") @@ -617,40 +625,53 @@ namespace LY.MicroService.PlatformManagement.Migrations b.Property("Level") .HasColumnType("int"); - b.Property("PlatformType") - .HasColumnType("int"); + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Name"); + + b.Property("Note") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Note"); b.Property("TenantId") .HasColumnType("char(36)") .HasColumnName("TenantId"); - b.Property("Title") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("varchar(50)") - .HasColumnName("Title"); - b.Property("Version") .IsRequired() - .HasMaxLength(20) - .HasColumnType("varchar(20)") + .HasMaxLength(30) + .HasColumnType("varchar(30)") .HasColumnName("Version"); b.HasKey("Id"); - b.HasIndex("Version"); + b.HasIndex("Name", "Version"); - b.ToTable("AppPlatformVersion", (string)null); + b.ToTable("AppPlatformPackages", (string)null); }); - modelBuilder.Entity("LINGYUN.Platform.Versions.VersionFile", b => + modelBuilder.Entity("LINGYUN.Platform.Packages.PackageBlob", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("int"); - b.Property("AppVersionId") - .HasColumnType("char(36)"); + b.Property("Authors") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("Authors"); + + b.Property("ContentType") + .HasMaxLength(256) + .HasColumnType("varchar(256)") + .HasColumnName("ContentType"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); b.Property("CreationTime") .HasColumnType("datetime(6)") @@ -663,16 +684,14 @@ namespace LY.MicroService.PlatformManagement.Migrations b.Property("DownloadCount") .HasColumnType("int"); - b.Property("FileType") - .HasColumnType("int"); - - b.Property("LastModificationTime") - .HasColumnType("datetime(6)") - .HasColumnName("LastModificationTime"); + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); - b.Property("LastModifierId") - .HasColumnType("char(36)") - .HasColumnName("LastModifierId"); + b.Property("License") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("License"); b.Property("Name") .IsRequired() @@ -680,38 +699,39 @@ namespace LY.MicroService.PlatformManagement.Migrations .HasColumnType("varchar(255)") .HasColumnName("Name"); - b.Property("Path") - .HasMaxLength(255) - .HasColumnType("varchar(255)") - .HasColumnName("Path"); + b.Property("PackageId") + .HasColumnType("char(36)"); b.Property("SHA256") - .IsRequired() - .HasMaxLength(65) - .HasColumnType("varchar(65)") + .HasMaxLength(256) + .HasColumnType("varchar(256)") .HasColumnName("SHA256"); - b.Property("Size") + b.Property("Size") .HasColumnType("bigint"); + b.Property("Summary") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)") + .HasColumnName("Summary"); + b.Property("TenantId") .HasColumnType("char(36)") .HasColumnName("TenantId"); - b.Property("Version") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("varchar(20)") - .HasColumnName("Version"); + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); - b.HasKey("Id"); + b.Property("Url") + .HasMaxLength(512) + .HasColumnType("varchar(512)") + .HasColumnName("Url"); - b.HasIndex("AppVersionId"); + b.HasKey("Id"); - b.HasIndex("Path", "Name", "Version") - .IsUnique(); + b.HasIndex("PackageId", "Name"); - b.ToTable("AppPlatformVersionFile", (string)null); + b.ToTable("AppPlatformPackageBlobs", (string)null); }); modelBuilder.Entity("LINGYUN.Platform.Datas.DataItem", b => @@ -723,15 +743,15 @@ namespace LY.MicroService.PlatformManagement.Migrations .IsRequired(); }); - modelBuilder.Entity("LINGYUN.Platform.Versions.VersionFile", b => + modelBuilder.Entity("LINGYUN.Platform.Packages.PackageBlob", b => { - b.HasOne("LINGYUN.Platform.Versions.AppVersion", "AppVersion") - .WithMany("Files") - .HasForeignKey("AppVersionId") + b.HasOne("LINGYUN.Platform.Packages.Package", "Package") + .WithMany("Blobs") + .HasForeignKey("PackageId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.Navigation("AppVersion"); + b.Navigation("Package"); }); modelBuilder.Entity("LINGYUN.Platform.Datas.Data", b => @@ -739,9 +759,9 @@ namespace LY.MicroService.PlatformManagement.Migrations b.Navigation("Items"); }); - modelBuilder.Entity("LINGYUN.Platform.Versions.AppVersion", b => + modelBuilder.Entity("LINGYUN.Platform.Packages.Package", b => { - b.Navigation("Files"); + b.Navigation("Blobs"); }); #pragma warning restore 612, 618 } diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Packages/PackageBlobOssManager.cs b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Packages/PackageBlobOssManager.cs new file mode 100644 index 000000000..15f7afa22 --- /dev/null +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Packages/PackageBlobOssManager.cs @@ -0,0 +1,105 @@ +using LINGYUN.Abp.OssManagement; +using LINGYUN.Platform.Packages; +using System; +using System.IO; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.BlobStoring; +using Volo.Abp.Content; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; + +namespace LY.MicroService.PlatformManagement.Packages; + +/// +/// 使用Oss模块管理包二进制文件 +/// +[Dependency(ReplaceServices = true)] +[ExposeServices( + typeof(IPackageBlobManager), + typeof(PackageBlobManager), + typeof(PackageBlobOssManager))] +public class PackageBlobOssManager : PackageBlobManager, ITransientDependency +{ + protected IOssObjectAppService ObjectAppService { get; } + + public PackageBlobOssManager( + IPackageBlobNormalizer blobNormalizer, + IBlobContainer packageContainer, + IOssObjectAppService objectAppService) + : base(blobNormalizer, packageContainer) + { + ObjectAppService = objectAppService; + } + + public async override Task RemoveBlobAsync( + Package package, + PackageBlob packageBlob, + CancellationToken cancellationToken = default) + { + var blobName = BlobNormalizer.Normalize(package, packageBlob); + var bucket = BlobContainerNameAttribute.GetContainerName(); + var path = blobName.Replace(packageBlob.Name, ""); + path.RemovePostFix(Path.PathSeparator.ToString()); + + var input = new GetOssObjectInput + { + Bucket = bucket, + Path = path, + Object = packageBlob.Name + }; + await ObjectAppService.DeleteAsync(input); + } + + protected async override Task DownloadFromBlobAsync( + Package package, + PackageBlob packageBlob, + CancellationToken cancellationToken = default) + { + var blobName = BlobNormalizer.Normalize(package, packageBlob); + var bucket = BlobContainerNameAttribute.GetContainerName(); + var path = blobName.Replace(packageBlob.Name, ""); + path.RemovePostFix(Path.PathSeparator.ToString()); + + var input = new GetOssObjectInput + { + Bucket = bucket, + Path = path, + Object = packageBlob.Name + }; + var ossContent = await ObjectAppService.GetContentAsync(input); + return ossContent.GetStream(); + } + + public async override Task SaveBlobAsync( + Package package, + PackageBlob packageBlob, + Stream stream, + bool overrideExisting = true, + CancellationToken cancellationToken = default) + { + var blobName = BlobNormalizer.Normalize(package, packageBlob); + var bucket = BlobContainerNameAttribute.GetContainerName(); + var path = blobName.Replace(packageBlob.Name, ""); + + var input = new CreateOssObjectInput + { + Bucket = bucket, + Path = path, + FileName= packageBlob.Name, + Overwrite= overrideExisting, + File = new RemoteStreamContent(stream, packageBlob.Name, packageBlob.ContentType) + }; + + var ossObject = await ObjectAppService.CreateAsync(input); + + if (!ossObject.MD5.IsNullOrWhiteSpace()) + { + packageBlob.SetProperty("md5", ossObject.MD5); + } + + stream.Seek(0, SeekOrigin.Begin); + packageBlob.SHA256 = ComputeHash(stream); + packageBlob.SetUrl($"api/platform/packages/{packageBlob.PackageId}/blob/{packageBlob.Name}"); + } +} 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 c0116b3b5..a4ecd9b1d 100644 --- a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.cs @@ -23,6 +23,7 @@ using LINGYUN.Abp.UI.Navigation.VueVbenAdmin; using LINGYUN.Platform; using LINGYUN.Platform.EntityFrameworkCore; using LINGYUN.Platform.HttpApi; +using LINGYUN.Platform.Packages; using LINGYUN.Platform.Theme.VueVbenAdmin; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; 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 df7137706..01dc9c084 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 @@ -1,82 +1,82 @@ - - - - net6.0 - LY.MicroService.RealtimeMessage - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + net6.0 + LY.MicroService.RealtimeMessage + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aspnet-core/tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests.csproj index 035a5cf92..46f74ebf6 100644 --- a/aspnet-core/tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests.csproj @@ -1,19 +1,19 @@ - - - - net6.0 - - false - - - - - - - - - - - - - + + + + net6.0 + + false + + + + + + + + + + + + + diff --git a/aspnet-core/tests/LINGYUN.Abp.ExceptionHandling.Emailing.Tests/LINGYUN.Abp.ExceptionHandling.Emailing.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.ExceptionHandling.Emailing.Tests/LINGYUN.Abp.ExceptionHandling.Emailing.Tests.csproj index 386916da2..0e295cc0f 100644 --- a/aspnet-core/tests/LINGYUN.Abp.ExceptionHandling.Emailing.Tests/LINGYUN.Abp.ExceptionHandling.Emailing.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.ExceptionHandling.Emailing.Tests/LINGYUN.Abp.ExceptionHandling.Emailing.Tests.csproj @@ -1,18 +1,18 @@ - - - - net6.0 - - false - - - - - - - - - - - - + + + + net6.0 + + false + + + + + + + + + + + + diff --git a/aspnet-core/tests/LINGYUN.Abp.Features.LimitValidation.Redis.Tests/LINGYUN.Abp.Features.LimitValidation.Redis.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Features.LimitValidation.Redis.Tests/LINGYUN.Abp.Features.LimitValidation.Redis.Tests.csproj index 843e9a350..f5ce9b05e 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Features.LimitValidation.Redis.Tests/LINGYUN.Abp.Features.LimitValidation.Redis.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Features.LimitValidation.Redis.Tests/LINGYUN.Abp.Features.LimitValidation.Redis.Tests.csproj @@ -1,23 +1,23 @@ - - - - net6.0 - - - false - - - - - - - - - - - - - - - - + + + + net6.0 + + + false + + + + + + + + + + + + + + + + diff --git a/aspnet-core/tests/LINGYUN.Abp.Features.LimitValidation.Tests/LINGYUN.Abp.Features.LimitValidation.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Features.LimitValidation.Tests/LINGYUN.Abp.Features.LimitValidation.Tests.csproj index b9b0d7e0d..165fcda67 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Features.LimitValidation.Tests/LINGYUN.Abp.Features.LimitValidation.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Features.LimitValidation.Tests/LINGYUN.Abp.Features.LimitValidation.Tests.csproj @@ -1,21 +1,21 @@ - - - - net6.0 - - false - - - - - - - - - - - - - - - + + + + net6.0 + + false + + + + + + + + + + + + + + + diff --git a/aspnet-core/tests/LINGYUN.Abp.Localization.Xml.Tests/LINGYUN.Abp.Localization.Xml.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Localization.Xml.Tests/LINGYUN.Abp.Localization.Xml.Tests.csproj index 4b786dd44..97ddff19b 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Localization.Xml.Tests/LINGYUN.Abp.Localization.Xml.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Localization.Xml.Tests/LINGYUN.Abp.Localization.Xml.Tests.csproj @@ -1,37 +1,37 @@ - - - - net6.0 - - false - - - - - - - - - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - - + + + + net6.0 + + false + + + + + + + + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + diff --git a/aspnet-core/tests/LINGYUN.Abp.Location.Baidu.Tests/LINGYUN.Abp.Location.Baidu.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Location.Baidu.Tests/LINGYUN.Abp.Location.Baidu.Tests.csproj index 3073f81e6..ac9361faf 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Location.Baidu.Tests/LINGYUN.Abp.Location.Baidu.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Location.Baidu.Tests/LINGYUN.Abp.Location.Baidu.Tests.csproj @@ -1,27 +1,27 @@ - - - - net6.0 - - false - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - - + + + + net6.0 + + false + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + diff --git a/aspnet-core/tests/LINGYUN.Abp.Location.Tencent.Tests/LINGYUN.Abp.Location.Tencent.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Location.Tencent.Tests/LINGYUN.Abp.Location.Tencent.Tests.csproj index 233439239..99fbc409d 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Location.Tencent.Tests/LINGYUN.Abp.Location.Tencent.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Location.Tencent.Tests/LINGYUN.Abp.Location.Tencent.Tests.csproj @@ -1,27 +1,27 @@ - - - - net6.0 - - false - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - - + + + + net6.0 + + false + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + diff --git a/aspnet-core/tests/LINGYUN.Abp.Rules.RulesEngine.Tests/LINGYUN.Abp.Rules.RulesEngine.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Rules.RulesEngine.Tests/LINGYUN.Abp.Rules.RulesEngine.Tests.csproj index a0410d44d..ef3f8856f 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Rules.RulesEngine.Tests/LINGYUN.Abp.Rules.RulesEngine.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.Rules.RulesEngine.Tests/LINGYUN.Abp.Rules.RulesEngine.Tests.csproj @@ -1,36 +1,36 @@ - - - - net6.0 - - false - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - - - - PreserveNewest - - - PreserveNewest - - - - + + + + net6.0 + + false + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + +