From 04290042ec27fe54551e84a56fcc6527904284f7 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Tue, 26 May 2020 22:29:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9C=B0=E5=9D=80=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E6=A8=A1=E5=9D=97;=E5=8F=98=E6=9B=B4Abp.Cap=E8=BF=87?= =?UTF-8?q?=E6=9C=9F=E6=B6=88=E6=81=AF=E6=B8=85=E7=90=86=E4=B8=BA=E5=8F=AF?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Ocelot/Dto/RouteGroupCreateDto.cs | 1 + .../ApiGateway/Ocelot/RouteGroupAppService.cs | 6 +- ...apExpiresMessageCleanupBackgroundWorker.cs | 74 +++++++++++ .../CAP/Processor/AbpCapProcessingServer.cs | 115 ++++++++++++++++++ .../LINGYUN.Abp.EventBus.CAP.csproj | 1 + .../LINGYUN.Abp.EventBus.CAP.xml | 88 ++++++++++++++ .../Abp/EventBus/CAP/AbpCAPEventBusModule.cs | 23 +++- .../Abp/EventBus/CAP/MessageCleanupOptions.cs | 19 +++ .../ServiceCollectionExtensions.cs | 14 +++ .../LINGYUN.Abp.Location.Baidu.csproj | 12 ++ .../Http/BaiduInverseLocationResponse.cs | 15 +++ .../Baidu/Http/BaiduLocationHttpClient.cs | 11 ++ .../Baidu/Http/BaiduLocationResponse.cs | 14 +++ .../Http/BaiduPositiveLocationResponse.cs | 10 ++ .../Abp/Location/Baidu/Http/Location.cs | 8 ++ .../LINGYUN.Abp.Location.csproj | 12 ++ .../LINGYUN/Abp/Location/AbpLocationModule.cs | 8 ++ .../Abp/Location/ILocationResolveProvider.cs | 9 ++ .../LINGYUN/Abp/Location/InverseLocation.cs | 45 +++++++ .../LINGYUN/Abp/Location/Location.cs | 97 +++++++++++++++ .../LINGYUN/Abp/Location/Position.cs | 55 +++++++++ .../LINGYUN/Abp/Location/PositiveLocation.cs | 27 ++++ vueJs/src/App.vue | 11 +- vueJs/src/api/abpconfiguration.ts | 10 ++ vueJs/src/api/apigateway.ts | 4 +- vueJs/src/lang/zh.ts | 3 +- vueJs/src/utils/localStorage.ts | 16 ++- .../components/GlobalCreateOrEditForm.vue | 7 +- .../components/RouteGroupCreateOrEditForm.vue | 4 + .../views/login/components/TenantSelect.vue | 57 +++++++++ vueJs/src/views/login/index.vue | 17 ++- 31 files changed, 776 insertions(+), 17 deletions(-) create mode 100644 aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/DotNetCore/CAP/Processor/AbpCapExpiresMessageCleanupBackgroundWorker.cs create mode 100644 aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/DotNetCore/CAP/Processor/AbpCapProcessingServer.cs create mode 100644 aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/MessageCleanupOptions.cs create mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN.Abp.Location.Baidu.csproj create mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/Http/BaiduInverseLocationResponse.cs create mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/Http/BaiduLocationHttpClient.cs create mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/Http/BaiduLocationResponse.cs create mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/Http/BaiduPositiveLocationResponse.cs create mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/Http/Location.cs create mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN.Abp.Location.csproj create mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN/Abp/Location/AbpLocationModule.cs create mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN/Abp/Location/ILocationResolveProvider.cs create mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN/Abp/Location/InverseLocation.cs create mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN/Abp/Location/Location.cs create mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN/Abp/Location/Position.cs create mode 100644 aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN/Abp/Location/PositiveLocation.cs create mode 100644 vueJs/src/views/login/components/TenantSelect.vue diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application.Contracts/LINGYUN/ApiGateway/Ocelot/Dto/RouteGroupCreateDto.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application.Contracts/LINGYUN/ApiGateway/Ocelot/Dto/RouteGroupCreateDto.cs index 843cc1e46..20531d446 100644 --- a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application.Contracts/LINGYUN/ApiGateway/Ocelot/Dto/RouteGroupCreateDto.cs +++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application.Contracts/LINGYUN/ApiGateway/Ocelot/Dto/RouteGroupCreateDto.cs @@ -16,6 +16,7 @@ namespace LINGYUN.ApiGateway.Ocelot [StringLength(100)] public string AppName { get; set; } + [Required] [StringLength(256)] public string AppIpAddress { get; set; } diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application/LINGYUN/ApiGateway/Ocelot/RouteGroupAppService.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application/LINGYUN/ApiGateway/Ocelot/RouteGroupAppService.cs index ba2beba97..733fbefc8 100644 --- a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application/LINGYUN/ApiGateway/Ocelot/RouteGroupAppService.cs +++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application/LINGYUN/ApiGateway/Ocelot/RouteGroupAppService.cs @@ -60,11 +60,11 @@ namespace LINGYUN.ApiGateway.Ocelot { using (DataFilter.Disable()) { - var routerTupes = await RouterRepository.GetPagedListAsync(routerGetByPagedInput.Filter, + var (Routers, TotalCount) = await RouterRepository.GetPagedListAsync(routerGetByPagedInput.Filter, routerGetByPagedInput.Sorting, routerGetByPagedInput.SkipCount, routerGetByPagedInput.MaxResultCount); - var routers = ObjectMapper.Map, List>(routerTupes.Routers); + var routers = ObjectMapper.Map, List>(Routers); - return new PagedResultDto(routerTupes.TotalCount, routers); + return new PagedResultDto(TotalCount, routers); } } diff --git a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/DotNetCore/CAP/Processor/AbpCapExpiresMessageCleanupBackgroundWorker.cs b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/DotNetCore/CAP/Processor/AbpCapExpiresMessageCleanupBackgroundWorker.cs new file mode 100644 index 000000000..88cfa3e64 --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/DotNetCore/CAP/Processor/AbpCapExpiresMessageCleanupBackgroundWorker.cs @@ -0,0 +1,74 @@ +using DotNetCore.CAP.Persistence; +using LINGYUN.Abp.EventBus.CAP; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using System; +using System.Threading.Tasks; +using Volo.Abp.BackgroundWorkers; +using Volo.Abp.Threading; + +namespace DotNetCore.CAP.Processor +{ + /// + /// 过期消息清理任务 + /// + public class AbpCapExpiresMessageCleanupBackgroundWorker : AsyncPeriodicBackgroundWorkerBase + { + /// + /// 过期消息清理配置 + /// + protected MessageCleanupOptions Options { get; } + /// + /// Initializer + /// + protected IStorageInitializer Initializer { get; } + /// + /// Storage + /// + protected IDataStorage Storage{ get; } + /// + /// 创建过期消息清理任务 + /// + /// + /// + /// + /// + /// + public AbpCapExpiresMessageCleanupBackgroundWorker( + AbpTimer timer, + IDataStorage storage, + IStorageInitializer initializer, + IOptions options, + IServiceScopeFactory serviceScopeFactory) + : base(timer, serviceScopeFactory) + { + Storage = storage; + Options = options.Value; + Initializer = initializer; + + timer.Period = Options.Interval; + } + + /// + /// 异步执行任务 + /// + /// + /// + protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) + { + var tables = new[] + { + Initializer.GetPublishedTableName(), + Initializer.GetReceivedTableName() + }; + + foreach (var table in tables) + { + Logger.LogDebug($"Collecting expired data from table: {table}"); + var time = DateTime.Now; + await Storage.DeleteExpiresAsync(table, time, Options.ItemBatch); + } + } + } +} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/DotNetCore/CAP/Processor/AbpCapProcessingServer.cs b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/DotNetCore/CAP/Processor/AbpCapProcessingServer.cs new file mode 100644 index 000000000..e55b00db7 --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/DotNetCore/CAP/Processor/AbpCapProcessingServer.cs @@ -0,0 +1,115 @@ +using DotNetCore.CAP.Internal; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace DotNetCore.CAP.Processor +{ + /// + /// CapProcessingServer + /// + public class AbpCapProcessingServer : IProcessingServer + { + private readonly CancellationTokenSource _cts; + private readonly ILogger _logger; + private readonly ILoggerFactory _loggerFactory; + private readonly IServiceProvider _provider; + + private Task _compositeTask; + private ProcessingContext _context; + private bool _disposed; + /// + /// CapProcessingServer + /// + /// + /// + /// + public AbpCapProcessingServer( + ILogger logger, + ILoggerFactory loggerFactory, + IServiceProvider provider) + { + _logger = logger; + _loggerFactory = loggerFactory; + _provider = provider; + _cts = new CancellationTokenSource(); + } + /// + /// Start + /// + public void Start() + { + _logger.LogInformation("Starting the processing server."); + + _context = new ProcessingContext(_provider, _cts.Token); + + var processorTasks = GetProcessors() + .Select(InfiniteRetry) + .Select(p => p.ProcessAsync(_context)); + _compositeTask = Task.WhenAll(processorTasks); + } + /// + /// Pulse + /// + public void Pulse() + { + _logger.LogTrace("Pulsing the processor."); + } + /// + /// Dispose + /// + public void Dispose() + { + if (_disposed) + { + return; + } + + try + { + _disposed = true; + + _logger.LogInformation("Shutting down the processing server..."); + _cts.Cancel(); + + _compositeTask?.Wait((int)TimeSpan.FromSeconds(10).TotalMilliseconds); + } + catch (AggregateException ex) + { + var innerEx = ex.InnerExceptions[0]; + if (!(innerEx is OperationCanceledException)) + { + _logger.LogWarning(innerEx, $"Expected an OperationCanceledException, but found '{innerEx.Message}'."); + } + } + catch (Exception ex) + { + _logger.LogWarning(ex, "An exception was occured when disposing."); + } + finally + { + _logger.LogInformation("### CAP shutdown!"); + } + } + + private IProcessor InfiniteRetry(IProcessor inner) + { + return new InfiniteRetryProcessor(inner, _loggerFactory); + } + + private IProcessor[] GetProcessors() + { + var returnedProcessors = new List + { + _provider.GetRequiredService(), + _provider.GetRequiredService(), + }; + + return returnedProcessors.ToArray(); + } + } +} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.csproj b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.csproj index e55aa8625..d82e3d5aa 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.csproj @@ -15,6 +15,7 @@ + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.xml b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.xml index 3cb756744..d1580a042 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.xml +++ b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.xml @@ -39,6 +39,71 @@ + + + 过期消息清理任务 + + + + + 过期消息清理配置 + + + + + Initializer + + + + + Storage + + + + + 创建过期消息清理任务 + + + + + + + + + + 异步执行任务 + + + + + + + CapProcessingServer + + + + + CapProcessingServer + + + + + + + + Start + + + + + Pulse + + + + + Dispose + + AbpCAPEventBusModule @@ -50,6 +115,12 @@ + + + OnApplicationInitialization + + + CAP分布式事件总线 @@ -141,6 +212,23 @@ + + + 过期消息清理配置项 + + + + + 批量清理数量 + default: 1000 + + + + + 执行间隔(ms) + default: 3600000 (1 hours) + + CAP ServiceCollectionExtensions diff --git a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/AbpCAPEventBusModule.cs b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/AbpCAPEventBusModule.cs index 3bf6ebb55..82d8c8412 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/AbpCAPEventBusModule.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/AbpCAPEventBusModule.cs @@ -1,5 +1,8 @@ -using Microsoft.Extensions.Configuration; +using DotNetCore.CAP.Processor; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Volo.Abp; +using Volo.Abp.BackgroundWorkers; using Volo.Abp.EventBus; using Volo.Abp.Modularity; @@ -8,7 +11,9 @@ namespace LINGYUN.Abp.EventBus.CAP /// /// AbpCAPEventBusModule /// - [DependsOn(typeof(AbpEventBusModule))] + [DependsOn( + typeof(AbpEventBusModule), + typeof(AbpBackgroundWorkersModule))] public class AbpCAPEventBusModule : AbpModule { /// @@ -24,5 +29,19 @@ namespace LINGYUN.Abp.EventBus.CAP context.Services.ExecutePreConfiguredActions(options); }); } + + /// + /// OnApplicationInitialization + /// + /// + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + context.ServiceProvider + .GetRequiredService() + .Add( + context.ServiceProvider + .GetRequiredService() + ); + } } } diff --git a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/MessageCleanupOptions.cs b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/MessageCleanupOptions.cs new file mode 100644 index 000000000..3f0f13aec --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/MessageCleanupOptions.cs @@ -0,0 +1,19 @@ +namespace LINGYUN.Abp.EventBus.CAP +{ + /// + /// 过期消息清理配置项 + /// + public class MessageCleanupOptions + { + /// + /// 批量清理数量 + /// default: 1000 + /// + public int ItemBatch { get; set; } = 1000; + /// + /// 执行间隔(ms) + /// default: 3600000 (1 hours) + /// + public int Interval { get; set; } = 3600000; + } +} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/Microsoft/Extensions/DependencyInjection/ServiceCollectionExtensions.cs b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/Microsoft/Extensions/DependencyInjection/ServiceCollectionExtensions.cs index d6a9afd09..741bb53b4 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/Microsoft/Extensions/DependencyInjection/ServiceCollectionExtensions.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/Microsoft/Extensions/DependencyInjection/ServiceCollectionExtensions.cs @@ -1,5 +1,9 @@ using DotNetCore.CAP; +using DotNetCore.CAP.Internal; +using DotNetCore.CAP.Processor; +using Microsoft.Extensions.DependencyInjection.Extensions; using System; +using System.Linq; namespace Microsoft.Extensions.DependencyInjection { @@ -17,6 +21,16 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddCAPEventBus(this IServiceCollection services, Action capAction) { services.AddCap(capAction); + // 移除默认的定时清理过期消息任务 + // 默认的五分钟,不可配置,时间间隔过短,使用自定义的后台任务 + services.RemoveAll(typeof(CollectorProcessor)); + var capProcessingServiceDescriptor = services + .FirstOrDefault(x => typeof(CapProcessingServer).Equals(x.ImplementationType)); + if(capProcessingServiceDescriptor != null) + { + services.Remove(capProcessingServiceDescriptor); + } + services.TryAddEnumerable(ServiceDescriptor.Singleton()); return services; } } diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN.Abp.Location.Baidu.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN.Abp.Location.Baidu.csproj new file mode 100644 index 000000000..bbfeeef2a --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN.Abp.Location.Baidu.csproj @@ -0,0 +1,12 @@ + + + + netstandard2.0 + + + + + + + + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/Http/BaiduInverseLocationResponse.cs b/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/Http/BaiduInverseLocationResponse.cs new file mode 100644 index 000000000..10eab45a1 --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/Http/BaiduInverseLocationResponse.cs @@ -0,0 +1,15 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace LINGYUN.Abp.Location.Baidu.Http +{ + public class BaiduInverseLocationResponse : BaiduLocationResponse + { + [JsonProperty("formatted_address")] + public string Address { get; set; } + + + } +} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/Http/BaiduLocationHttpClient.cs b/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/Http/BaiduLocationHttpClient.cs new file mode 100644 index 000000000..63b37a672 --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/Http/BaiduLocationHttpClient.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace LINGYUN.Abp.Location.Baidu.Http +{ + public class BaiduLocationHttpClient + { + + } +} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/Http/BaiduLocationResponse.cs b/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/Http/BaiduLocationResponse.cs new file mode 100644 index 000000000..a0b6ce6b8 --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/Http/BaiduLocationResponse.cs @@ -0,0 +1,14 @@ +namespace LINGYUN.Abp.Location.Baidu.Http +{ + public abstract class BaiduLocationResponse + { + public int Status { get; set; } + + public Location Location { get; set; } + + public bool IsSuccess() + { + return Status == 0; + } + } +} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/Http/BaiduPositiveLocationResponse.cs b/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/Http/BaiduPositiveLocationResponse.cs new file mode 100644 index 000000000..771b77c63 --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/Http/BaiduPositiveLocationResponse.cs @@ -0,0 +1,10 @@ +namespace LINGYUN.Abp.Location.Baidu.Http +{ + public class BaiduPositiveLocationResponse : BaiduLocationResponse + { + public int Precise { get; set; } + public int Confidence { get; set; } + public int Comprehension { get; set; } + public string Level { get; set; } + } +} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/Http/Location.cs b/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/Http/Location.cs new file mode 100644 index 000000000..69094316f --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/Http/Location.cs @@ -0,0 +1,8 @@ +namespace LINGYUN.Abp.Location.Baidu.Http +{ + public class Location + { + public double Lat { get; set; } + public double Lng { get; set; } + } +} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN.Abp.Location.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN.Abp.Location.csproj new file mode 100644 index 000000000..268dae169 --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN.Abp.Location.csproj @@ -0,0 +1,12 @@ + + + + netstandard2.0 + + + + + + + + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN/Abp/Location/AbpLocationModule.cs b/aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN/Abp/Location/AbpLocationModule.cs new file mode 100644 index 000000000..bc677f26b --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN/Abp/Location/AbpLocationModule.cs @@ -0,0 +1,8 @@ +using Volo.Abp.Modularity; + +namespace LINGYUN.Abp.Location +{ + public class AbpLocationModule : AbpModule + { + } +} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN/Abp/Location/ILocationResolveProvider.cs b/aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN/Abp/Location/ILocationResolveProvider.cs new file mode 100644 index 000000000..20ed819de --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN/Abp/Location/ILocationResolveProvider.cs @@ -0,0 +1,9 @@ +namespace LINGYUN.Abp.Location +{ + public interface ILocationResolveProvider + { + PositiveLocation GetPositiveLocation(string address); + + InverseLocation GetInverseLocation(double lat, double lng); + } +} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN/Abp/Location/InverseLocation.cs b/aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN/Abp/Location/InverseLocation.cs new file mode 100644 index 000000000..bb9f0a290 --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN/Abp/Location/InverseLocation.cs @@ -0,0 +1,45 @@ +namespace LINGYUN.Abp.Location +{ + /// + /// 逆地址 + /// + public class InverseLocation + { + /// + /// 详细地址 + /// + public string Address { get; set; } + /// + /// 国家 + /// + public string Country { get; set; } + /// + /// 省份 + /// + public string Province { get; set; } + /// + /// 城市 + /// + public string City { get; set; } + /// + /// 区县 + /// + public string District { get; set; } + /// + /// 街道 + /// + public string Street { get; set; } + /// + /// adcode + /// + public string AdCode { get; set; } + /// + /// 乡镇 + /// + public string Town { get; set; } + /// + /// 门牌号 + /// + public string Number { get; set; } + } +} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN/Abp/Location/Location.cs b/aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN/Abp/Location/Location.cs new file mode 100644 index 000000000..ed1ebaee4 --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN/Abp/Location/Location.cs @@ -0,0 +1,97 @@ +using System; + +namespace LINGYUN.Abp.Location +{ + public abstract class Location + { + /// + /// 地球半径(米) + /// + public const double EARTH_RADIUS = 6378137; + /// + /// 纬度 + /// + public double Latitude { get; set; } + /// + /// 经度 + /// + public double Longitude { get; set; } + + /// + /// 计算两个位置的距离,返回两点的距离,单位 米 + /// 该公式为GOOGLE提供,误差小于0.2米 + /// + /// 参与计算的位置信息 + /// 返回两个位置的距离 + public double CalcDistance(Location location) + { + return CalcDistance(this, location); + } + /// + /// 计算两个位置的距离,返回两点的距离,单位 米 + /// 该公式为GOOGLE提供,误差小于0.2米 + /// + /// 参与计算的位置信息 + /// 参与计算的位置信息 + /// 返回两个位置的距离 + public static double CalcDistance(Location location1, Location location2) + { + double radLat1 = Rad(location1.Latitude); + double radLng1 = Rad(location1.Longitude); + double radLat2 = Rad(location2.Latitude); + double radLng2 = Rad(location2.Longitude); + double a = radLat1 - radLat2; + double b = radLng1 - radLng2; + double result = 2 * Math.Asin(Math.Sqrt(Math.Pow(Math.Sin(a / 2), 2) + Math.Cos(radLat1) * Math.Cos(radLat2) * Math.Pow(Math.Sin(b / 2), 2))); + result *= EARTH_RADIUS; + return result; + } + /// + /// 计算位置的偏移距离 + /// + /// 参与计算的位置 + /// 位置偏移量,单位 米 + /// + public static Position CalcOffsetDistance(Location location, double distance) + { + double dlng = 2 * Math.Asin(Math.Sin(distance / (2 * EARTH_RADIUS)) / Math.Cos(Rad(location.Latitude))); + dlng = Deg(dlng); + double dlat = distance / EARTH_RADIUS; + dlat = Deg(dlat); + double leftTopLat = location.Latitude + dlat; + double leftTopLng = location.Longitude - dlng; + + double leftBottomLat = location.Latitude - dlat; + double leftBottomLng = location.Longitude - dlng; + + double rightTopLat = location.Latitude + dlat; + double rightTopLng = location.Longitude + dlng; + + double rightBottomLat = location.Latitude - dlat; + double rightBottomLng = location.Longitude + dlng; + + return new Position(leftTopLat, leftBottomLat, leftTopLng, leftBottomLng, + rightTopLat, rightBottomLat, rightTopLng, rightBottomLng); + } + + /// + /// 角度转换为弧度 + /// + /// + /// + public static double Rad(double d) + { + return d * Math.PI / 180d; + } + + /// + /// 弧度转换为角度 + /// + /// + /// + public static double Deg(double d) + { + return d * (180 / Math.PI); + } + } +} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN/Abp/Location/Position.cs b/aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN/Abp/Location/Position.cs new file mode 100644 index 000000000..d466846fd --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN/Abp/Location/Position.cs @@ -0,0 +1,55 @@ +namespace LINGYUN.Abp.Location +{ + /// + /// 位置量 + /// + public class Position + { + /// + /// 左上纬度 + /// + public double LeftTopLatitude { get; } + /// + /// 左上经度 + /// + public double LeftTopLongitude { get; } + /// + /// 左下纬度 + /// + public double LeftBottomLatitude { get; } + /// + /// 左下经度 + /// + public double LeftBottomLongitude { get; } + + /// + /// 右上纬度 + /// + public double RightTopLatitude { get; } + /// + /// 右上经度 + /// + public double RightTopLongitude { get; } + /// + /// 右下纬度 + /// + public double RightBottomLatitude { get; } + /// + /// 右下经度 + /// + public double RightBottomLongitude { get; } + + internal Position(double leftTopLat, double leftBottomLat, double leftTopLng, double leftBottomLng, + double rightTopLat, double rightBottomLat, double rightTopLng, double rightBottomLng) + { + LeftTopLatitude = leftTopLat; + LeftBottomLatitude = leftBottomLat; + LeftTopLongitude = leftTopLng; + LeftBottomLongitude = leftBottomLng; + RightTopLatitude = rightTopLat; + RightTopLongitude = rightTopLng; + RightBottomLatitude = rightBottomLat; + RightBottomLongitude = rightBottomLng; + } + } +} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN/Abp/Location/PositiveLocation.cs b/aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN/Abp/Location/PositiveLocation.cs new file mode 100644 index 000000000..b7008523a --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN/Abp/Location/PositiveLocation.cs @@ -0,0 +1,27 @@ +namespace LINGYUN.Abp.Location +{ + /// + /// 正地址 + /// + public class PositiveLocation : Location + { + /// + /// 附加信息 + /// + public int Precise { get; set; } + /// + /// 绝对精度 + /// + public int Confidence { get; set; } + /// + /// 理解程度 + /// 分值范围0-100 + /// 分值越大,服务对地址理解程度越高 + /// + public int Pomprehension { get; set; } + /// + /// 能精确理解的地址类型 + /// + public string Level { get; set; } + } +} diff --git a/vueJs/src/App.vue b/vueJs/src/App.vue index 772997990..fa8146b67 100644 --- a/vueJs/src/App.vue +++ b/vueJs/src/App.vue @@ -6,6 +6,7 @@ diff --git a/vueJs/src/api/abpconfiguration.ts b/vueJs/src/api/abpconfiguration.ts index 697026231..2faa10727 100644 --- a/vueJs/src/api/abpconfiguration.ts +++ b/vueJs/src/api/abpconfiguration.ts @@ -96,4 +96,14 @@ export class AbpConfiguration implements IAbpConfiguration { multiTenancy!: MultiTenancy objectExtensions!: any setting!: Setting + + constructor() { + this.auth = new Auth() + this.setting = new Setting() + this.features = new Feature() + this.currentUser = new CurrentUser() + this.localization = new Localization() + this.multiTenancy = new MultiTenancy() + this.currentTenant = new CurrentTenant() + } } \ No newline at end of file diff --git a/vueJs/src/api/apigateway.ts b/vueJs/src/api/apigateway.ts index dac2a1bb8..94ebde590 100644 --- a/vueJs/src/api/apigateway.ts +++ b/vueJs/src/api/apigateway.ts @@ -277,7 +277,7 @@ export class GlobalConfigurationBase { export class GlobalConfigurationDto extends GlobalConfigurationBase { appId!: string - itemId!: number + itemId!: string } export class GlobalConfigurationCreateDto extends GlobalConfigurationBase { @@ -285,7 +285,7 @@ export class GlobalConfigurationCreateDto extends GlobalConfigurationBase { } export class GlobalConfigurationUpdateDto extends GlobalConfigurationBase { - itemId!: number + itemId!: string } export class GlobalGetByPagedDto extends PagedAndSortedResultRequestDto { diff --git a/vueJs/src/lang/zh.ts b/vueJs/src/lang/zh.ts index 5bac66fd6..0f83d9487 100644 --- a/vueJs/src/lang/zh.ts +++ b/vueJs/src/lang/zh.ts @@ -105,7 +105,8 @@ export default { tokenExprition: '身份令牌已过期,请重新登录!', confirmLogout: '确认登出', relogin: '重新登录', - cancel: '取消' + cancel: '取消', + tenantIsNotAvailable: '给定的租户不可用: {name}' }, documentation: { documentation: '文档', diff --git a/vueJs/src/utils/localStorage.ts b/vueJs/src/utils/localStorage.ts index fc6d2c1d1..92a1450c9 100644 --- a/vueJs/src/utils/localStorage.ts +++ b/vueJs/src/utils/localStorage.ts @@ -16,9 +16,21 @@ export const removeAbpConfig = () => localStorage.removeItem(abpConfigKey) // User const tokenKey = 'vue_typescript_admin_token' const refreshTokenKey = 'vue_typescript_admin_refresh_token' -export const getToken = () => localStorage.getItem(tokenKey) +export function getToken() { + const tokenItem = localStorage.getItem(tokenKey) + if (tokenItem) { + return tokenItem + } + return '' +} export const setToken = (token: string) => localStorage.setItem(tokenKey, token) -export const getRefreshToken = () => localStorage.getItem(refreshTokenKey) +export const getRefreshToken = () => { + const tokenItem = localStorage.getItem(refreshTokenKey) + if (tokenItem) { + return tokenItem + } + return '' +} export const setRefreshToken = (token: string) => localStorage.setItem(refreshTokenKey, token) export const removeToken = () => { localStorage.removeItem(tokenKey) diff --git a/vueJs/src/views/admin/apigateway/components/GlobalCreateOrEditForm.vue b/vueJs/src/views/admin/apigateway/components/GlobalCreateOrEditForm.vue index 6045f8d1c..65f6b9fb5 100644 --- a/vueJs/src/views/admin/apigateway/components/GlobalCreateOrEditForm.vue +++ b/vueJs/src/views/admin/apigateway/components/GlobalCreateOrEditForm.vue @@ -13,7 +13,7 @@ > @@ -386,7 +386,7 @@ export default class extends Vue { } get hasEdit() { - if (this.globalConfiguration.itemId && this.globalConfiguration.itemId !== 0) { + if (this.globalConfiguration.itemId) { return true } return false @@ -411,6 +411,8 @@ export default class extends Vue { private handleAppIdChanged(appId: string) { if (appId) { this.handleGetGlobalConfiguration() + } else { + this.globalConfiguration = new GlobalConfigurationDto() } } @@ -443,6 +445,7 @@ export default class extends Vue { } private onCancel() { + this.appId = '' const formGlobal = this.$refs.formGlobal as any formGlobal.resetFields() this.$emit('closed', false) diff --git a/vueJs/src/views/admin/apigateway/components/RouteGroupCreateOrEditForm.vue b/vueJs/src/views/admin/apigateway/components/RouteGroupCreateOrEditForm.vue index bdf3b5384..6e4aa4848 100644 --- a/vueJs/src/views/admin/apigateway/components/RouteGroupCreateOrEditForm.vue +++ b/vueJs/src/views/admin/apigateway/components/RouteGroupCreateOrEditForm.vue @@ -97,6 +97,9 @@ export default class extends Vue { ], appName: [ { required: true, message: this.l('pleaseInputBy', { key: this.l('apiGateWay.appName') }), trigger: 'blur' } + ], + appIpAddress: [ + { required: true, message: this.l('pleaseInputBy', { key: this.l('apiGateWay.appIpAddress') }), trigger: 'blur' } ] } @@ -143,6 +146,7 @@ export default class extends Vue { } private onCancel() { + this.apiGateWayRouteGroup = new RouteGroupDto() const routerEditForm = this.$refs.formRouteGroup as any routerEditForm.resetFields() this.$emit('closed', false) diff --git a/vueJs/src/views/login/components/TenantSelect.vue b/vueJs/src/views/login/components/TenantSelect.vue new file mode 100644 index 000000000..d96409f90 --- /dev/null +++ b/vueJs/src/views/login/components/TenantSelect.vue @@ -0,0 +1,57 @@ + + + diff --git a/vueJs/src/views/login/index.vue b/vueJs/src/views/login/index.vue index c45c1144f..58c764125 100644 --- a/vueJs/src/views/login/index.vue +++ b/vueJs/src/views/login/index.vue @@ -14,6 +14,10 @@ + { const phoneReg = /^1[34578]\d{9}$/ if (!value || !phoneReg.test(value)) { @@ -301,7 +312,6 @@ export default class extends Vue { .title { font-size: 26px; - color: $lightGray; margin: 0px auto 20px auto; text-align: center; font-weight: bold; @@ -320,7 +330,6 @@ export default class extends Vue { } .set-language { - color: #fff; position: absolute; top: 3px; font-size: 18px; @@ -347,7 +356,7 @@ export default class extends Vue { padding: 35px 35px 15px; border: 1px solid #8c9494; box-shadow: 0 0 25px #454646; - background-color:rgb(110, 115, 116); + background-color:rgb(247, 255, 255); .loginTab.el-tabs__item { width: 180px;