diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NullNotificationStore.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NullNotificationStore.cs new file mode 100644 index 000000000..4aebff7f6 --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NullNotificationStore.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; + +namespace LINGYUN.Abp.Notifications +{ + [Dependency(Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton, TryRegister = true)] + [ExposeServices(typeof(INotificationStore))] + public class NullNotificationStore : INotificationStore + { + public Task ChangeUserNotificationReadStateAsync(Guid? tenantId, Guid userId, long notificationId, NotificationReadState readState) + { + return Task.CompletedTask; + } + + public Task DeleteAllUserSubscriptionAsync(Guid? tenantId, string notificationName) + { + return Task.CompletedTask; + } + + public Task DeleteNotificationAsync(NotificationInfo notification) + { + return Task.CompletedTask; + } + + public Task DeleteNotificationAsync(int batchCount) + { + return Task.CompletedTask; + } + + public Task DeleteUserNotificationAsync(Guid? tenantId, Guid userId, long notificationId) + { + return Task.CompletedTask; + } + + public Task DeleteUserSubscriptionAsync(Guid? tenantId, Guid userId, string notificationName) + { + return Task.CompletedTask; + } + + public Task DeleteUserSubscriptionAsync(Guid? tenantId, IEnumerable identifiers, string notificationName) + { + return Task.CompletedTask; + } + + public Task GetNotificationOrNullAsync(Guid? tenantId, long notificationId) + { + return Task.FromResult(new NotificationInfo()); + } + + public Task> GetSubscriptionsAsync(Guid? tenantId, string notificationName) + { + return Task.FromResult(new List()); + } + + public Task> GetUserNotificationsAsync(Guid? tenantId, Guid userId, NotificationReadState readState = NotificationReadState.UnRead, int maxResultCount = 10) + { + return Task.FromResult(new List()); + } + + public Task> GetUserSubscriptionsAsync(Guid? tenantId, Guid userId) + { + return Task.FromResult(new List()); + } + + public Task> GetUserSubscriptionsAsync(Guid? tenantId, string userName) + { + return Task.FromResult(new List()); + } + + public Task InsertNotificationAsync(NotificationInfo notification) + { + return Task.CompletedTask; + } + + public Task InsertUserNotificationAsync(NotificationInfo notification, Guid userId) + { + return Task.CompletedTask; + } + + public Task InsertUserNotificationsAsync(NotificationInfo notification, IEnumerable userIds) + { + return Task.CompletedTask; + } + + public Task InsertUserSubscriptionAsync(Guid? tenantId, UserIdentifier identifier, string notificationName) + { + return Task.CompletedTask; + } + + public Task InsertUserSubscriptionAsync(Guid? tenantId, IEnumerable identifiers, string notificationName) + { + return Task.CompletedTask; + } + + public Task IsSubscribedAsync(Guid? tenantId, Guid userId, string notificationName) + { + return Task.FromResult(false); + } + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN.Platform.Application.Contracts.csproj b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN.Platform.Application.Contracts.csproj new file mode 100644 index 000000000..ffa1b08ed --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN.Platform.Application.Contracts.csproj @@ -0,0 +1,28 @@ + + + + netstandard2.0 + + true + 3.0.0 + LINGYUN + + + + + D:\LocalNuget + + + + + + + + + + + + + + + diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/PlatformApplicationContractModule.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/PlatformApplicationContractModule.cs new file mode 100644 index 000000000..124a55953 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/PlatformApplicationContractModule.cs @@ -0,0 +1,10 @@ +using Volo.Abp.Modularity; + +namespace LINGYUN.Platform +{ + [DependsOn(typeof(PlatformDomainSharedModule))] + public class PlatformApplicationContractModule : AbpModule + { + + } +} 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 new file mode 100644 index 000000000..d77417546 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionCreateDto.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; + +namespace LINGYUN.Platform.Versions +{ + public class VersionCreateDto + { + /// + /// 标题 + /// + public string Title { get; set; } + /// + /// 版本号 + /// + public string Version { get; set; } + /// + /// 描述 + /// + public string Description { get; set; } + /// + /// 重要级别 + /// + public ImportantLevel Level { get; set; } = ImportantLevel.Low; + + public List VersionFiles { get; set; } = new List(); + } +} 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 new file mode 100644 index 000000000..7d3f707bb --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionDeleteDto.cs @@ -0,0 +1,7 @@ +namespace LINGYUN.Platform.Versions +{ + public class VersionDeleteDto + { + public string Version { 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 new file mode 100644 index 000000000..cace34964 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionDto.cs @@ -0,0 +1,30 @@ +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 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 new file mode 100644 index 000000000..2b95f1925 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileCreateDto.cs @@ -0,0 +1,45 @@ +using Newtonsoft.Json; +using System; +using System.ComponentModel.DataAnnotations; + +namespace LINGYUN.Platform.Versions +{ + public class VersionFileCreateDto + { + [Required] + public Guid VersionId { get; set; } + + [Required] + public string Version { 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 new file mode 100644 index 000000000..afa3cfd10 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileDeleteDto.cs @@ -0,0 +1,10 @@ +using System; + +namespace LINGYUN.Platform.Versions +{ + public class VersionFileDeleteDto + { + public Guid VersionId { get; set; } + 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 new file mode 100644 index 000000000..f5c060199 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileDto.cs @@ -0,0 +1,29 @@ +using Newtonsoft.Json; + +namespace LINGYUN.Platform.Versions +{ + public class VersionFileDto + { + /// + /// 文件名称 + /// + 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 new file mode 100644 index 000000000..85330f3d5 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionFileGetDto.cs @@ -0,0 +1,11 @@ +using System; + +namespace LINGYUN.Platform.Versions +{ + public class VersionFileGetDto + { + public string Version { get; set; } + public string FileName { get; set; } + 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 new file mode 100644 index 000000000..2b4d24ebf --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionGetByIdDto.cs @@ -0,0 +1,9 @@ +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 new file mode 100644 index 000000000..bacfcb1ad --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/Dto/VersionGetByPagedDto.cs @@ -0,0 +1,9 @@ +using Volo.Abp.Application.Dtos; + +namespace LINGYUN.Platform.Versions +{ + public class VersionGetByPagedDto : PagedAndSortedResultRequestDto + { + public string Filter { get; set; } + } +} 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 new file mode 100644 index 000000000..65365d3d7 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Versions/IVersionAppService.cs @@ -0,0 +1,27 @@ +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; + +namespace LINGYUN.Platform.Versions +{ + public interface IVersionAppService : IApplicationService + { + Task GetLastestAsync(); + + 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.Application.csproj b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN.Platform.Application.csproj new file mode 100644 index 000000000..34b2f5378 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN.Platform.Application.csproj @@ -0,0 +1,21 @@ + + + + netstandard2.0 + + true + 3.0.0 + LINGYUN + + + + + D:\LocalNuget + + + + + + + + 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 new file mode 100644 index 000000000..71419ecb9 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationMappingProfile.cs @@ -0,0 +1,14 @@ +using AutoMapper; +using LINGYUN.Platform.Versions; + +namespace LINGYUN.Platform +{ + public class PlatformApplicationMappingProfile : Profile + { + public PlatformApplicationMappingProfile() + { + CreateMap(); + CreateMap(); + } + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationModule.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationModule.cs new file mode 100644 index 000000000..91fa001f7 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationModule.cs @@ -0,0 +1,20 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.AutoMapper; +using Volo.Abp.Modularity; + +namespace LINGYUN.Platform +{ + [DependsOn(typeof(PlatformApplicationContractModule))] + public class PlatformApplicationModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddAutoMapperObjectMapper(); + + Configure(options => + { + options.AddProfile(validate: true); + }); + } + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationServiceBase.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationServiceBase.cs new file mode 100644 index 000000000..9da28d2d0 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/PlatformApplicationServiceBase.cs @@ -0,0 +1,12 @@ +using Volo.Abp.Application.Services; + +namespace LINGYUN.Platform +{ + public abstract class PlatformApplicationServiceBase : ApplicationService + { + protected PlatformApplicationServiceBase() + { + + } + } +} 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 new file mode 100644 index 000000000..a40ce7c6f --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Versions/VersionAppService.cs @@ -0,0 +1,93 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Application.Dtos; + +namespace LINGYUN.Platform.Versions +{ + public class VersionAppService : PlatformApplicationServiceBase, IVersionAppService + { + private readonly VersionManager _versionManager; + public VersionAppService( + VersionManager versionManager) + { + _versionManager = versionManager; + } + + public virtual async Task AppendFileAsync(VersionFileCreateDto versionFileCreate) + { + await _versionManager.AppendFileAsync(versionFileCreate.VersionId, + versionFileCreate.SHA256, versionFileCreate.FileName, versionFileCreate.FileVersion, + versionFileCreate.TotalByte, versionFileCreate.FileType); + } + + public virtual async Task CreateAsync(VersionCreateDto versionCreate) + { + if (await _versionManager.ExistsAsync(versionCreate.Version)) + { + throw new UserFriendlyException("VersionAlreadyExists"); + } + var version = new AppVersion(GuidGenerator.Create(), versionCreate.Title, + versionCreate.Version, CurrentTenant.Id) + { + Description = versionCreate.Description, + Level = versionCreate.Level + }; + + await _versionManager.CreateAsync(version); + + return ObjectMapper.Map(version); + } + + public virtual async Task DeleteAsync(VersionDeleteDto versionDelete) + { + var version = await _versionManager.GetByVersionAsync(versionDelete.Version); + if (version != null) + { + await _versionManager.DeleteAsync(version.Id); + } + } + + public virtual async Task> GetAsync(VersionGetByPagedDto versionGetByPaged) + { + var versionCount = await _versionManager.GetCountAsync(versionGetByPaged.Filter); + var versions = await _versionManager.GetPagedListAsync(versionGetByPaged.Filter, + versionGetByPaged.Sorting, true, + versionGetByPaged.SkipCount, versionGetByPaged.MaxResultCount); + + return new PagedResultDto(versionCount, + ObjectMapper.Map, List>(versions)); + } + + public virtual async Task GetAsync(VersionGetByIdDto versionGetById) + { + var version = await _versionManager.GetByIdAsync(versionGetById.Id); + + return ObjectMapper.Map(version); + } + + public virtual async Task GetLastestAsync() + { + var version = await _versionManager.GetLatestAsync(); + + return ObjectMapper.Map(version); + } + + public virtual async Task RemoveAllFileAsync(VersionGetByIdDto versionGetById) + { + await _versionManager.RemoveAllFileAsync(versionGetById.Id); + } + + public virtual async 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.Domain.Shared.csproj b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN.Platform.Domain.Shared.csproj new file mode 100644 index 000000000..0359b2d09 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN.Platform.Domain.Shared.csproj @@ -0,0 +1,30 @@ + + + + netstandard2.0 + + true + 3.0.0 + LINGYUN + + + + + D:\LocalNuget + + + + + + + + + + + + + + + + + diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/PlatformResource.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/PlatformResource.cs new file mode 100644 index 000000000..cb20541b4 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/PlatformResource.cs @@ -0,0 +1,10 @@ +using Volo.Abp.Localization; + +namespace LINGYUN.Platform.Localization +{ + [LocalizationResourceName("AppPlatform")] + public class PlatformResource + { + + } +} 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 new file mode 100644 index 000000000..aad2c838f --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/en.json @@ -0,0 +1,11 @@ +{ + "culture": "en", + "texts": { + "UploadFileSizeBeyondLimit": "Upload file size cannot exceed {0} MB!", + "NotAllowedFileExtensionName": "Not allowed file extension: {0}!", + "DisplayName:VersionFileLimitLength": "File limit size", + "Description:VersionFileLimitLength": "Limit size of uploaded file in MB", + "DisplayName:AllowVersionFileExtensions": "File extension", + "Description:AllowVersionFileExtensions": "List of allowed extensions to upload files, with multiple extensions separated by, don't need a notation" + } +} \ No newline at end of file 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 new file mode 100644 index 000000000..dcb79b404 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Localization/Resources/zh-Hans.json @@ -0,0 +1,11 @@ +{ + "culture": "zh-Hans", + "texts": { + "UploadFileSizeBeyondLimit": "上传文件大小不能超过 {0} MB!", + "NotAllowedFileExtensionName": "不被允许的文件扩展名: {0}!", + "DisplayName:VersionFileLimitLength": "文件限制大小", + "Description:VersionFileLimitLength": "上传文件的限制大小,单位(MB)", + "DisplayName:AllowVersionFileExtensions": "文件扩展名", + "Description:AllowVersionFileExtensions": "允许的上传文件扩展名列表,多个扩展名以,分隔,无需输入.符号" + } +} \ No newline at end of file diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/ObjectExtending/PlatformModuleExtensionConfigurationDictionaryExtensions.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/ObjectExtending/PlatformModuleExtensionConfigurationDictionaryExtensions.cs new file mode 100644 index 000000000..3c37991d1 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/ObjectExtending/PlatformModuleExtensionConfigurationDictionaryExtensions.cs @@ -0,0 +1,18 @@ +using System; +using Volo.Abp.ObjectExtending.Modularity; + +namespace LINGYUN.Platform.ObjectExtending +{ + public static class PlatformModuleExtensionConfigurationDictionaryExtensions + { + public static ModuleExtensionConfigurationDictionary ConfigurePlatform( + this ModuleExtensionConfigurationDictionary modules, + Action configureAction) + { + return modules.ConfigureModule( + PlatformModuleExtensionConsts.ModuleName, + configureAction + ); + } + } +} 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 new file mode 100644 index 000000000..b7b7a46b8 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/ObjectExtending/PlatformModuleExtensionConsts.cs @@ -0,0 +1,14 @@ +namespace LINGYUN.Platform.ObjectExtending +{ + public class PlatformModuleExtensionConsts + { + public const string ModuleName = "AppPlatform"; + + public static class EntityNames + { + public const string Route = "Route"; + + public const string AppVersion = "AppVersion"; + } + } +} 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 new file mode 100644 index 000000000..808bb168b --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/ObjectExtending/PlatfromModuleExtensionConfiguration.cs @@ -0,0 +1,26 @@ +using System; +using Volo.Abp.ObjectExtending.Modularity; + +namespace LINGYUN.Platform.ObjectExtending +{ + public class PlatfromModuleExtensionConfiguration : ModuleExtensionConfiguration + { + public PlatfromModuleExtensionConfiguration ConfigureRoute( + Action configureAction) + { + return this.ConfigureEntity( + PlatformModuleExtensionConsts.EntityNames.Route, + configureAction + ); + } + + public PlatfromModuleExtensionConfiguration ConfigureAppVersion( + Action configureAction) + { + return this.ConfigureEntity( + PlatformModuleExtensionConsts.EntityNames.AppVersion, + configureAction + ); + } + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/PlatformDomainSharedModule.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/PlatformDomainSharedModule.cs new file mode 100644 index 000000000..5a755b048 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/PlatformDomainSharedModule.cs @@ -0,0 +1,34 @@ +using LINGYUN.Platform.Localization; +using Volo.Abp.Localization; +using Volo.Abp.Localization.ExceptionHandling; +using Volo.Abp.Modularity; +using Volo.Abp.Validation.Localization; +using Volo.Abp.VirtualFileSystem; + +namespace LINGYUN.Platform +{ + [DependsOn(typeof(AbpLocalizationModule))] + public class PlatformDomainSharedModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.FileSets.AddEmbedded(); + }); + + Configure(options => + { + options.Resources + .Add("en") + .AddBaseTypes(typeof(AbpValidationResource)) + .AddVirtualJson("/LINGYUN/Platform/Localization/Resources"); + }); + + Configure(options => + { + options.MapCodeNamespace("LINGYUN.Platform", typeof(AbpValidationResource)); + }); + } + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/PlatformType.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/PlatformType.cs new file mode 100644 index 000000000..3869af371 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/PlatformType.cs @@ -0,0 +1,60 @@ +using System; + +namespace LINGYUN.Platform +{ + /// + /// 平台类型 + /// + [Flags] + public enum PlatformType + { + /// + /// 未定义 + /// + None = 0, + /// + /// Windows CE + /// + WinCe = 2, + /// + /// Windows NT + /// + WinForm = 4, + /// + /// Windows桌面通用 + /// + Desktop = WinCe | WinForm, + /// + /// WebForm + /// + WebForm = 8, + /// + /// MVC + /// + WebMvc = 16, + /// + /// 其他Mvvm架构 + /// + WebMvvm = 32, + /// + /// Web通用 + /// + Web = WebForm | WebMvc, + /// + /// Android + /// + Android = 64, + /// + /// IOS + /// + iOS = 128, + /// + /// 移动端通用 + /// + Mobile = Android | iOS, + /// + /// 所有平台通用 + /// + All = Desktop | Web | Mobile + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Routes/RoleRouteConsts.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Routes/RoleRouteConsts.cs new file mode 100644 index 000000000..63f382a13 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Routes/RoleRouteConsts.cs @@ -0,0 +1,11 @@ +namespace LINGYUN.Platform.Routes +{ + public class RoleRouteConsts + { + public static int MaxRoleNameLength + { + get; + set; + } = 256; + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Routes/RoleRouteEto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Routes/RoleRouteEto.cs new file mode 100644 index 000000000..6f6a0eabf --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Routes/RoleRouteEto.cs @@ -0,0 +1,12 @@ +using System; +using Volo.Abp.MultiTenancy; + +namespace LINGYUN.Platform.Routes +{ + public class RoleRouteEto : IMultiTenant + { + public Guid? TenantId { get; set; } + public Guid RouteId { get; set; } + public string RoleName { get; set; } + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Routes/RouteConsts.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Routes/RouteConsts.cs new file mode 100644 index 000000000..605d76431 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Routes/RouteConsts.cs @@ -0,0 +1,53 @@ +namespace LINGYUN.Platform.Routes +{ + public class RouteConsts + { + public static int MaxNameLength + { + get; + set; + } = 64; + + public static int MaxFullNameLength + { + get; + set; + } = 128; + + public static int MaxDisplayNameLength + { + get; + set; + } = 128; + + public static int MaxDescriptionLength + { + get; + set; + } = 255; + + public static int MaxIconLength + { + get; + set; + } = 128; + + public static int MaxLinkUrlLength + { + get; + set; + } = 255; + /// + /// 层级深度 + /// + public const int MaxDepth = 16; + /// + /// 编码长度 + /// + public const int CodeUnitLength = 5; + /// + /// 编号最大长度 + /// + public const int MaxCodeLength = MaxDepth * (CodeUnitLength + 1) - 1; + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Routes/RouteEto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Routes/RouteEto.cs new file mode 100644 index 000000000..94855b2e8 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Routes/RouteEto.cs @@ -0,0 +1,17 @@ +using System; +using Volo.Abp.MultiTenancy; + +namespace LINGYUN.Platform.Routes +{ + public class RouteEto : IMultiTenant + { + public Guid? TenantId { get; set; } + public Guid Id { get; set; } + public string Code { get; set; } + public string Name { get; set; } + public string DisplayName { get; set; } + public string LinkUrl { get; set; } + public string Icon { get; set; } + public PlatformType PlatformType { get; set; } + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Routes/UserRouteEto.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Routes/UserRouteEto.cs new file mode 100644 index 000000000..75409b0b5 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Routes/UserRouteEto.cs @@ -0,0 +1,12 @@ +using System; +using Volo.Abp.MultiTenancy; + +namespace LINGYUN.Platform.Routes +{ + public class UserRouteEto : IMultiTenant + { + public Guid? TenantId { get; set; } + public Guid RouteId { get; set; } + public Guid UserId { get; set; } + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Settings/PlatformSettingNames.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Settings/PlatformSettingNames.cs new file mode 100644 index 000000000..2aeb8247c --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Settings/PlatformSettingNames.cs @@ -0,0 +1,20 @@ +namespace LINGYUN.Platform.Settings +{ + public class PlatformSettingNames + { + public const string GroupName = "AppPlatform"; + + public class AppVersion + { + public const string Default = GroupName + ".AppVersion"; + /// + /// 文件限制长度 + /// + public const string VersionFileLimitLength = Default + ".VersionFileLimitLength"; + /// + /// 允许的文件扩展名类型 + /// + public const string AllowVersionFileExtensions = Default + ".AllowVersionFileExtensions"; + } + } +} 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 new file mode 100644 index 000000000..59b6a26e3 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/AppVersionConsts.cs @@ -0,0 +1,14 @@ +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 new file mode 100644 index 000000000..aa82205e8 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/AppVersionEto.cs @@ -0,0 +1,33 @@ +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 new file mode 100644 index 000000000..195eb3f90 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/FileType.cs @@ -0,0 +1,21 @@ +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 new file mode 100644 index 000000000..5a98a5ffb --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/IVersionFileManager.cs @@ -0,0 +1,11 @@ +using System.IO; +using System.Threading.Tasks; + +namespace LINGYUN.Platform.Versions +{ + public interface IVersionFileManager + { + Task AppendFileAsync(string version, string fileName, string fileVersion, byte[] data); + Task GetFileAsync(string version, 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 new file mode 100644 index 000000000..72db7a119 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/ImportantLevel.cs @@ -0,0 +1,22 @@ +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 new file mode 100644 index 000000000..3ba0274fa --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN/Platform/Versions/VersionFileConsts.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace LINGYUN.Platform.Versions +{ + public static class VersionFileConsts + { + public const int MaxNameLength = 255; + + public const int MaxVersionLength = 20; + + public const int MaxSHA256Length = 65; + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN.Platform.Domain.csproj b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN.Platform.Domain.csproj new file mode 100644 index 000000000..d4418e5fc --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN.Platform.Domain.csproj @@ -0,0 +1,27 @@ + + + + netstandard2.0 + + true + 3.0.0 + LINGYUN + + + + + D:\LocalNuget + + + + + + + + + + + + + + diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/PlatformDbProperties.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/PlatformDbProperties.cs new file mode 100644 index 000000000..b6cc902a0 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/PlatformDbProperties.cs @@ -0,0 +1,11 @@ +namespace LINGYUN.Platform +{ + public static class PlatformDbProperties + { + public static string DbTablePrefix { get; set; } = "AppPlatform"; + + public static string DbSchema { get; set; } = null; + + public const string ConnectionStringName = "AppPlatform"; + } +} 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 new file mode 100644 index 000000000..9c6016ad2 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/PlatformDomainMappingProfile.cs @@ -0,0 +1,19 @@ +using AutoMapper; +using LINGYUN.Platform.Routes; +using LINGYUN.Platform.Versions; + +namespace LINGYUN.Platform +{ + public class PlatformDomainMappingProfile : Profile + { + public PlatformDomainMappingProfile() + { + CreateMap(); + CreateMap(); + CreateMap(); + + CreateMap() + .ForMember(eto => eto.FileCount, map => map.MapFrom(src => src.Files.Count)); + } + } +} 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 new file mode 100644 index 000000000..af6866dda --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/PlatformDomainModule.cs @@ -0,0 +1,60 @@ +using LINGYUN.Platform.ObjectExtending; +using LINGYUN.Platform.Routes; +using LINGYUN.Platform.Versions; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.AutoMapper; +using Volo.Abp.BlobStoring; +using Volo.Abp.Domain.Entities.Events.Distributed; +using Volo.Abp.EventBus; +using Volo.Abp.Modularity; +using Volo.Abp.ObjectExtending.Modularity; + +namespace LINGYUN.Platform +{ + [DependsOn( + typeof(PlatformDomainSharedModule), + typeof(AbpBlobStoringModule), + typeof(AbpEventBusModule))] + public class PlatformDomainModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddAutoMapperObjectMapper(); + + Configure(options => + { + options.AddProfile(validate: true); + }); + + Configure(options => + { + options.Containers.Configure(containerConfiguration => + { + containerConfiguration.IsMultiTenant = true; + }); + }); + + Configure(options => + { + 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) + { + ModuleExtensionConfigurationHelper.ApplyEntityConfigurationToEntity( + PlatformModuleExtensionConsts.ModuleName, + PlatformModuleExtensionConsts.EntityNames.Route, + typeof(Route) + ); + ModuleExtensionConfigurationHelper.ApplyEntityConfigurationToEntity( + PlatformModuleExtensionConsts.ModuleName, + PlatformModuleExtensionConsts.EntityNames.AppVersion, + typeof(AppVersion) + ); + } + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Routes/IRouteRepository.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Routes/IRouteRepository.cs new file mode 100644 index 000000000..38191bad2 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Routes/IRouteRepository.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories; + +namespace LINGYUN.Platform.Routes +{ + public interface IRouteRepository : IBasicRepository + { + Task> GetChildrenAsync( + Guid? parentId, + CancellationToken cancellationToken = default + ); + + Task> GetAllChildrenWithParentCodeAsync( + string code, + Guid? parentId, + CancellationToken cancellationToken = default + ); + + Task GetAsync( + string displayName, + CancellationToken cancellationToken = default + ); + + Task> GetPagedListAsync( + string sorting = null, + int maxResultCount = int.MaxValue, + int skipCount = 0, + CancellationToken cancellationToken = default + ); + + Task> GetRolesRouteAsync( + string roleName, + CancellationToken cancellationToken = default + ); + + Task> GetUsersRouteAsync( + Guid userId, + CancellationToken cancellationToken = default + ); + + Task RemoveAllUsersRouteAsync( + Route route, + CancellationToken cancellationToken = default + ); + + Task RemoveUserRouteAsync( + Guid userId, + Route route, + CancellationToken cancellationToken = default + ); + + Task RemoveAllRolesRouteAsync( + Route route, + CancellationToken cancellationToken = default + ); + + Task RemoveRoleRouteAsync( + string roleName, + Route route, + CancellationToken cancellationToken = default + ); + + Task IsInRouteAsync( + string roleName, + Route route, + CancellationToken cancellationToken = default + ); + + Task IsInRouteAsync( + Guid userId, + Route route, + CancellationToken cancellationToken = default + ); + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Routes/RoleRoute.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Routes/RoleRoute.cs new file mode 100644 index 000000000..6ecf9644a --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Routes/RoleRoute.cs @@ -0,0 +1,31 @@ +using JetBrains.Annotations; +using System; +using Volo.Abp; +using Volo.Abp.Domain.Entities.Auditing; +using Volo.Abp.MultiTenancy; + +namespace LINGYUN.Platform.Routes +{ + public class RoleRoute : FullAuditedEntity, IMultiTenant + { + public virtual Guid? TenantId { get; protected set; } + public virtual string RoleName { get; protected set; } + public virtual Guid RouteId { get; protected set; } + protected RoleRoute() + { + + } + + public RoleRoute(int id) + { + Id = id; + } + + public RoleRoute(Guid routeId, [NotNull] string roleName, Guid? tenantId = null) + { + RouteId = routeId; + TenantId = tenantId; + RoleName = Check.NotNullOrWhiteSpace(roleName, nameof(roleName)); + } + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Routes/Route.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Routes/Route.cs new file mode 100644 index 000000000..244a499d1 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Routes/Route.cs @@ -0,0 +1,190 @@ +using JetBrains.Annotations; +using System; +using System.Collections.Generic; +using System.Linq; +using Volo.Abp; +using Volo.Abp.Domain.Entities.Auditing; +using Volo.Abp.MultiTenancy; + +namespace LINGYUN.Platform.Routes +{ + public class Route : FullAuditedAggregateRoot, IMultiTenant + { + /// + /// 租户标识 + /// + public virtual Guid? TenantId { get; protected set; } + /// + /// 编号 + /// + public virtual string Code { get; set; } + /// + /// 名称 + /// + public virtual string Name { get; protected set; } + /// + /// 全名 + /// + public virtual string FullName { get; set; } + /// + /// 显示名称 + /// + public virtual string DisplayName { get; protected set; } + /// + /// 平台标识 + /// + public virtual PlatformType PlatformType { get; set; } + /// + /// 说明 + /// + public virtual string Description { get; set; } + /// + /// 图标 + /// + public virtual string Icon { get; protected set; } + /// + /// 路由地址 + /// + public virtual string LinkUrl { get; protected set; } + /// + /// 是否菜单 + /// + public virtual bool IsMenu { get; set; } + /// + /// 是否工具栏 + /// + public virtual bool IsToolBar { get; set; } + /// + /// 是否侧边栏 + /// + public virtual bool IsSideBar { get; set; } + /// + /// 是否公共路由 + /// + public virtual bool IsPublic { get; set; } + /// + /// 是否内置 + /// + public virtual bool IsStatic { get; set; } + /// + /// 总是显示根菜单 + /// + public virtual bool AlwaysShow { get; set; } + /// + /// 父级标识 + /// + public virtual Guid? ParentId { get; set; } + protected Route() + { + + } + + public Route(Guid id, string name, string displayName, string url) + { + Id = id; + LinkToUrl(url); + ChangeName(name, displayName); + } + + public void LinkToUrl([NotNull] string linkUrl) + { + LinkUrl = Check.NotNullOrWhiteSpace(linkUrl, nameof(linkUrl)); + } + + public void ChangeIcon(string icon) + { + Icon = icon; + } + + public void ChangeName([NotNull] string name, [CanBeNull] string displayName) + { + Name = Check.NotNullOrWhiteSpace(name, nameof(name)); + DisplayName = displayName; + } + + public static string CreateCode(params int[] numbers) + { + if (numbers.IsNullOrEmpty()) + { + return null; + } + + return numbers.Select(number => number.ToString(new string('0', RouteConsts.CodeUnitLength))).JoinAsString("."); + } + + public static string AppendCode(string parentCode, string childCode) + { + if (childCode.IsNullOrEmpty()) + { + throw new ArgumentNullException(nameof(childCode), "childCode can not be null or empty."); + } + + if (parentCode.IsNullOrEmpty()) + { + return childCode; + } + + return parentCode + "." + childCode; + } + + public static string GetRelativeCode(string code, string parentCode) + { + if (code.IsNullOrEmpty()) + { + throw new ArgumentNullException(nameof(code), "code can not be null or empty."); + } + + if (parentCode.IsNullOrEmpty()) + { + return code; + } + + if (code.Length == parentCode.Length) + { + return null; + } + + return code.Substring(parentCode.Length + 1); + } + + public static string CalculateNextCode(string code) + { + if (code.IsNullOrEmpty()) + { + throw new ArgumentNullException(nameof(code), "code can not be null or empty."); + } + + var parentCode = GetParentCode(code); + var lastUnitCode = GetLastUnitCode(code); + + return AppendCode(parentCode, CreateCode(Convert.ToInt32(lastUnitCode) + 1)); + } + + public static string GetLastUnitCode(string code) + { + if (code.IsNullOrEmpty()) + { + throw new ArgumentNullException(nameof(code), "code can not be null or empty."); + } + + var splittedCode = code.Split('.'); + return splittedCode[splittedCode.Length - 1]; + } + + public static string GetParentCode(string code) + { + if (code.IsNullOrEmpty()) + { + throw new ArgumentNullException(nameof(code), "code can not be null or empty."); + } + + var splittedCode = code.Split('.'); + if (splittedCode.Length == 1) + { + return null; + } + + return splittedCode.Take(splittedCode.Length - 1).JoinAsString("."); + } + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Routes/RouteManager.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Routes/RouteManager.cs new file mode 100644 index 000000000..949beb7bd --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Routes/RouteManager.cs @@ -0,0 +1,139 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp.Domain.Services; +using Volo.Abp.Uow; + +namespace LINGYUN.Platform.Routes +{ + public class RouteManager : DomainService + { + protected IRouteRepository RouteRepository { get; } + public RouteManager( + IRouteRepository routeRepository) + { + RouteRepository = routeRepository; + } + + [UnitOfWork] + public virtual async Task CreateAsync(Route route) + { + route.Code = await GetNextChildCodeAsync(route.ParentId); + await RouteRepository.InsertAsync(route); + } + + public virtual async Task UpdateAsync(Route route) + { + await RouteRepository.UpdateAsync(route); + } + + [UnitOfWork] + public virtual async Task DeleteAsync(Guid id) + { + var children = await FindChildrenAsync(id, true); + + foreach (var child in children) + { + await RouteRepository.RemoveAllUsersRouteAsync(child); + await RouteRepository.RemoveAllRolesRouteAsync(child); + await RouteRepository.DeleteAsync(child); + } + + var organizationUnit = await RouteRepository.GetAsync(id); + + await RouteRepository.RemoveAllUsersRouteAsync(organizationUnit); + await RouteRepository.RemoveAllRolesRouteAsync(organizationUnit); + await RouteRepository.DeleteAsync(id); + } + + [UnitOfWork] + public virtual async Task MoveAsync(Guid id, Guid? parentId) + { + var route = await RouteRepository.GetAsync(id); + if (route.ParentId == parentId) + { + return; + } + + var children = await FindChildrenAsync(id, true); + + var oldCode = route.Code; + + route.Code = await GetNextChildCodeAsync(parentId); + route.ParentId = parentId; + + foreach (var child in children) + { + child.Code = Route.AppendCode(route.Code, Route.GetRelativeCode(child.Code, oldCode)); + } + } + + public virtual async Task RemoveRoleFromRouteAsync(string roleName, Route route) + { + await RouteRepository.RemoveRoleRouteAsync(roleName, route); + } + + public virtual async Task RemoveUserFromRouteAsync(Guid userId, Route route) + { + await RouteRepository.RemoveUserRouteAsync(userId, route); + } + + public virtual async Task GetNextChildCodeAsync(Guid? parentId) + { + var lastChild = await GetLastChildOrNullAsync(parentId); + if (lastChild != null) + { + return Route.CalculateNextCode(lastChild.Code); + } + + var parentCode = parentId != null + ? await GetCodeOrDefaultAsync(parentId.Value) + : null; + + return Route.AppendCode( + parentCode, + Route.CreateCode(1) + ); + } + + public virtual async Task GetLastChildOrNullAsync(Guid? parentId) + { + var children = await RouteRepository.GetChildrenAsync(parentId); + return children.OrderBy(c => c.Code).LastOrDefault(); + } + + public virtual async Task GetCodeOrDefaultAsync(Guid id) + { + var ou = await RouteRepository.GetAsync(id); + return ou?.Code; + } + + public async Task> FindChildrenAsync(Guid? parentId, bool recursive = false) + { + if (!recursive) + { + return await RouteRepository.GetChildrenAsync(parentId); + } + + if (!parentId.HasValue) + { + return await RouteRepository.GetListAsync(); + } + + var code = await GetCodeOrDefaultAsync(parentId.Value); + + return await RouteRepository.GetAllChildrenWithParentCodeAsync(code, parentId); + } + + public virtual async Task IsInRouteAsync(Guid userId, Route route) + { + return await RouteRepository.IsInRouteAsync(userId, route); + } + + public virtual async Task IsInRouteAsync(string roleName, Route route) + { + return await RouteRepository.IsInRouteAsync(roleName, route); + } + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Routes/UserRoute.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Routes/UserRoute.cs new file mode 100644 index 000000000..575846473 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Routes/UserRoute.cs @@ -0,0 +1,29 @@ +using System; +using Volo.Abp.Domain.Entities.Auditing; +using Volo.Abp.MultiTenancy; + +namespace LINGYUN.Platform.Routes +{ + public class UserRoute : FullAuditedEntity, IMultiTenant + { + public virtual Guid? TenantId { get; protected set; } + public virtual Guid UserId { get; protected set; } + public virtual Guid RouteId { get; protected set; } + protected UserRoute() + { + + } + + public UserRoute(int id) + { + Id = id; + } + + public UserRoute(Guid routeId, Guid userId, Guid? tenantId = null) + { + UserId = userId; + RouteId = routeId; + TenantId = tenantId; + } + } +} 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 new file mode 100644 index 000000000..3108202e2 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Settings/PlatformSettingDefinitionProvider.cs @@ -0,0 +1,31 @@ +using LINGYUN.Platform.Localization; +using LINGYUN.Platform.Versions; +using Volo.Abp.Localization; +using Volo.Abp.Settings; + +namespace LINGYUN.Platform.Settings +{ + public class PlatformSettingDefinitionProvider : SettingDefinitionProvider + { + public override void Define(ISettingDefinitionContext context) + { + context.Add(CreateAppVersionSettings()); + } + + protected SettingDefinition[] CreateAppVersionSettings() + { + return new SettingDefinition[] + { + new SettingDefinition(PlatformSettingNames.AppVersion.VersionFileLimitLength, AppVersionConsts.DefaultVersionFileLimitLength.ToString(), + L("DisplayName:VersionFileLimitLength"), L("Description:VersionFileLimitLength"), isVisibleToClients: true), + new SettingDefinition(PlatformSettingNames.AppVersion.AllowVersionFileExtensions, AppVersionConsts.DefaultAllowVersionFileExtensions, + L("DisplayName:AllowVersionFileExtensions"), L("Description:AllowVersionFileExtensions"), isVisibleToClients: true), + }; + } + + protected LocalizableString L(string name) + { + return LocalizableString.Create(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 new file mode 100644 index 000000000..f17173709 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/AppVersion.cs @@ -0,0 +1,95 @@ +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 ICollection Files { get; protected set; } + + protected AppVersion() + { + Files = new List(); + } + + public AppVersion(Guid id, string title, string version, Guid? tenantId = null) + { + Id = id; + Title = title; + Version = version; + TenantId = tenantId; + Level = ImportantLevel.Low; + } + + public void AppendFile(string name, string version, long size, string sha256, FileType fileType = FileType.Stream) + { + if (!FileExists(name)) + { + Files.Add(new VersionFile(name, version, size, sha256, fileType, TenantId)); + } + } + + 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 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 new file mode 100644 index 000000000..3375f00a1 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/IVersionRepository.cs @@ -0,0 +1,21 @@ +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(string version, CancellationToken cancellationToken = default); + + Task GetByVersionAsync(string version, CancellationToken cancellationToken = default); + + Task GetCountAsync(string filter = "", CancellationToken cancellationToken = default); + + Task> GetPagedListAsync(string filter = "", string soring = nameof(AppVersion.CreationTime), bool includeDetails = true, int skipCount = 1, int maxResultCount = 10, CancellationToken cancellationToken = default); + + Task GetLatestVersionAsync(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 new file mode 100644 index 000000000..214fe1c3c --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/VersionContainer.cs @@ -0,0 +1,9 @@ +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 new file mode 100644 index 000000000..e6ce01db7 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/VersionFile.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Text.RegularExpressions; +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 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) + { + var fileNameWithNotExten = fileName; + // 取出文件扩展名 + var fileExten = FileHelper.GetExtension(fileName); + if (!fileExten.IsNullOrWhiteSpace()) + { + // 取出不带扩展名的文件名 + fileNameWithNotExten = fileName.Replace(fileExten, ""); + // 去掉最后一位扩展名符号 + fileNameWithNotExten = fileNameWithNotExten.Remove(fileNameWithNotExten.Length - 1); + } + // 转换不受支持的符号 + fileNameWithNotExten = fileNameWithNotExten.Replace(".", "-"); + // 最终文件名为 应用版本号/文件名(不带扩展名)/文件版本/文件名 + // 例: 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 new file mode 100644 index 000000000..9f8ee1ada --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Versions/VersionManager.cs @@ -0,0 +1,138 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Security.Cryptography; +using System.Threading.Tasks; +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 virtual async Task ExistsAsync(string version) + { + return await VersionRepository.ExistsAsync(version); + } + + public virtual async Task GetByIdAsync(Guid id) + { + return await VersionRepository.GetAsync(id); + } + + public virtual async Task GetByVersionAsync(string version) + { + return await VersionRepository.GetByVersionAsync(version); + } + + public virtual async Task GetCountAsync(string filter) + { + return await VersionRepository.GetCountAsync(filter); + } + + public virtual async Task> GetPagedListAsync(string filter = "", string soring = nameof(AppVersion.CreationTime), bool includeDetails = true, int skipCount = 1, int maxResultCount = 10) + { + return await VersionRepository.GetPagedListAsync(filter, soring, includeDetails, skipCount, maxResultCount); + } + + [UnitOfWork] + public virtual async Task CreateAsync(AppVersion version) + { + await VersionRepository.InsertAsync(version); + } + + + [UnitOfWork] + public virtual async Task UpdateAsync(AppVersion version) + { + await VersionRepository.UpdateAsync(version); + } + + [UnitOfWork] + public virtual async Task DeleteAsync(Guid id) + { + await RemoveAllFileAsync(id); + await VersionRepository.DeleteAsync(id); + } + + public virtual async Task GetLatestAsync() + { + return await VersionRepository.GetLatestVersionAsync(); + } + + public virtual async Task GetFileAsync(string version, string fileName, string fileVersion) + { + return await VersionBlobContainer.GetAsync( + VersionFile.NormalizeBlobName(version, fileName, fileVersion)); + } + public virtual async Task GetFileAsync(VersionFile versionFile) + { + return await GetFileAsync(versionFile.AppVersion.Version, versionFile.Name, versionFile.Version); + } + + public virtual async Task AppendFileAsync(string version, string fileName, string fileVersion, byte[] data) + { + // 计算指纹 + var sha256 = new SHA256Managed(); + var checkHash = sha256.ComputeHash(data); + var sha256Hash = BitConverter.ToString(checkHash).Replace("-", string.Empty); + + await VersionBlobContainer + .SaveAsync(VersionFile.NormalizeBlobName(version, fileName, fileVersion), data, true); + + return sha256Hash; + } + + [UnitOfWork] + public virtual async Task AppendFileAsync(Guid versionId, string fileSha256, + string fileName, string fileVersion, long fileSize, FileType fileType = FileType.Stream) + { + var appVersion = await VersionRepository.GetAsync(versionId); + if (appVersion.FileExists(fileName)) + { + appVersion.RemoveFile(fileName); + } + appVersion.AppendFile(fileName, fileVersion, fileSize, fileSha256, fileType); + } + + [UnitOfWork] + public virtual async 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 virtual async 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.EntityFrameworkCore/LINGYUN.Platform.EntityFrameworkCore.csproj b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN.Platform.EntityFrameworkCore.csproj new file mode 100644 index 000000000..4b20998c2 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN.Platform.EntityFrameworkCore.csproj @@ -0,0 +1,24 @@ + + + + netstandard2.0 + + true + 3.0.0 + LINGYUN + + + + + D:\LocalNuget + + + + + + + + + + + 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 new file mode 100644 index 000000000..5876d6a5d --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/IPlatformDbContext.cs @@ -0,0 +1,15 @@ +using LINGYUN.Platform.Routes; +using LINGYUN.Platform.Versions; +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Data; +using Volo.Abp.EntityFrameworkCore; + +namespace LINGYUN.Platform.EntityFrameworkCore +{ + [ConnectionStringName(PlatformDbProperties.ConnectionStringName)] + public interface IPlatformDbContext : IEfCoreDbContext + { + DbSet Routes { get; set; } + DbSet AppVersions { 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 new file mode 100644 index 000000000..587c5ec29 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContext.cs @@ -0,0 +1,29 @@ +using LINGYUN.Platform.Routes; +using LINGYUN.Platform.Versions; +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Data; +using Volo.Abp.EntityFrameworkCore; + +namespace LINGYUN.Platform.EntityFrameworkCore +{ + [ConnectionStringName(PlatformDbProperties.ConnectionStringName)] + public class PlatformDbContext : AbpDbContext, IPlatformDbContext + { + public DbSet Routes { get; set; } + + public DbSet AppVersions { get; set; } + + public PlatformDbContext(DbContextOptions options) + : base(options) + { + + } + + protected override void OnModelCreating(ModelBuilder builder) + { + base.OnModelCreating(builder); + + builder.ConfigurePlatform(); + } + } +} 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 new file mode 100644 index 000000000..66254f6de --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContextModelBuilderExtensions.cs @@ -0,0 +1,138 @@ +using LINGYUN.Platform.Routes; +using LINGYUN.Platform.Versions; +using Microsoft.EntityFrameworkCore; +using System; +using Volo.Abp; +using Volo.Abp.EntityFrameworkCore.Modeling; + +namespace LINGYUN.Platform.EntityFrameworkCore +{ + public static class PlatformDbContextModelBuilderExtensions + { + public static void ConfigurePlatform( + this ModelBuilder builder, + Action optionsAction = null) + { + Check.NotNull(builder, nameof(builder)); + + var options = new PlatformModelBuilderConfigurationOptions( + PlatformDbProperties.DbTablePrefix, + PlatformDbProperties.DbSchema + ); + + optionsAction?.Invoke(options); + + builder.Entity(x => + { + x.ToTable(options.TablePrefix + "Route"); + + x.Property(p => p.Code) + .IsRequired() + .HasMaxLength(RouteConsts.MaxCodeLength) + .HasColumnName(nameof(Route.Code)); + x.Property(p => p.DisplayName) + .IsRequired() + .HasMaxLength(RouteConsts.MaxDisplayNameLength) + .HasColumnName(nameof(Route.DisplayName)); + x.Property(p => p.LinkUrl) + .IsRequired() + .HasMaxLength(RouteConsts.MaxLinkUrlLength) + .HasColumnName(nameof(Route.LinkUrl)); + x.Property(p => p.Name) + .IsRequired() + .HasMaxLength(RouteConsts.MaxNameLength) + .HasColumnName(nameof(Route.Name)); + + x.Property(p => p.Icon) + .HasMaxLength(RouteConsts.MaxIconLength) + .HasColumnName(nameof(Route.Icon)); + x.Property(p => p.FullName) + .HasMaxLength(RouteConsts.MaxFullNameLength) + .HasColumnName(nameof(Route.FullName)); + x.Property(p => p.Description) + .HasMaxLength(RouteConsts.MaxDescriptionLength) + .HasColumnName(nameof(Route.Description)); + + x.ConfigureByConvention(); + + x.HasMany().WithOne().HasForeignKey(p => p.ParentId); + + x.HasIndex(i => i.Code); + }); + + builder.Entity(x => + { + x.ToTable(options.TablePrefix + "RoleRoute"); + + x.Property(p => p.RoleName) + .IsRequired() + .HasMaxLength(RoleRouteConsts.MaxRoleNameLength) + .HasColumnName(nameof(RoleRoute.RoleName)); + + x.ConfigureMultiTenant(); + + x.HasIndex(i => new { i.RoleName, i.RouteId }); + }); + + builder.Entity(x => + { + x.ToTable(options.TablePrefix + "UserRoute"); + + x.ConfigureMultiTenant(); + + x.HasIndex(i => new { i.UserId, i.RouteId }); + }); + + builder.Entity(x => + { + x.ToTable(options.TablePrefix + "Version", options.Schema); + + x.Property(p => p.Title) + .IsRequired() + .HasColumnName(nameof(AppVersion.Title)) + .HasMaxLength(AppVersionConsts.MaxTitleLength); + x.Property(p => p.Version) + .IsRequired() + .HasColumnName(nameof(AppVersion.Version)) + .HasMaxLength(AppVersionConsts.MaxVersionLength); + + x.Property(p => p.Description) + .HasColumnName(nameof(AppVersion.Description)) + .HasMaxLength(AppVersionConsts.MaxDescriptionLength); + + x.ConfigureByConvention(); + + x.HasIndex(i => i.Version); + + x.HasMany(p => p.Files) + .WithOne(q => q.AppVersion) + .HasPrincipalKey(pk => pk.Id) + .HasForeignKey(fk => fk.AppVersionId) + .OnDelete(DeleteBehavior.Cascade); + }); + + builder.Entity(x => + { + x.ToTable(options.TablePrefix + "VersionFile", 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); + + x.ConfigureAudited(); + x.ConfigureMultiTenant(); + + x.HasIndex(i => new { i.Name, i.Version }); + }); + } + } +} 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 new file mode 100644 index 000000000..3461419c7 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformEntityFrameworkCoreModule.cs @@ -0,0 +1,32 @@ +using LINGYUN.Platform.Routes; +using LINGYUN.Platform.Versions; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.Modularity; + +namespace LINGYUN.Platform.EntityFrameworkCore +{ + [DependsOn( + typeof(PlatformDomainModule), + typeof(AbpEntityFrameworkCoreModule))] + public class PlatformEntityFrameworkCoreModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddAbpDbContext(options => + { + 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/EntityFrameworkCore/PlatformModelBuilderConfigurationOptions.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformModelBuilderConfigurationOptions.cs new file mode 100644 index 000000000..260ea5b4f --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformModelBuilderConfigurationOptions.cs @@ -0,0 +1,18 @@ +using JetBrains.Annotations; +using Volo.Abp.EntityFrameworkCore.Modeling; + +namespace LINGYUN.Platform.EntityFrameworkCore +{ + public class PlatformModelBuilderConfigurationOptions : AbpModelBuilderConfigurationOptions + { + public PlatformModelBuilderConfigurationOptions( + [NotNull] string tablePrefix = "", + [CanBeNull] string schema = null) + : base( + tablePrefix, + schema) + { + + } + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Routes/EfCoreRouteRepository.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Routes/EfCoreRouteRepository.cs new file mode 100644 index 000000000..fb4aa061e --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Routes/EfCoreRouteRepository.cs @@ -0,0 +1,141 @@ +using LINGYUN.Platform.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Dynamic.Core; +using System.Security.Cryptography.X509Certificates; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Domain.Repositories.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore; + +namespace LINGYUN.Platform.Routes +{ + public class EfCoreRouteRepository : EfCoreRepository, IRouteRepository, ITransientDependency + { + public EfCoreRouteRepository( + IDbContextProvider dbContextProvider) + : base(dbContextProvider) + { + } + + public virtual async Task> GetAllChildrenWithParentCodeAsync(string code, Guid? parentId, CancellationToken cancellationToken = default) + { + return await DbSet + .Where(ou => ou.Code.StartsWith(code) && ou.Id != parentId.Value) + .ToListAsync(GetCancellationToken(cancellationToken)); + } + + public virtual async Task GetAsync(string displayName, CancellationToken cancellationToken = default) + { + return await DbSet + .FirstOrDefaultAsync( + ou => ou.DisplayName == displayName, + GetCancellationToken(cancellationToken) + ); + } + + public virtual async Task> GetChildrenAsync(Guid? parentId, CancellationToken cancellationToken = default) + { + return await DbSet + .Where(x => x.ParentId == parentId) + .ToListAsync(GetCancellationToken(cancellationToken)); + } + + public virtual async Task> GetPagedListAsync(string sorting = null, int maxResultCount = int.MaxValue, int skipCount = 0, CancellationToken cancellationToken = default) + { + return await DbSet + .OrderBy(sorting ?? nameof(Route.Code)) + .Page(skipCount, maxResultCount) + .ToListAsync(GetCancellationToken(cancellationToken)); + } + + public virtual async Task> GetRolesRouteAsync(string roleName, CancellationToken cancellationToken = default) + { + var roleRoutes = await (from route in DbSet + join roleRoute in DbContext.Set() + on route.Id equals roleRoute.RouteId + where roleRoute.RoleName.Equals(roleName) + select route) + .ToListAsync(GetCancellationToken(cancellationToken)); + + return roleRoutes; + } + + public virtual async Task> GetUsersRouteAsync(Guid userId, CancellationToken cancellationToken = default) + { + var userRoutes = await (from route in DbSet + join userRoute in DbContext.Set() + on route.Id equals userRoute.RouteId + where userRoute.UserId.Equals(userId) + select route) + .ToListAsync(GetCancellationToken(cancellationToken)); + + return userRoutes; + } + + public virtual async Task IsInRouteAsync(string roleName, Route route, CancellationToken cancellationToken = default) + { + return await DbContext.Set() + .AnyAsync(x => x.RouteId.Equals(route.Id) && x.RoleName.Equals(roleName), + GetCancellationToken(cancellationToken)); + } + + public virtual async Task IsInRouteAsync(Guid userId, Route route, CancellationToken cancellationToken = default) + { + return await DbContext.Set() + .AnyAsync(x => x.RouteId.Equals(route.Id) && x.UserId.Equals(userId), + GetCancellationToken(cancellationToken)); + } + + public virtual async Task RemoveAllRolesRouteAsync(Route route, CancellationToken cancellationToken = default) + { + var roleRoutes = await DbContext.Set() + .Where(x => x.RouteId.Equals(route.Id)) + .Select(x => new RoleRoute(x.Id)) + .AsNoTracking() + .ToArrayAsync(GetCancellationToken(cancellationToken)); + + DbContext.Set().AttachRange(roleRoutes); + DbContext.Set().RemoveRange(roleRoutes); + } + + public virtual async Task RemoveAllUsersRouteAsync(Route route, CancellationToken cancellationToken = default) + { + var userRoutes = await DbContext.Set() + .Where(x => x.RouteId.Equals(route.Id)) + .Select(x => new UserRoute(x.Id)) + .AsNoTracking() + .ToArrayAsync(GetCancellationToken(cancellationToken)); + + DbContext.Set().AttachRange(userRoutes); + DbContext.Set().RemoveRange(userRoutes); + } + + public virtual async Task RemoveRoleRouteAsync(string roleName, Route route, CancellationToken cancellationToken = default) + { + var roleRoutes = await DbContext.Set() + .Where(x => x.RouteId.Equals(route.Id) && x.RoleName.Equals(roleName)) + .Select(x => new RoleRoute(x.Id)) + .AsNoTracking() + .ToArrayAsync(GetCancellationToken(cancellationToken)); + + DbContext.Set().AttachRange(roleRoutes); + DbContext.Set().RemoveRange(roleRoutes); + } + + public virtual async Task RemoveUserRouteAsync(Guid userId, Route route, CancellationToken cancellationToken = default) + { + var userRoutes = await DbContext.Set() + .Where(x => x.RouteId.Equals(route.Id) && x.UserId.Equals(userId)) + .Select(x => new UserRoute(x.Id)) + .AsNoTracking() + .ToArrayAsync(GetCancellationToken(cancellationToken)); + + DbContext.Set().AttachRange(userRoutes); + DbContext.Set().RemoveRange(userRoutes); + } + } +} 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 new file mode 100644 index 000000000..b6f730ac4 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Versions/EfCoreVersionRepository.cs @@ -0,0 +1,63 @@ +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 virtual async Task GetCountAsync(string filter = "", CancellationToken cancellationToken = default) + { + return await DbSet + .WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Version.Contains(filter) || x.Title.Contains(filter)) + .LongCountAsync(GetCancellationToken(cancellationToken)); + } + + public virtual async Task> GetPagedListAsync(string filter = "", string soring = nameof(AppVersion.CreationTime), bool includeDetails = true, int skipCount = 1, int maxResultCount = 10, CancellationToken cancellationToken = default) + { + return await DbSet + .IncludeIf(includeDetails, x => x.Files) + .WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Version.Contains(filter) || x.Title.Contains(filter)) + .OrderBy(soring ?? "") // TODO: 排序待优化 + .Page(skipCount, maxResultCount) + .ToListAsync(GetCancellationToken(cancellationToken)); + } + + + public virtual async Task ExistsAsync(string version, CancellationToken cancellationToken = default) + { + return await DbSet + .AnyAsync(x => x.Version.Equals(version), GetCancellationToken(cancellationToken)); + } + + public virtual async Task GetByVersionAsync(string version, CancellationToken cancellationToken = default) + { + return await DbSet + .Include(x => x.Files) + .Where(x => x.Version.Equals(version)) + .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); + } + + public virtual async Task GetLatestVersionAsync(CancellationToken cancellationToken = default) + { + return await DbSet + .Include(x => x.Files) + .OrderByDescending(x => x.CreationTime) + .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); + } + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN.Platform.HttpApi.csproj b/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN.Platform.HttpApi.csproj new file mode 100644 index 000000000..43ba3dcaa --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN.Platform.HttpApi.csproj @@ -0,0 +1,24 @@ + + + + netcoreapp3.1 + + true + 3.0.0 + LINGYUN + + + + + D:\LocalNuget + + + + + + + + + + + diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/PlatformControllerBase.cs b/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/PlatformControllerBase.cs new file mode 100644 index 000000000..94c25092b --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/PlatformControllerBase.cs @@ -0,0 +1,17 @@ +using LINGYUN.Platform.Localization; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Settings; + +namespace LINGYUN.Platform +{ + public abstract class PlatformControllerBase : AbpController + { + private ISettingProvider _settingProvider; + protected ISettingProvider SettingProvider => LazyGetRequiredService(ref _settingProvider); + + protected PlatformControllerBase() + { + LocalizationResource = typeof(PlatformResource); + } + } +} diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/PlatformHttpApiModule.cs b/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/PlatformHttpApiModule.cs new file mode 100644 index 000000000..b7aa8ce52 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/PlatformHttpApiModule.cs @@ -0,0 +1,31 @@ +using Microsoft.AspNetCore.Http.Features; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Modularity; + +namespace LINGYUN.Platform.HttpApi +{ + [DependsOn( + typeof(PlatformApplicationContractModule), + typeof(AbpAspNetCoreMvcModule))] + public class PlatformHttpApiModule : AbpModule + { + public override void PreConfigureServices(ServiceConfigurationContext context) + { + PreConfigure(mvcBuilder => + { + mvcBuilder.AddApplicationPartIfNotExists(typeof(PlatformApplicationContractModule).Assembly); + }); + } + + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.ValueLengthLimit = int.MaxValue; + options.MultipartBodyLengthLimit = int.MaxValue; + options.MultipartHeadersLengthLimit = int.MaxValue; + }); + } + } +} 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 new file mode 100644 index 000000000..642207454 --- /dev/null +++ b/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/Versions/VersionController.cs @@ -0,0 +1,217 @@ +using LINGYUN.Platform.Settings; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.StaticFiles; +using System; +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 +{ + [Area("platform")] + [Route("api/platform/version")] + public class VersionController : PlatformControllerBase + { + private readonly IVersionFileManager _versionFileManager; + private readonly IVersionAppService _versionAppService; + + public VersionController( + IVersionAppService versionAppService, + IVersionFileManager versionFileManager) + { + _versionAppService = versionAppService; + _versionFileManager = versionFileManager; + } + + [HttpPost] + [Route("file/append")] + public virtual async 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.AppendFileAsync(versionFileCreate.Version, + versionFileCreate.FileName, versionFileCreate.FileVersion, fileData); + } + // 添加到版本信息 + await _versionAppService.AppendFileAsync(versionFileCreate); + // 文件保存之后删除临时文件目录 + Directory.Delete(tempFilePath, true); + } + } + catch + { + // 发生异常删除临时文件目录 + Directory.Delete(tempFilePath, true); + throw; + } + } + + [HttpPost] + public virtual async Task CreateAsync(VersionCreateDto versionCreate) + { + return await _versionAppService.CreateAsync(versionCreate); + } + + [HttpDelete] + public virtual async Task DeleteAsync(VersionDeleteDto versionDelete) + { + await _versionAppService.DeleteAsync(versionDelete); + } + + [HttpGet] + public virtual async Task> GetAsync(VersionGetByPagedDto versionGetByPaged) + { + return await _versionAppService.GetAsync(versionGetByPaged); + } + + [HttpGet] + [Route("{Id}")] + public virtual async Task GetAsync(VersionGetByIdDto versionGetById) + { + return await _versionAppService.GetAsync(versionGetById); + } + + [HttpGet] + [Route("lastest")] + public virtual async Task GetLastestAsync() + { + return await _versionAppService.GetLastestAsync(); + } + + [HttpDelete] + [Route("file/clean")] + public virtual async Task RemoveAllFileAsync(VersionGetByIdDto versionGetById) + { + await _versionAppService.RemoveAllFileAsync(versionGetById); + } + + [HttpDelete] + [Route("file/remove")] + public virtual async Task RemoveFileAsync(VersionFileDeleteDto versionFileDelete) + { + await _versionAppService.RemoveFileAsync(versionFileDelete); + } + + [HttpGet] + [Route("file/download")] + public virtual async Task DownloadFileAsync(VersionFileGetDto versionFileGet) + { + // 分块模式下载文件 + + // 得到文件流 + var fileStream = await _versionFileManager.GetFileAsync( + versionFileGet.Version, 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/services/admin/LINGYUN.BackendAdminApp.Host/.gitignore b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/.gitignore new file mode 100644 index 000000000..53f2c2fc2 --- /dev/null +++ b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/.gitignore @@ -0,0 +1,4 @@ +bin +obj +Logs +appsettings.*.json \ No newline at end of file diff --git a/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/BackendAdminHostModule.cs b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/BackendAdminHostModule.cs new file mode 100644 index 000000000..6bf20a1ef --- /dev/null +++ b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/BackendAdminHostModule.cs @@ -0,0 +1,257 @@ +using DotNetCore.CAP; +using IdentityModel; +using LINGYUN.Abp.EventBus.CAP; +using LINGYUN.Abp.ExceptionHandling; +using LINGYUN.Abp.ExceptionHandling.Emailing; +using LINGYUN.Abp.IdentityServer; +using LINGYUN.Abp.Location.Tencent; +using LINGYUN.Abp.MessageService; +using LINGYUN.Abp.SettingManagement; +using LINGYUN.Abp.TenantManagement; +using LINGYUN.ApiGateway; +using LINGYUN.BackendAdmin.MultiTenancy; +using LINYUN.Abp.Sms.Aliyun; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Identity; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.OpenApi.Models; +using StackExchange.Redis; +using System; +using System.Collections.Generic; +using System.Text; +using Volo.Abp; +using Volo.Abp.Account; +using Volo.Abp.AspNetCore.Authentication.JwtBearer; +using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy; +using Volo.Abp.Authorization.Permissions; +using Volo.Abp.Autofac; +using Volo.Abp.Caching; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore.MySQL; +using Volo.Abp.Identity; +using Volo.Abp.Identity.EntityFrameworkCore; +using Volo.Abp.Identity.Localization; +using Volo.Abp.IdentityServer.EntityFrameworkCore; +using Volo.Abp.Localization; +using Volo.Abp.Modularity; +using Volo.Abp.MultiTenancy; +using Volo.Abp.PermissionManagement; +using Volo.Abp.PermissionManagement.EntityFrameworkCore; +using Volo.Abp.PermissionManagement.HttpApi; +using Volo.Abp.PermissionManagement.Identity; +using Volo.Abp.PermissionManagement.IdentityServer; +using Volo.Abp.Security.Claims; +using Volo.Abp.Security.Encryption; +using Volo.Abp.SettingManagement.EntityFrameworkCore; +using Volo.Abp.TenantManagement.EntityFrameworkCore; +using Volo.Abp.VirtualFileSystem; +namespace LINGYUN.BackendAdmin +{ + [DependsOn( + typeof(AbpAspNetCoreMvcUiMultiTenancyModule), + typeof(AbpPermissionManagementDomainIdentityModule), + typeof(AbpPermissionManagementDomainIdentityServerModule), + typeof(ApiGatewayApplicationContractsModule), + typeof(AbpMessageServiceApplicationContractsModule), + typeof(AbpIdentityHttpApiModule), + typeof(AbpIdentityApplicationModule), + typeof(Abp.Account.AbpAccountApplicationModule), + typeof(Abp.Account.AbpAccountHttpApiModule), + typeof(AbpAccountApplicationModule), + typeof(AbpAccountHttpApiModule), + typeof(AbpIdentityServerApplicationModule), + typeof(AbpIdentityServerHttpApiModule), + typeof(AbpSettingManagementApplicationModule), + typeof(AbpSettingManagementHttpApiModule), + typeof(AbpPermissionManagementApplicationModule), + typeof(AbpPermissionManagementHttpApiModule), + typeof(AbpTenantManagementApplicationModule), + typeof(AbpTenantManagementHttpApiModule), + typeof(AbpEntityFrameworkCoreMySQLModule), + typeof(AbpIdentityEntityFrameworkCoreModule), + typeof(AbpIdentityServerEntityFrameworkCoreModule), + typeof(AbpTenantManagementEntityFrameworkCoreModule), + typeof(AbpSettingManagementEntityFrameworkCoreModule), + typeof(AbpPermissionManagementEntityFrameworkCoreModule), + typeof(AbpAspNetCoreAuthenticationJwtBearerModule), + typeof(AbpEmailingExceptionHandlingModule), + typeof(AbpCAPEventBusModule), + typeof(AbpAliyunSmsModule), +#if DEBUG + typeof(AbpTencentLocationModule), +#endif + typeof(AbpAutofacModule) + )] + public class BackendAdminHostModule : AbpModule + { + public override void PreConfigureServices(ServiceConfigurationContext context) + { + var configuration = context.Services.GetConfiguration(); + + PreConfigure(options => + { + options + .UseMySql(configuration.GetConnectionString("Default")) + .UseRabbitMQ(rabbitMQOptions => + { + configuration.GetSection("CAP:RabbitMQ").Bind(rabbitMQOptions); + }) + .UseDashboard(); + }); + + PreConfigure(builder => + { + builder.AddDefaultTokenProviders(); + }); + } + + public override void ConfigureServices(ServiceConfigurationContext context) + { + var hostingEnvironment = context.Services.GetHostingEnvironment(); + var configuration = hostingEnvironment.BuildConfiguration(); + // 配置Ef + Configure(options => + { + options.UseMySQL(); + }); + + // 加解密 + Configure(options => + { + options.DefaultPassPhrase = "s46c5q55nxpeS8Ra"; + options.InitVectorBytes = Encoding.ASCII.GetBytes("s83ng0abvd02js84"); + options.DefaultSalt = Encoding.ASCII.GetBytes("sf&5)s3#"); + }); + + Configure(options => + { + // Rename IdentityServer.Client.ManagePermissions + // See https://github.com/abpframework/abp/blob/dev/modules/identityserver/src/Volo.Abp.PermissionManagement.Domain.IdentityServer/Volo/Abp/PermissionManagement/IdentityServer/AbpPermissionManagementDomainIdentityServerModule.cs + options.ProviderPolicies[ClientPermissionValueProvider.ProviderName] = AbpIdentityServerPermissions.Clients.ManagePermissions; + }); + + // 自定义需要处理的异常 + Configure(options => + { + // 加入需要处理的异常类型 + options.Handlers.Add(); + }); + // 自定义需要发送邮件通知的异常类型 + Configure(options => + { + // 是否发送堆栈信息 + options.SendStackTrace = true; + // 未指定异常接收者的默认接收邮件 + options.DefaultReceiveEmail = "colin.in@foxmail.com"; + // 指定某种异常发送到哪个邮件 + options.HandReceivedException("colin.in@foxmail.com"); + }); + + + Configure(options => + { + // 滑动过期30天 + options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30); + // 绝对过期60天 + options.GlobalCacheEntryOptions.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(60); + }); + + Configure(options => + { + options.FileSets.AddEmbedded("LINGYUN.BackendAdmin"); + }); + + // 多租户 + Configure(options => + { + options.IsEnabled = true; + }); + + Configure(options => + { + options.TenantResolvers.Insert(0, new AuthorizationTenantResolveContributor()); + }); + + // Swagger + context.Services.AddSwaggerGen( + options => + { + options.SwaggerDoc("v1", new OpenApiInfo { Title = "BackendAdmin API", Version = "v1" }); + options.DocInclusionPredicate((docName, description) => true); + options.CustomSchemaIds(type => type.FullName); + }); + + // 支持本地化语言类型 + Configure(options => + { + options.Languages.Add(new LanguageInfo("en", "en", "English")); + options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); + + options.Resources + .Get() + .AddVirtualJson("/LINGYUN/BackendAdmin/Identity/Localization"); + }); + + context.Services.AddAuthentication("Bearer") + .AddIdentityServerAuthentication(options => + { + options.Authority = configuration["AuthServer:Authority"]; + options.RequireHttpsMetadata = false; + options.ApiName = configuration["AuthServer:ApiName"]; + AbpClaimTypes.UserId = JwtClaimTypes.Subject; + AbpClaimTypes.UserName = JwtClaimTypes.Name; + AbpClaimTypes.Role = JwtClaimTypes.Role; + AbpClaimTypes.Email = JwtClaimTypes.Email; + }); + + context.Services.AddStackExchangeRedisCache(options => + { + options.Configuration = configuration["RedisCache:ConnectString"]; + var instanceName = configuration["RedisCache:RedisPrefix"]; + options.InstanceName = instanceName.IsNullOrEmpty() ? "BackendAdmin_Cache" : instanceName; + }); + + if (!hostingEnvironment.IsDevelopment()) + { + var redis = ConnectionMultiplexer.Connect(configuration["RedisCache:ConnectString"]); + context.Services + .AddDataProtection() + .PersistKeysToStackExchangeRedis(redis, "BackendAdmin-Protection-Keys"); + } + } + + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + // http调用链 + app.UseCorrelationId(); + // 虚拟文件系统 + app.UseVirtualFiles(); + // 本地化 + app.UseAbpRequestLocalization(); + //路由 + app.UseRouting(); + // 认证 + app.UseAuthentication(); + // jwt + app.UseJwtTokenMiddleware(); + // 多租户 + app.UseMultiTenancy(); + // Swagger + app.UseSwagger(); + // Swagger可视化界面 + app.UseSwaggerUI(options => + { + options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support BackendAdmin API"); + }); + // 审计日志 + app.UseAuditing(); + // 路由 + app.UseConfiguredEndpoints(); + } + } +} diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Controllers/LocationController.cs b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Controllers/LocationController.cs similarity index 96% rename from aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Controllers/LocationController.cs rename to aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Controllers/LocationController.cs index 6d7bb3fc6..fbac764b0 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Controllers/LocationController.cs +++ b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Controllers/LocationController.cs @@ -4,7 +4,7 @@ using System.Threading.Tasks; using Volo.Abp.AspNetCore.Mvc; #if DEBUG -namespace LINGYUN.Platform.Controllers +namespace LINGYUN.BackendAdmin.Controllers { [Route("Location")] public class LocationController : AbpController diff --git a/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/EntityFrameworkCore/BackendAdminHostMigrationsDbContext.cs b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/EntityFrameworkCore/BackendAdminHostMigrationsDbContext.cs new file mode 100644 index 000000000..752ae063b --- /dev/null +++ b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/EntityFrameworkCore/BackendAdminHostMigrationsDbContext.cs @@ -0,0 +1,31 @@ +using Microsoft.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.Identity.EntityFrameworkCore; +using Volo.Abp.IdentityServer.EntityFrameworkCore; +using Volo.Abp.PermissionManagement.EntityFrameworkCore; +using Volo.Abp.SettingManagement.EntityFrameworkCore; +using Volo.Abp.TenantManagement.EntityFrameworkCore; + +namespace LINGYUN.BackendAdmin.EntityFrameworkCore +{ + public class BackendAdminHostMigrationsDbContext : AbpDbContext + { + public BackendAdminHostMigrationsDbContext(DbContextOptions options) + : base(options) + { + + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.UseMySQL(); + modelBuilder.ConfigureIdentity(); + modelBuilder.ConfigureIdentityServer(); + //modelBuilder.ConfigureTenantManagement(); + //modelBuilder.ConfigureSettingManagement(); + //modelBuilder.ConfigurePermissionManagement(); + } + } +} diff --git a/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/EntityFrameworkCore/BackendAdminHostMigrationsDbContextFactory.cs b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/EntityFrameworkCore/BackendAdminHostMigrationsDbContextFactory.cs new file mode 100644 index 000000000..d342b5fa0 --- /dev/null +++ b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/EntityFrameworkCore/BackendAdminHostMigrationsDbContextFactory.cs @@ -0,0 +1,29 @@ +using System.IO; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Design; +using Microsoft.Extensions.Configuration; + +namespace LINGYUN.BackendAdmin.EntityFrameworkCore +{ + public class BackendAdminHostMigrationsDbContextFactory : IDesignTimeDbContextFactory + { + public BackendAdminHostMigrationsDbContext CreateDbContext(string[] args) + { + var configuration = BuildConfiguration(); + + var builder = new DbContextOptionsBuilder() + .UseMySql(configuration.GetConnectionString("AbpIdentityServer")); + + return new BackendAdminHostMigrationsDbContext(builder.Options); + } + + private static IConfigurationRoot BuildConfiguration() + { + var builder = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.Development.json", optional: false); + + return builder.Build(); + } + } +} diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EntityFrameworkCore/Identity/EfCoreIdentityUserExtensionRepository.cs b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/EntityFrameworkCore/Identity/EfCoreIdentityUserExtensionRepository.cs similarity index 100% rename from aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EntityFrameworkCore/Identity/EfCoreIdentityUserExtensionRepository.cs rename to aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/EntityFrameworkCore/Identity/EfCoreIdentityUserExtensionRepository.cs diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EventBus/Handlers/TenantConnectionStringCreateEventHandler.cs b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/EventBus/Handlers/TenantConnectionStringCreateEventHandler.cs similarity index 78% rename from aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EventBus/Handlers/TenantConnectionStringCreateEventHandler.cs rename to aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/EventBus/Handlers/TenantConnectionStringCreateEventHandler.cs index 6b70ba77a..30cec7423 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EventBus/Handlers/TenantConnectionStringCreateEventHandler.cs +++ b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/EventBus/Handlers/TenantConnectionStringCreateEventHandler.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace LINGYUN.Platform.EventBus.Handlers +namespace LINGYUN.BackendAdmin.EventBus.Handlers { public class TenantConnectionStringCreateEventHandler { diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EventBus/Handlers/TenantCreateEventHandler.cs b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/EventBus/Handlers/TenantCreateEventHandler.cs similarity index 99% rename from aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EventBus/Handlers/TenantCreateEventHandler.cs rename to aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/EventBus/Handlers/TenantCreateEventHandler.cs index a0b05c86f..f1db6048c 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EventBus/Handlers/TenantCreateEventHandler.cs +++ b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/EventBus/Handlers/TenantCreateEventHandler.cs @@ -13,7 +13,7 @@ using Volo.Abp.MultiTenancy; using Volo.Abp.PermissionManagement; using Volo.Abp.Uow; -namespace LINGYUN.Platform.EventBus.Handlers +namespace LINGYUN.BackendAdmin.EventBus.Handlers { public class TenantCreateEventHandler : IDistributedEventHandler, ITransientDependency { diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EventBus/Handlers/TenantDeleteEventHandler.cs b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/EventBus/Handlers/TenantDeleteEventHandler.cs similarity index 98% rename from aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EventBus/Handlers/TenantDeleteEventHandler.cs rename to aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/EventBus/Handlers/TenantDeleteEventHandler.cs index 92f2b29cf..177ba8d08 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EventBus/Handlers/TenantDeleteEventHandler.cs +++ b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/EventBus/Handlers/TenantDeleteEventHandler.cs @@ -12,7 +12,7 @@ using Volo.Abp.PermissionManagement; using Volo.Abp.TenantManagement; using Volo.Abp.Uow; -namespace LINGYUN.Platform.EventBus.Handlers +namespace LINGYUN.BackendAdmin.EventBus.Handlers { public class TenantDeleteEventHandler : IDistributedEventHandler>, ITransientDependency { diff --git a/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/LINGYUN.BackendAdminApp.Host.csproj b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/LINGYUN.BackendAdminApp.Host.csproj new file mode 100644 index 000000000..43b286adb --- /dev/null +++ b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/LINGYUN.BackendAdminApp.Host.csproj @@ -0,0 +1,83 @@ + + + + netcoreapp3.1 + LINGYUN.BackendAdmin + + + + + + + + + + + + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN/Platform/Identity/Localization/en.json b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/LINGYUN/BackendAdmin/Identity/Localization/en.json similarity index 100% rename from aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN/Platform/Identity/Localization/en.json rename to aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/LINGYUN/BackendAdmin/Identity/Localization/en.json diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN/Platform/Identity/Localization/zh-Hans.json b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/LINGYUN/BackendAdmin/Identity/Localization/zh-Hans.json similarity index 100% rename from aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN/Platform/Identity/Localization/zh-Hans.json rename to aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/LINGYUN/BackendAdmin/Identity/Localization/zh-Hans.json diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200513010936_Migration-IdentityServer-MySql.Designer.cs b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Migrations/20200513010936_Migration-IdentityServer-MySql.Designer.cs similarity index 99% rename from aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200513010936_Migration-IdentityServer-MySql.Designer.cs rename to aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Migrations/20200513010936_Migration-IdentityServer-MySql.Designer.cs index 7493706b8..f536b10eb 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200513010936_Migration-IdentityServer-MySql.Designer.cs +++ b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Migrations/20200513010936_Migration-IdentityServer-MySql.Designer.cs @@ -1,13 +1,13 @@ // -using LINGYUN.Platform.EntityFrameworkCore; +using LINGYUN.BackendAdmin.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using System; -namespace LINGYUN.Platform.Migrations +namespace LINGYUN.BackendAdmin.Migrations { - [DbContext(typeof(PlatformHttpApiHostMigrationsDbContext))] + [DbContext(typeof(BackendAdminHostMigrationsDbContext))] [Migration("20200513010936_Migration-IdentityServer-MySql")] partial class MigrationIdentityServerMySql { diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200513010936_Migration-IdentityServer-MySql.cs b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Migrations/20200513010936_Migration-IdentityServer-MySql.cs similarity index 99% rename from aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200513010936_Migration-IdentityServer-MySql.cs rename to aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Migrations/20200513010936_Migration-IdentityServer-MySql.cs index cfd47f8c5..019c84d44 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200513010936_Migration-IdentityServer-MySql.cs +++ b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Migrations/20200513010936_Migration-IdentityServer-MySql.cs @@ -1,7 +1,7 @@ using System; using Microsoft.EntityFrameworkCore.Migrations; -namespace LINGYUN.Platform.Migrations +namespace LINGYUN.BackendAdmin.Migrations { public partial class MigrationIdentityServerMySql : Migration { diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200606012143_Upgrade-Abp-2.9.0.Designer.cs b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Migrations/20200606012143_Upgrade-Abp-2.9.0.Designer.cs similarity index 99% rename from aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200606012143_Upgrade-Abp-2.9.0.Designer.cs rename to aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Migrations/20200606012143_Upgrade-Abp-2.9.0.Designer.cs index b963751c4..15cf5f348 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200606012143_Upgrade-Abp-2.9.0.Designer.cs +++ b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Migrations/20200606012143_Upgrade-Abp-2.9.0.Designer.cs @@ -1,15 +1,15 @@ // using System; -using LINGYUN.Platform.EntityFrameworkCore; +using LINGYUN.BackendAdmin.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Volo.Abp.EntityFrameworkCore; -namespace LINGYUN.Platform.Migrations +namespace LINGYUN.BackendAdmin.Migrations { - [DbContext(typeof(PlatformHttpApiHostMigrationsDbContext))] + [DbContext(typeof(BackendAdminHostMigrationsDbContext))] [Migration("20200606012143_Upgrade-Abp-3.0.0")] partial class UpgradeAbp290 { diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200606012143_Upgrade-Abp-2.9.0.cs b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Migrations/20200606012143_Upgrade-Abp-2.9.0.cs similarity index 99% rename from aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200606012143_Upgrade-Abp-2.9.0.cs rename to aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Migrations/20200606012143_Upgrade-Abp-2.9.0.cs index 6bc7368c7..c191065ff 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200606012143_Upgrade-Abp-2.9.0.cs +++ b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Migrations/20200606012143_Upgrade-Abp-2.9.0.cs @@ -1,7 +1,7 @@ using System; using Microsoft.EntityFrameworkCore.Migrations; -namespace LINGYUN.Platform.Migrations +namespace LINGYUN.BackendAdmin.Migrations { public partial class UpgradeAbp290 : Migration { diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/IdentityServerMigrationsDbContextModelSnapshot.cs b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Migrations/IdentityServerMigrationsDbContextModelSnapshot.cs similarity index 99% rename from aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/IdentityServerMigrationsDbContextModelSnapshot.cs rename to aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Migrations/IdentityServerMigrationsDbContextModelSnapshot.cs index a05a6827e..9f5eb42a1 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/IdentityServerMigrationsDbContextModelSnapshot.cs +++ b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Migrations/IdentityServerMigrationsDbContextModelSnapshot.cs @@ -1,14 +1,14 @@ // using System; -using LINGYUN.Platform.EntityFrameworkCore; +using LINGYUN.BackendAdmin.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Volo.Abp.EntityFrameworkCore; -namespace LINGYUN.Platform.Migrations +namespace LINGYUN.BackendAdmin.Migrations { - [DbContext(typeof(PlatformHttpApiHostMigrationsDbContext))] + [DbContext(typeof(BackendAdminHostMigrationsDbContext))] partial class IdentityServerMigrationsDbContextModelSnapshot : ModelSnapshot { protected override void BuildModel(ModelBuilder modelBuilder) diff --git a/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/MultiTenancy/AuthorizationTenantResolveContributor.cs b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/MultiTenancy/AuthorizationTenantResolveContributor.cs new file mode 100644 index 000000000..c2d1fd63c --- /dev/null +++ b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/MultiTenancy/AuthorizationTenantResolveContributor.cs @@ -0,0 +1,35 @@ +using Microsoft.AspNetCore.Http; +using System.Linq; +using Volo.Abp.AspNetCore.MultiTenancy; +using Volo.Abp.MultiTenancy; +using Volo.Abp.Security.Claims; + +namespace LINGYUN.BackendAdmin.MultiTenancy +{ + public class AuthorizationTenantResolveContributor : HttpTenantResolveContributorBase + { + public override string Name => "Authorization"; + + protected override string GetTenantIdOrNameFromHttpContextOrNull(ITenantResolveContext context, HttpContext httpContext) + { + if (httpContext.User?.Identity == null) + { + return null; + } + if (!httpContext.User.Identity.IsAuthenticated) + { + return null; + } + var tenantIdKey = context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey; + + var tenantClaim = httpContext.User.Claims.FirstOrDefault(x => x.Type.Equals(AbpClaimTypes.TenantId)); + + if (tenantClaim == null) + { + return null; + } + + return tenantClaim.Value; + } + } +} diff --git a/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Program.cs b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Program.cs new file mode 100644 index 000000000..68f5d2289 --- /dev/null +++ b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Program.cs @@ -0,0 +1,49 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Serilog; +using System; +using System.IO; + +namespace LINGYUN.BackendAdmin +{ + public class Program + { + public static int Main(string[] args) + { + var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production"; + var configuration = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile($"appsettings.{env}.json", optional: false, reloadOnChange: true) + .AddEnvironmentVariables() + .Build(); + Log.Logger = new LoggerConfiguration() + .ReadFrom.Configuration(configuration) + .CreateLogger(); + try + { + Log.Information("Starting web host."); + CreateHostBuilder(args).Build().Run(); + return 0; + } + catch (Exception ex) + { + Log.Fatal(ex, "Host terminated unexpectedly!"); + return 1; + } + finally + { + Log.CloseAndFlush(); + } + } + + internal static IHostBuilder CreateHostBuilder(string[] args) => + Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }) + .UseSerilog() + .UseAutofac(); + } +} diff --git a/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Properties/launchSettings.json b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Properties/launchSettings.json new file mode 100644 index 000000000..549604928 --- /dev/null +++ b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Properties/launchSettings.json @@ -0,0 +1,20 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:54521", + "sslPort": 0 + } + }, + "profiles": { + "LINGYUN.BackendAdminApp.Host": { + "commandName": "Project", + "launchBrowser": false, + "applicationUrl": "http://localhost:30010", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Startup.cs b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Startup.cs new file mode 100644 index 000000000..0b753d385 --- /dev/null +++ b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/Startup.cs @@ -0,0 +1,18 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; + +namespace LINGYUN.BackendAdmin +{ + public class Startup + { + public void ConfigureServices(IServiceCollection services) + { + services.AddApplication(); + } + + public void Configure(IApplicationBuilder app) + { + app.InitializeApplication(); + } + } +} diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/tempkey.rsa b/aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/tempkey.rsa similarity index 100% rename from aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/tempkey.rsa rename to aspnet-core/services/admin/LINGYUN.BackendAdminApp.Host/tempkey.rsa diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/.gitignore b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/.gitignore index 53f2c2fc2..2381b38da 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/.gitignore +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/.gitignore @@ -1,4 +1,2 @@ -bin -obj -Logs -appsettings.*.json \ No newline at end of file +.vs +file-blob-storing \ No newline at end of file diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EntityFrameworkCore/PlatformHttpApiHostMigrationsDbContext.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EntityFrameworkCore/PlatformHttpApiHostMigrationsDbContext.cs index 58d969d74..2f7833872 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EntityFrameworkCore/PlatformHttpApiHostMigrationsDbContext.cs +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EntityFrameworkCore/PlatformHttpApiHostMigrationsDbContext.cs @@ -1,10 +1,5 @@ using Microsoft.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; -using Volo.Abp.Identity.EntityFrameworkCore; -using Volo.Abp.IdentityServer.EntityFrameworkCore; -using Volo.Abp.PermissionManagement.EntityFrameworkCore; -using Volo.Abp.SettingManagement.EntityFrameworkCore; -using Volo.Abp.TenantManagement.EntityFrameworkCore; namespace LINGYUN.Platform.EntityFrameworkCore { @@ -20,16 +15,7 @@ namespace LINGYUN.Platform.EntityFrameworkCore { base.OnModelCreating(modelBuilder); - modelBuilder.UseMySQL(); - modelBuilder.ConfigureIdentity(); - modelBuilder.ConfigureIdentityServer(options => - { - options.TablePrefix = "IdentityServer"; - options.Schema = null; - }); - //modelBuilder.ConfigureTenantManagement(); - //modelBuilder.ConfigureSettingManagement(); - //modelBuilder.ConfigurePermissionManagement(); + modelBuilder.ConfigurePlatform(); } } } diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EntityFrameworkCore/PlatformHttpApiHostMigrationsDbContextFactory.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EntityFrameworkCore/PlatformHttpApiHostMigrationsDbContextFactory.cs index 678225c61..9dd641cfd 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EntityFrameworkCore/PlatformHttpApiHostMigrationsDbContextFactory.cs +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EntityFrameworkCore/PlatformHttpApiHostMigrationsDbContextFactory.cs @@ -12,7 +12,7 @@ namespace LINGYUN.Platform.EntityFrameworkCore var configuration = BuildConfiguration(); var builder = new DbContextOptionsBuilder() - .UseMySql(configuration.GetConnectionString("AbpIdentityServer")); + .UseMySql(configuration.GetConnectionString("Default")); return new PlatformHttpApiHostMigrationsDbContext(builder.Options); } diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj index 30d44ebdc..9b89562f0 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj @@ -1,4 +1,4 @@ - + netcoreapp3.1 @@ -6,20 +6,8 @@ - - - - - - - - - - - - - - + + @@ -40,44 +28,23 @@ - + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200723133732_Add-Platform-Module.Designer.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200723133732_Add-Platform-Module.Designer.cs new file mode 100644 index 000000000..e797c115e --- /dev/null +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200723133732_Add-Platform-Module.Designer.cs @@ -0,0 +1,397 @@ +// +using System; +using LINGYUN.Platform.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +namespace LINGYUN.Platform.Migrations +{ + [DbContext(typeof(PlatformHttpApiHostMigrationsDbContext))] + [Migration("20200723133732_Add-Platform-Module")] + partial class AddPlatformModule + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "3.1.5") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Platform.Routes.RoleRoute", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)"); + + b.Property("CreatorId") + .HasColumnType("char(36)"); + + b.Property("DeleterId") + .HasColumnType("char(36)"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)"); + + b.Property("IsDeleted") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)"); + + b.Property("LastModifierId") + .HasColumnType("char(36)"); + + b.Property("RoleName") + .IsRequired() + .HasColumnName("RoleName") + .HasColumnType("varchar(256) CHARACTER SET utf8mb4") + .HasMaxLength(256); + + b.Property("RouteId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnName("TenantId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("RoleName", "RouteId"); + + b.ToTable("AppPlatformRoleRoute"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Routes.Route", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AlwaysShow") + .HasColumnType("tinyint(1)"); + + b.Property("Code") + .IsRequired() + .HasColumnName("Code") + .HasColumnType("varchar(95) CHARACTER SET utf8mb4") + .HasMaxLength(95); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnName("ConcurrencyStamp") + .HasColumnType("varchar(40) CHARACTER SET utf8mb4") + .HasMaxLength(40); + + b.Property("CreationTime") + .HasColumnName("CreationTime") + .HasColumnType("datetime(6)"); + + b.Property("CreatorId") + .HasColumnName("CreatorId") + .HasColumnType("char(36)"); + + b.Property("DeleterId") + .HasColumnName("DeleterId") + .HasColumnType("char(36)"); + + b.Property("DeletionTime") + .HasColumnName("DeletionTime") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnName("Description") + .HasColumnType("varchar(255) CHARACTER SET utf8mb4") + .HasMaxLength(255); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("DisplayName") + .HasColumnType("varchar(128) CHARACTER SET utf8mb4") + .HasMaxLength(128); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties") + .HasColumnType("longtext CHARACTER SET utf8mb4"); + + b.Property("FullName") + .HasColumnName("FullName") + .HasColumnType("varchar(128) CHARACTER SET utf8mb4") + .HasMaxLength(128); + + b.Property("Icon") + .HasColumnName("Icon") + .HasColumnType("varchar(128) CHARACTER SET utf8mb4") + .HasMaxLength(128); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnName("IsDeleted") + .HasColumnType("tinyint(1)") + .HasDefaultValue(false); + + b.Property("IsMenu") + .HasColumnType("tinyint(1)"); + + b.Property("IsPublic") + .HasColumnType("tinyint(1)"); + + b.Property("IsSideBar") + .HasColumnType("tinyint(1)"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("IsToolBar") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnName("LastModificationTime") + .HasColumnType("datetime(6)"); + + b.Property("LastModifierId") + .HasColumnName("LastModifierId") + .HasColumnType("char(36)"); + + b.Property("LinkUrl") + .IsRequired() + .HasColumnName("LinkUrl") + .HasColumnType("varchar(255) CHARACTER SET utf8mb4") + .HasMaxLength(255); + + b.Property("Name") + .IsRequired() + .HasColumnName("Name") + .HasColumnType("varchar(64) CHARACTER SET utf8mb4") + .HasMaxLength(64); + + b.Property("ParentId") + .HasColumnType("char(36)"); + + b.Property("PlatformType") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnName("TenantId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.HasIndex("ParentId"); + + b.ToTable("AppPlatformRoute"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Routes.UserRoute", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)"); + + b.Property("CreatorId") + .HasColumnType("char(36)"); + + b.Property("DeleterId") + .HasColumnType("char(36)"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)"); + + b.Property("IsDeleted") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)"); + + b.Property("LastModifierId") + .HasColumnType("char(36)"); + + b.Property("RouteId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnName("TenantId") + .HasColumnType("char(36)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId", "RouteId"); + + b.ToTable("AppPlatformUserRoute"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Versions.AppVersion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnName("ConcurrencyStamp") + .HasColumnType("varchar(40) CHARACTER SET utf8mb4") + .HasMaxLength(40); + + b.Property("CreationTime") + .HasColumnName("CreationTime") + .HasColumnType("datetime(6)"); + + b.Property("CreatorId") + .HasColumnName("CreatorId") + .HasColumnType("char(36)"); + + b.Property("DeleterId") + .HasColumnName("DeleterId") + .HasColumnType("char(36)"); + + b.Property("DeletionTime") + .HasColumnName("DeletionTime") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnName("Description") + .HasColumnType("longtext CHARACTER SET utf8mb4") + .HasMaxLength(2048); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties") + .HasColumnType("longtext CHARACTER SET utf8mb4"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnName("IsDeleted") + .HasColumnType("tinyint(1)") + .HasDefaultValue(false); + + b.Property("LastModificationTime") + .HasColumnName("LastModificationTime") + .HasColumnType("datetime(6)"); + + b.Property("LastModifierId") + .HasColumnName("LastModifierId") + .HasColumnType("char(36)"); + + b.Property("Level") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnName("TenantId") + .HasColumnType("char(36)"); + + b.Property("Title") + .IsRequired() + .HasColumnName("Title") + .HasColumnType("varchar(50) CHARACTER SET utf8mb4") + .HasMaxLength(50); + + b.Property("Version") + .IsRequired() + .HasColumnName("Version") + .HasColumnType("varchar(20) CHARACTER SET utf8mb4") + .HasMaxLength(20); + + b.HasKey("Id"); + + b.HasIndex("Version"); + + b.ToTable("AppPlatformVersion"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Versions.VersionFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AppVersionId") + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnName("CreationTime") + .HasColumnType("datetime(6)"); + + b.Property("CreatorId") + .HasColumnName("CreatorId") + .HasColumnType("char(36)"); + + b.Property("DownloadCount") + .HasColumnType("int"); + + b.Property("FileType") + .HasColumnType("int"); + + b.Property("LastModificationTime") + .HasColumnName("LastModificationTime") + .HasColumnType("datetime(6)"); + + b.Property("LastModifierId") + .HasColumnName("LastModifierId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnName("Name") + .HasColumnType("varchar(255) CHARACTER SET utf8mb4") + .HasMaxLength(255); + + b.Property("SHA256") + .IsRequired() + .HasColumnName("SHA256") + .HasColumnType("varchar(32) CHARACTER SET utf8mb4") + .HasMaxLength(32); + + b.Property("Size") + .HasColumnType("bigint"); + + b.Property("TenantId") + .HasColumnName("TenantId") + .HasColumnType("char(36)"); + + b.Property("Version") + .IsRequired() + .HasColumnName("Version") + .HasColumnType("varchar(20) CHARACTER SET utf8mb4") + .HasMaxLength(20); + + b.HasKey("Id"); + + b.HasIndex("AppVersionId"); + + b.HasIndex("Name", "Version"); + + b.ToTable("AppPlatformVersionFile"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Routes.Route", b => + { + b.HasOne("LINGYUN.Platform.Routes.Route", null) + .WithMany() + .HasForeignKey("ParentId"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Versions.VersionFile", b => + { + b.HasOne("LINGYUN.Platform.Versions.AppVersion", "AppVersion") + .WithMany("Files") + .HasForeignKey("AppVersionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200723133732_Add-Platform-Module.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200723133732_Add-Platform-Module.cs new file mode 100644 index 000000000..3dd098539 --- /dev/null +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200723133732_Add-Platform-Module.cs @@ -0,0 +1,206 @@ +using System; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace LINGYUN.Platform.Migrations +{ + public partial class AddPlatformModule : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "AppPlatformRoleRoute", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + CreationTime = table.Column(nullable: false), + CreatorId = table.Column(nullable: true), + LastModificationTime = table.Column(nullable: true), + LastModifierId = table.Column(nullable: true), + IsDeleted = table.Column(nullable: false), + DeleterId = table.Column(nullable: true), + DeletionTime = table.Column(nullable: true), + TenantId = table.Column(nullable: true), + RoleName = table.Column(maxLength: 256, nullable: false), + RouteId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AppPlatformRoleRoute", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AppPlatformRoute", + columns: table => new + { + Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(maxLength: 40, nullable: true), + CreationTime = table.Column(nullable: false), + CreatorId = table.Column(nullable: true), + LastModificationTime = table.Column(nullable: true), + LastModifierId = table.Column(nullable: true), + IsDeleted = table.Column(nullable: false, defaultValue: false), + DeleterId = table.Column(nullable: true), + DeletionTime = table.Column(nullable: true), + TenantId = table.Column(nullable: true), + Code = table.Column(maxLength: 95, nullable: false), + Name = table.Column(maxLength: 64, nullable: false), + FullName = table.Column(maxLength: 128, nullable: true), + DisplayName = table.Column(maxLength: 128, nullable: false), + PlatformType = table.Column(nullable: false), + Description = table.Column(maxLength: 255, nullable: true), + Icon = table.Column(maxLength: 128, nullable: true), + LinkUrl = table.Column(maxLength: 255, nullable: false), + IsMenu = table.Column(nullable: false), + IsToolBar = table.Column(nullable: false), + IsSideBar = table.Column(nullable: false), + IsPublic = table.Column(nullable: false), + IsStatic = table.Column(nullable: false), + AlwaysShow = table.Column(nullable: false), + ParentId = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AppPlatformRoute", x => x.Id); + table.ForeignKey( + name: "FK_AppPlatformRoute_AppPlatformRoute_ParentId", + column: x => x.ParentId, + principalTable: "AppPlatformRoute", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "AppPlatformUserRoute", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + CreationTime = table.Column(nullable: false), + CreatorId = table.Column(nullable: true), + LastModificationTime = table.Column(nullable: true), + LastModifierId = table.Column(nullable: true), + IsDeleted = table.Column(nullable: false), + DeleterId = table.Column(nullable: true), + DeletionTime = table.Column(nullable: true), + TenantId = table.Column(nullable: true), + UserId = table.Column(nullable: false), + RouteId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AppPlatformUserRoute", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AppPlatformVersion", + columns: table => new + { + Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(maxLength: 40, nullable: true), + CreationTime = table.Column(nullable: false), + CreatorId = table.Column(nullable: true), + LastModificationTime = table.Column(nullable: true), + LastModifierId = table.Column(nullable: true), + IsDeleted = table.Column(nullable: false, defaultValue: false), + DeleterId = table.Column(nullable: true), + DeletionTime = table.Column(nullable: true), + TenantId = table.Column(nullable: true), + Title = table.Column(maxLength: 50, nullable: false), + Version = table.Column(maxLength: 20, nullable: false), + Description = table.Column(maxLength: 2048, nullable: true), + Level = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AppPlatformVersion", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AppPlatformVersionFile", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + CreationTime = table.Column(nullable: false), + CreatorId = table.Column(nullable: true), + LastModificationTime = table.Column(nullable: true), + LastModifierId = table.Column(nullable: true), + TenantId = table.Column(nullable: true), + Name = table.Column(maxLength: 255, nullable: false), + Version = table.Column(maxLength: 20, nullable: false), + Size = table.Column(nullable: false), + FileType = table.Column(nullable: false), + SHA256 = table.Column(maxLength: 32, nullable: false), + DownloadCount = table.Column(nullable: false), + AppVersionId = table.Column(nullable: false) + }, + 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); + }); + + migrationBuilder.CreateIndex( + name: "IX_AppPlatformRoleRoute_RoleName_RouteId", + table: "AppPlatformRoleRoute", + columns: new[] { "RoleName", "RouteId" }); + + migrationBuilder.CreateIndex( + name: "IX_AppPlatformRoute_Code", + table: "AppPlatformRoute", + column: "Code"); + + migrationBuilder.CreateIndex( + name: "IX_AppPlatformRoute_ParentId", + table: "AppPlatformRoute", + column: "ParentId"); + + migrationBuilder.CreateIndex( + name: "IX_AppPlatformUserRoute_UserId_RouteId", + table: "AppPlatformUserRoute", + columns: new[] { "UserId", "RouteId" }); + + 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_Name_Version", + table: "AppPlatformVersionFile", + columns: new[] { "Name", "Version" }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AppPlatformRoleRoute"); + + migrationBuilder.DropTable( + name: "AppPlatformRoute"); + + migrationBuilder.DropTable( + name: "AppPlatformUserRoute"); + + migrationBuilder.DropTable( + name: "AppPlatformVersionFile"); + + migrationBuilder.DropTable( + name: "AppPlatformVersion"); + } + } +} diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200723143103_Modify-Version-File-SHA256-Length.Designer.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200723143103_Modify-Version-File-SHA256-Length.Designer.cs new file mode 100644 index 000000000..834493ed9 --- /dev/null +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200723143103_Modify-Version-File-SHA256-Length.Designer.cs @@ -0,0 +1,397 @@ +// +using System; +using LINGYUN.Platform.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +namespace LINGYUN.Platform.Migrations +{ + [DbContext(typeof(PlatformHttpApiHostMigrationsDbContext))] + [Migration("20200723143103_Modify-Version-File-SHA256-Length")] + partial class ModifyVersionFileSHA256Length + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "3.1.5") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Platform.Routes.RoleRoute", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)"); + + b.Property("CreatorId") + .HasColumnType("char(36)"); + + b.Property("DeleterId") + .HasColumnType("char(36)"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)"); + + b.Property("IsDeleted") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)"); + + b.Property("LastModifierId") + .HasColumnType("char(36)"); + + b.Property("RoleName") + .IsRequired() + .HasColumnName("RoleName") + .HasColumnType("varchar(256) CHARACTER SET utf8mb4") + .HasMaxLength(256); + + b.Property("RouteId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnName("TenantId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("RoleName", "RouteId"); + + b.ToTable("AppPlatformRoleRoute"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Routes.Route", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AlwaysShow") + .HasColumnType("tinyint(1)"); + + b.Property("Code") + .IsRequired() + .HasColumnName("Code") + .HasColumnType("varchar(95) CHARACTER SET utf8mb4") + .HasMaxLength(95); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnName("ConcurrencyStamp") + .HasColumnType("varchar(40) CHARACTER SET utf8mb4") + .HasMaxLength(40); + + b.Property("CreationTime") + .HasColumnName("CreationTime") + .HasColumnType("datetime(6)"); + + b.Property("CreatorId") + .HasColumnName("CreatorId") + .HasColumnType("char(36)"); + + b.Property("DeleterId") + .HasColumnName("DeleterId") + .HasColumnType("char(36)"); + + b.Property("DeletionTime") + .HasColumnName("DeletionTime") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnName("Description") + .HasColumnType("varchar(255) CHARACTER SET utf8mb4") + .HasMaxLength(255); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("DisplayName") + .HasColumnType("varchar(128) CHARACTER SET utf8mb4") + .HasMaxLength(128); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties") + .HasColumnType("longtext CHARACTER SET utf8mb4"); + + b.Property("FullName") + .HasColumnName("FullName") + .HasColumnType("varchar(128) CHARACTER SET utf8mb4") + .HasMaxLength(128); + + b.Property("Icon") + .HasColumnName("Icon") + .HasColumnType("varchar(128) CHARACTER SET utf8mb4") + .HasMaxLength(128); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnName("IsDeleted") + .HasColumnType("tinyint(1)") + .HasDefaultValue(false); + + b.Property("IsMenu") + .HasColumnType("tinyint(1)"); + + b.Property("IsPublic") + .HasColumnType("tinyint(1)"); + + b.Property("IsSideBar") + .HasColumnType("tinyint(1)"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("IsToolBar") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnName("LastModificationTime") + .HasColumnType("datetime(6)"); + + b.Property("LastModifierId") + .HasColumnName("LastModifierId") + .HasColumnType("char(36)"); + + b.Property("LinkUrl") + .IsRequired() + .HasColumnName("LinkUrl") + .HasColumnType("varchar(255) CHARACTER SET utf8mb4") + .HasMaxLength(255); + + b.Property("Name") + .IsRequired() + .HasColumnName("Name") + .HasColumnType("varchar(64) CHARACTER SET utf8mb4") + .HasMaxLength(64); + + b.Property("ParentId") + .HasColumnType("char(36)"); + + b.Property("PlatformType") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnName("TenantId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.HasIndex("ParentId"); + + b.ToTable("AppPlatformRoute"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Routes.UserRoute", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)"); + + b.Property("CreatorId") + .HasColumnType("char(36)"); + + b.Property("DeleterId") + .HasColumnType("char(36)"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)"); + + b.Property("IsDeleted") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)"); + + b.Property("LastModifierId") + .HasColumnType("char(36)"); + + b.Property("RouteId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnName("TenantId") + .HasColumnType("char(36)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId", "RouteId"); + + b.ToTable("AppPlatformUserRoute"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Versions.AppVersion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnName("ConcurrencyStamp") + .HasColumnType("varchar(40) CHARACTER SET utf8mb4") + .HasMaxLength(40); + + b.Property("CreationTime") + .HasColumnName("CreationTime") + .HasColumnType("datetime(6)"); + + b.Property("CreatorId") + .HasColumnName("CreatorId") + .HasColumnType("char(36)"); + + b.Property("DeleterId") + .HasColumnName("DeleterId") + .HasColumnType("char(36)"); + + b.Property("DeletionTime") + .HasColumnName("DeletionTime") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnName("Description") + .HasColumnType("longtext CHARACTER SET utf8mb4") + .HasMaxLength(2048); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties") + .HasColumnType("longtext CHARACTER SET utf8mb4"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnName("IsDeleted") + .HasColumnType("tinyint(1)") + .HasDefaultValue(false); + + b.Property("LastModificationTime") + .HasColumnName("LastModificationTime") + .HasColumnType("datetime(6)"); + + b.Property("LastModifierId") + .HasColumnName("LastModifierId") + .HasColumnType("char(36)"); + + b.Property("Level") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnName("TenantId") + .HasColumnType("char(36)"); + + b.Property("Title") + .IsRequired() + .HasColumnName("Title") + .HasColumnType("varchar(50) CHARACTER SET utf8mb4") + .HasMaxLength(50); + + b.Property("Version") + .IsRequired() + .HasColumnName("Version") + .HasColumnType("varchar(20) CHARACTER SET utf8mb4") + .HasMaxLength(20); + + b.HasKey("Id"); + + b.HasIndex("Version"); + + b.ToTable("AppPlatformVersion"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Versions.VersionFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AppVersionId") + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnName("CreationTime") + .HasColumnType("datetime(6)"); + + b.Property("CreatorId") + .HasColumnName("CreatorId") + .HasColumnType("char(36)"); + + b.Property("DownloadCount") + .HasColumnType("int"); + + b.Property("FileType") + .HasColumnType("int"); + + b.Property("LastModificationTime") + .HasColumnName("LastModificationTime") + .HasColumnType("datetime(6)"); + + b.Property("LastModifierId") + .HasColumnName("LastModifierId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnName("Name") + .HasColumnType("varchar(255) CHARACTER SET utf8mb4") + .HasMaxLength(255); + + b.Property("SHA256") + .IsRequired() + .HasColumnName("SHA256") + .HasColumnType("varchar(65) CHARACTER SET utf8mb4") + .HasMaxLength(65); + + b.Property("Size") + .HasColumnType("bigint"); + + b.Property("TenantId") + .HasColumnName("TenantId") + .HasColumnType("char(36)"); + + b.Property("Version") + .IsRequired() + .HasColumnName("Version") + .HasColumnType("varchar(20) CHARACTER SET utf8mb4") + .HasMaxLength(20); + + b.HasKey("Id"); + + b.HasIndex("AppVersionId"); + + b.HasIndex("Name", "Version"); + + b.ToTable("AppPlatformVersionFile"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Routes.Route", b => + { + b.HasOne("LINGYUN.Platform.Routes.Route", null) + .WithMany() + .HasForeignKey("ParentId"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Versions.VersionFile", b => + { + b.HasOne("LINGYUN.Platform.Versions.AppVersion", "AppVersion") + .WithMany("Files") + .HasForeignKey("AppVersionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200723143103_Modify-Version-File-SHA256-Length.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200723143103_Modify-Version-File-SHA256-Length.cs new file mode 100644 index 000000000..9e7193a66 --- /dev/null +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/20200723143103_Modify-Version-File-SHA256-Length.cs @@ -0,0 +1,31 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace LINGYUN.Platform.Migrations +{ + public partial class ModifyVersionFileSHA256Length : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "SHA256", + table: "AppPlatformVersionFile", + maxLength: 65, + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(32) CHARACTER SET utf8mb4", + oldMaxLength: 32); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "SHA256", + table: "AppPlatformVersionFile", + type: "varchar(32) CHARACTER SET utf8mb4", + maxLength: 32, + nullable: false, + oldClrType: typeof(string), + oldMaxLength: 65); + } + } +} diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/PlatformHttpApiHostMigrationsDbContextModelSnapshot.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/PlatformHttpApiHostMigrationsDbContextModelSnapshot.cs new file mode 100644 index 000000000..b22be8893 --- /dev/null +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Migrations/PlatformHttpApiHostMigrationsDbContextModelSnapshot.cs @@ -0,0 +1,395 @@ +// +using System; +using LINGYUN.Platform.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +namespace LINGYUN.Platform.Migrations +{ + [DbContext(typeof(PlatformHttpApiHostMigrationsDbContext))] + partial class PlatformHttpApiHostMigrationsDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "3.1.5") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Platform.Routes.RoleRoute", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)"); + + b.Property("CreatorId") + .HasColumnType("char(36)"); + + b.Property("DeleterId") + .HasColumnType("char(36)"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)"); + + b.Property("IsDeleted") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)"); + + b.Property("LastModifierId") + .HasColumnType("char(36)"); + + b.Property("RoleName") + .IsRequired() + .HasColumnName("RoleName") + .HasColumnType("varchar(256) CHARACTER SET utf8mb4") + .HasMaxLength(256); + + b.Property("RouteId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnName("TenantId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("RoleName", "RouteId"); + + b.ToTable("AppPlatformRoleRoute"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Routes.Route", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AlwaysShow") + .HasColumnType("tinyint(1)"); + + b.Property("Code") + .IsRequired() + .HasColumnName("Code") + .HasColumnType("varchar(95) CHARACTER SET utf8mb4") + .HasMaxLength(95); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnName("ConcurrencyStamp") + .HasColumnType("varchar(40) CHARACTER SET utf8mb4") + .HasMaxLength(40); + + b.Property("CreationTime") + .HasColumnName("CreationTime") + .HasColumnType("datetime(6)"); + + b.Property("CreatorId") + .HasColumnName("CreatorId") + .HasColumnType("char(36)"); + + b.Property("DeleterId") + .HasColumnName("DeleterId") + .HasColumnType("char(36)"); + + b.Property("DeletionTime") + .HasColumnName("DeletionTime") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnName("Description") + .HasColumnType("varchar(255) CHARACTER SET utf8mb4") + .HasMaxLength(255); + + b.Property("DisplayName") + .IsRequired() + .HasColumnName("DisplayName") + .HasColumnType("varchar(128) CHARACTER SET utf8mb4") + .HasMaxLength(128); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties") + .HasColumnType("longtext CHARACTER SET utf8mb4"); + + b.Property("FullName") + .HasColumnName("FullName") + .HasColumnType("varchar(128) CHARACTER SET utf8mb4") + .HasMaxLength(128); + + b.Property("Icon") + .HasColumnName("Icon") + .HasColumnType("varchar(128) CHARACTER SET utf8mb4") + .HasMaxLength(128); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnName("IsDeleted") + .HasColumnType("tinyint(1)") + .HasDefaultValue(false); + + b.Property("IsMenu") + .HasColumnType("tinyint(1)"); + + b.Property("IsPublic") + .HasColumnType("tinyint(1)"); + + b.Property("IsSideBar") + .HasColumnType("tinyint(1)"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("IsToolBar") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnName("LastModificationTime") + .HasColumnType("datetime(6)"); + + b.Property("LastModifierId") + .HasColumnName("LastModifierId") + .HasColumnType("char(36)"); + + b.Property("LinkUrl") + .IsRequired() + .HasColumnName("LinkUrl") + .HasColumnType("varchar(255) CHARACTER SET utf8mb4") + .HasMaxLength(255); + + b.Property("Name") + .IsRequired() + .HasColumnName("Name") + .HasColumnType("varchar(64) CHARACTER SET utf8mb4") + .HasMaxLength(64); + + b.Property("ParentId") + .HasColumnType("char(36)"); + + b.Property("PlatformType") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnName("TenantId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.HasIndex("ParentId"); + + b.ToTable("AppPlatformRoute"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Routes.UserRoute", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)"); + + b.Property("CreatorId") + .HasColumnType("char(36)"); + + b.Property("DeleterId") + .HasColumnType("char(36)"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)"); + + b.Property("IsDeleted") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)"); + + b.Property("LastModifierId") + .HasColumnType("char(36)"); + + b.Property("RouteId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnName("TenantId") + .HasColumnType("char(36)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId", "RouteId"); + + b.ToTable("AppPlatformUserRoute"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Versions.AppVersion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnName("ConcurrencyStamp") + .HasColumnType("varchar(40) CHARACTER SET utf8mb4") + .HasMaxLength(40); + + b.Property("CreationTime") + .HasColumnName("CreationTime") + .HasColumnType("datetime(6)"); + + b.Property("CreatorId") + .HasColumnName("CreatorId") + .HasColumnType("char(36)"); + + b.Property("DeleterId") + .HasColumnName("DeleterId") + .HasColumnType("char(36)"); + + b.Property("DeletionTime") + .HasColumnName("DeletionTime") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasColumnName("Description") + .HasColumnType("longtext CHARACTER SET utf8mb4") + .HasMaxLength(2048); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties") + .HasColumnType("longtext CHARACTER SET utf8mb4"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnName("IsDeleted") + .HasColumnType("tinyint(1)") + .HasDefaultValue(false); + + b.Property("LastModificationTime") + .HasColumnName("LastModificationTime") + .HasColumnType("datetime(6)"); + + b.Property("LastModifierId") + .HasColumnName("LastModifierId") + .HasColumnType("char(36)"); + + b.Property("Level") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnName("TenantId") + .HasColumnType("char(36)"); + + b.Property("Title") + .IsRequired() + .HasColumnName("Title") + .HasColumnType("varchar(50) CHARACTER SET utf8mb4") + .HasMaxLength(50); + + b.Property("Version") + .IsRequired() + .HasColumnName("Version") + .HasColumnType("varchar(20) CHARACTER SET utf8mb4") + .HasMaxLength(20); + + b.HasKey("Id"); + + b.HasIndex("Version"); + + b.ToTable("AppPlatformVersion"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Versions.VersionFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AppVersionId") + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnName("CreationTime") + .HasColumnType("datetime(6)"); + + b.Property("CreatorId") + .HasColumnName("CreatorId") + .HasColumnType("char(36)"); + + b.Property("DownloadCount") + .HasColumnType("int"); + + b.Property("FileType") + .HasColumnType("int"); + + b.Property("LastModificationTime") + .HasColumnName("LastModificationTime") + .HasColumnType("datetime(6)"); + + b.Property("LastModifierId") + .HasColumnName("LastModifierId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnName("Name") + .HasColumnType("varchar(255) CHARACTER SET utf8mb4") + .HasMaxLength(255); + + b.Property("SHA256") + .IsRequired() + .HasColumnName("SHA256") + .HasColumnType("varchar(65) CHARACTER SET utf8mb4") + .HasMaxLength(65); + + b.Property("Size") + .HasColumnType("bigint"); + + b.Property("TenantId") + .HasColumnName("TenantId") + .HasColumnType("char(36)"); + + b.Property("Version") + .IsRequired() + .HasColumnName("Version") + .HasColumnType("varchar(20) CHARACTER SET utf8mb4") + .HasMaxLength(20); + + b.HasKey("Id"); + + b.HasIndex("AppVersionId"); + + b.HasIndex("Name", "Version"); + + b.ToTable("AppPlatformVersionFile"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Routes.Route", b => + { + b.HasOne("LINGYUN.Platform.Routes.Route", null) + .WithMany() + .HasForeignKey("ParentId"); + }); + + modelBuilder.Entity("LINGYUN.Platform.Versions.VersionFile", b => + { + b.HasOne("LINGYUN.Platform.Versions.AppVersion", "AppVersion") + .WithMany("Files") + .HasForeignKey("AppVersionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/PlatformHttpApiHostModule.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/PlatformHttpApiHostModule.cs index 622564075..95d54da11 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/PlatformHttpApiHostModule.cs +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/PlatformHttpApiHostModule.cs @@ -3,87 +3,55 @@ using IdentityModel; using LINGYUN.Abp.EventBus.CAP; using LINGYUN.Abp.ExceptionHandling; using LINGYUN.Abp.ExceptionHandling.Emailing; -using LINGYUN.Abp.IdentityServer; -using LINGYUN.Abp.Location.Tencent; -using LINGYUN.Abp.MessageService; -using LINGYUN.Abp.SettingManagement; -using LINGYUN.Abp.TenantManagement; -using LINGYUN.ApiGateway; +using LINGYUN.Abp.Notifications; +using LINGYUN.Platform.EntityFrameworkCore; +using LINGYUN.Platform.HttpApi; using LINGYUN.Platform.MultiTenancy; -using LINYUN.Abp.Sms.Aliyun; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Server.Kestrel.Core; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.OpenApi.Models; using StackExchange.Redis; using System; -using System.Collections.Generic; +using System.IO; using System.Text; using Volo.Abp; -using Volo.Abp.Account; using Volo.Abp.AspNetCore.Authentication.JwtBearer; -using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy; -using Volo.Abp.Authorization.Permissions; +using Volo.Abp.AspNetCore.MultiTenancy; using Volo.Abp.Autofac; +using Volo.Abp.BlobStoring; +using Volo.Abp.BlobStoring.FileSystem; using Volo.Abp.Caching; using Volo.Abp.EntityFrameworkCore; -using Volo.Abp.EntityFrameworkCore.MySQL; -using Volo.Abp.Identity; -using Volo.Abp.Identity.EntityFrameworkCore; -using Volo.Abp.Identity.Localization; -using Volo.Abp.IdentityServer.EntityFrameworkCore; using Volo.Abp.Localization; using Volo.Abp.Modularity; using Volo.Abp.MultiTenancy; -using Volo.Abp.PermissionManagement; using Volo.Abp.PermissionManagement.EntityFrameworkCore; -using Volo.Abp.PermissionManagement.HttpApi; -using Volo.Abp.PermissionManagement.Identity; -using Volo.Abp.PermissionManagement.IdentityServer; using Volo.Abp.Security.Claims; using Volo.Abp.Security.Encryption; using Volo.Abp.SettingManagement.EntityFrameworkCore; using Volo.Abp.TenantManagement.EntityFrameworkCore; using Volo.Abp.VirtualFileSystem; + namespace LINGYUN.Platform { [DependsOn( - typeof(AbpAspNetCoreMvcUiMultiTenancyModule), - typeof(AbpPermissionManagementDomainIdentityModule), - typeof(AbpPermissionManagementDomainIdentityServerModule), - typeof(ApiGatewayApplicationContractsModule), - typeof(AbpMessageServiceApplicationContractsModule), - typeof(AbpIdentityHttpApiModule), - typeof(AbpIdentityApplicationModule), - typeof(Abp.Account.AbpAccountApplicationModule), - typeof(Abp.Account.AbpAccountHttpApiModule), - typeof(AbpAccountApplicationModule), - typeof(AbpAccountHttpApiModule), - typeof(AbpIdentityServerApplicationModule), - typeof(AbpIdentityServerHttpApiModule), - typeof(AbpSettingManagementApplicationModule), - typeof(AbpSettingManagementHttpApiModule), - typeof(AbpPermissionManagementApplicationModule), - typeof(AbpPermissionManagementHttpApiModule), - typeof(AbpTenantManagementApplicationModule), - typeof(AbpTenantManagementHttpApiModule), - typeof(AbpEntityFrameworkCoreMySQLModule), - typeof(AbpIdentityEntityFrameworkCoreModule), - typeof(AbpIdentityServerEntityFrameworkCoreModule), + typeof(PlatformApplicationModule), + typeof(PlatformHttpApiModule), + typeof(PlatformEntityFrameworkCoreModule), + typeof(AbpAspNetCoreMultiTenancyModule), typeof(AbpTenantManagementEntityFrameworkCoreModule), typeof(AbpSettingManagementEntityFrameworkCoreModule), typeof(AbpPermissionManagementEntityFrameworkCoreModule), typeof(AbpAspNetCoreAuthenticationJwtBearerModule), + typeof(AbpNotificationModule), typeof(AbpEmailingExceptionHandlingModule), typeof(AbpCAPEventBusModule), - typeof(AbpAliyunSmsModule), -#if DEBUG - typeof(AbpTencentLocationModule), -#endif + typeof(AbpBlobStoringFileSystemModule), typeof(AbpAutofacModule) )] public class PlatformHttpApiHostModule : AbpModule @@ -102,11 +70,6 @@ namespace LINGYUN.Platform }) .UseDashboard(); }); - - PreConfigure(builder => - { - builder.AddDefaultTokenProviders(); - }); } public override void ConfigureServices(ServiceConfigurationContext context) @@ -119,6 +82,23 @@ namespace LINGYUN.Platform options.UseMySQL(); }); + Configure(options => + { + options.Limits.MaxRequestBodySize = null; + options.Limits.MaxRequestBufferSize = null; + }); + + Configure(options => + { + options.Containers.ConfigureAll((containerName, containerConfiguration) => + { + containerConfiguration.UseFileSystem(fileSystem => + { + fileSystem.BasePath = Path.Combine(Directory.GetCurrentDirectory(), "file-blob-storing"); + }); + }); + }); + // 加解密 Configure(options => { @@ -127,13 +107,6 @@ namespace LINGYUN.Platform options.DefaultSalt = Encoding.ASCII.GetBytes("sf&5)s3#"); }); - Configure(options => - { - // Rename IdentityServer.Client.ManagePermissions - // See https://github.com/abpframework/abp/blob/dev/modules/identityserver/src/Volo.Abp.PermissionManagement.Domain.IdentityServer/Volo/Abp/PermissionManagement/IdentityServer/AbpPermissionManagementDomainIdentityServerModule.cs - options.ProviderPolicies[ClientPermissionValueProvider.ProviderName] = AbpIdentityServerPermissions.Clients.ManagePermissions; - }); - // 自定义需要处理的异常 Configure(options => { @@ -147,11 +120,10 @@ namespace LINGYUN.Platform options.SendStackTrace = true; // 未指定异常接收者的默认接收邮件 options.DefaultReceiveEmail = "colin.in@foxmail.com"; - // 指定某种异常发送到哪个邮件 + // 指定某种异常发送到哪个邮件 options.HandReceivedException("colin.in@foxmail.com"); }); - Configure(options => { // 滑动过期30天 @@ -190,10 +162,6 @@ namespace LINGYUN.Platform { options.Languages.Add(new LanguageInfo("en", "en", "English")); options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); - - options.Resources - .Get() - .AddVirtualJson("/LINGYUN/Platform/Identity/Localization"); }); context.Services.AddAuthentication("Bearer") @@ -224,6 +192,14 @@ namespace LINGYUN.Platform } } + //public override void OnPostApplicationInitialization(ApplicationInitializationContext context) + //{ + // var backgroundJobManager = context.ServiceProvider.GetRequiredService(); + // // 五分钟执行一次的定时任务 + // AsyncHelper.RunSync(async () => await + // backgroundJobManager.EnqueueAsync(CronGenerator.Minute(5), new NotificationCleanupExpritionJobArgs(200))); + //} + public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); @@ -239,6 +215,8 @@ namespace LINGYUN.Platform app.UseAuthentication(); // jwt app.UseJwtTokenMiddleware(); + // 授权 + app.UseAuthorization(); // 多租户 app.UseMultiTenancy(); // Swagger diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Program.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Program.cs index 3b15eab57..b6cf26bae 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Program.cs +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Program.cs @@ -1,4 +1,4 @@ -using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Serilog; diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Properties/launchSettings.json b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Properties/launchSettings.json index 147337220..fc9124c2a 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Properties/launchSettings.json +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:54521", + "applicationUrl": "http://localhost:64238", "sslPort": 0 } }, @@ -11,7 +11,7 @@ "LINGYUN.Platform.HttpApi.Host": { "commandName": "Project", "launchBrowser": false, - "applicationUrl": "http://localhost:30010", + "applicationUrl": "http://localhost:30025", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Startup.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Startup.cs index 0d25d597a..4e90cd498 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Startup.cs +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/Startup.cs @@ -1,4 +1,4 @@ -using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; namespace LINGYUN.Platform diff --git a/aspnet-core/services/start-all-service.bat b/aspnet-core/services/start-all-service.bat index a311b5962..1527d49c4 100644 --- a/aspnet-core/services/start-all-service.bat +++ b/aspnet-core/services/start-all-service.bat @@ -3,7 +3,7 @@ cls start .\start-identity-server.bat --run start .\start-apigateway-admin.bat --run -start .\start-platform.bat --run +start .\start-backend-admin.bat --run start .\start-messages.bat --run ping -n 10 127.1 >nul start .\start-apigateway-host.bat --run \ No newline at end of file diff --git a/aspnet-core/services/start-backend-admin.bat b/aspnet-core/services/start-backend-admin.bat new file mode 100644 index 000000000..c18e6ed0a --- /dev/null +++ b/aspnet-core/services/start-backend-admin.bat @@ -0,0 +1,29 @@ +@echo off +cls +chcp 65001 + +echo. 启动后台管理服务 + +cd .\admin\LINGYUN.BackendAdminApp.Host + +if '%1' equ '--publish' goto publish +if '%1' equ '--run' goto run +if '%1' equ '--restore' goto restore +if '%1' equ '' goto run +exit + +:publish +dotnet publish -c Release -o ..\..\Publish\admin --no-cache --no-restore +copy Dockerfile ..\..\Publish\admin\Dockerfile +pause +exit + +:run +dotnet run +pause +exit + +:restore +dotnet restore +pause +exit \ No newline at end of file