30 changed files with 492 additions and 40 deletions
@ -0,0 +1,20 @@ |
|||||
|
using Newtonsoft.Json; |
||||
|
using System.Text.Json.Serialization; |
||||
|
|
||||
|
namespace LINGYUN.Abp.Location.Baidu.Model |
||||
|
{ |
||||
|
public class AddressDetail |
||||
|
{ |
||||
|
[JsonProperty("city")] |
||||
|
[JsonPropertyName("city")] |
||||
|
public string City { get; set; } |
||||
|
|
||||
|
[JsonProperty("city_code")] |
||||
|
[JsonPropertyName("city_code")] |
||||
|
public int CityCode { get; set; } |
||||
|
|
||||
|
[JsonProperty("province")] |
||||
|
[JsonPropertyName("province")] |
||||
|
public string Province { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
using Newtonsoft.Json; |
||||
|
using System.Text.Json.Serialization; |
||||
|
|
||||
|
namespace LINGYUN.Abp.Location.Baidu.Model |
||||
|
{ |
||||
|
public class Content |
||||
|
{ |
||||
|
public string Address { get; set; } |
||||
|
|
||||
|
[JsonProperty("address_detail")] |
||||
|
[JsonPropertyName("address_detail")] |
||||
|
public AddressDetail AddressDetail { get; set; } = new AddressDetail(); |
||||
|
|
||||
|
public IpPoint Point { get; set; } = new IpPoint(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,29 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace LINGYUN.Abp.Location.Baidu.Model |
||||
|
{ |
||||
|
public class IpPoint |
||||
|
{ |
||||
|
public string X { get; set; } |
||||
|
public string Y { get; set; } |
||||
|
|
||||
|
public Point ToPoint() |
||||
|
{ |
||||
|
if (!X.IsNullOrWhiteSpace() && |
||||
|
!Y.IsNullOrWhiteSpace()) |
||||
|
{ |
||||
|
if (float.TryParse(X, out float x) && |
||||
|
float.TryParse(Y, out float y)) |
||||
|
{ |
||||
|
return new Point |
||||
|
{ |
||||
|
X = x, |
||||
|
Y = y |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return new Point(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
using LINGYUN.Abp.Location.Baidu.Model; |
||||
|
|
||||
|
namespace LINGYUN.Abp.Location.Baidu.Response |
||||
|
{ |
||||
|
public class BaiduIpGeocodeResponse : BaiduLocationResponse |
||||
|
{ |
||||
|
public string Address { get; set; } |
||||
|
|
||||
|
public Content Content { get; set; } = new Content(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,27 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>net5.0</TargetFramework> |
||||
|
<RootNamespace /> |
||||
|
<IsPackable>false</IsPackable> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" /> |
||||
|
<PackageReference Include="xunit" Version="2.4.1" /> |
||||
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> |
||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
||||
|
<PrivateAssets>all</PrivateAssets> |
||||
|
</PackageReference> |
||||
|
<PackageReference Include="coverlet.collector" Version="1.3.0"> |
||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
||||
|
<PrivateAssets>all</PrivateAssets> |
||||
|
</PackageReference> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\..\modules\common\LINGYUN.Abp.Location.Baidu\LINGYUN.Abp.Location.Baidu.csproj" /> |
||||
|
<ProjectReference Include="..\LINGYUN.Abp.TestBase\LINGYUN.Abp.TestsBase.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,9 @@ |
|||||
|
using LINGYUN.Abp.Tests; |
||||
|
|
||||
|
namespace LINGYUN.Abp.Location.Baidu |
||||
|
{ |
||||
|
public class AbpLocationBaiduTestBase : AbpTestsBase<AbpLocationBaiduTestModule> |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,24 @@ |
|||||
|
using LINGYUN.Abp.Tests; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace LINGYUN.Abp.Location.Baidu |
||||
|
{ |
||||
|
[DependsOn( |
||||
|
typeof(AbpBaiduLocationModule), |
||||
|
typeof(AbpTestsBaseModule))] |
||||
|
public class AbpLocationBaiduTestModule : AbpModule |
||||
|
{ |
||||
|
public override void PreConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
var configurationOptions = new AbpConfigurationBuilderOptions |
||||
|
{ |
||||
|
BasePath = @"D:\Projects\Development\Abp\Location\Baidu", |
||||
|
EnvironmentName = "Development" |
||||
|
}; |
||||
|
|
||||
|
context.Services.ReplaceConfiguration(ConfigurationHelper.BuildConfiguration(configurationOptions)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,58 @@ |
|||||
|
using Shouldly; |
||||
|
using System.Threading.Tasks; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace LINGYUN.Abp.Location.Baidu |
||||
|
{ |
||||
|
public class BaiduLocationResolveProviderTests : AbpLocationBaiduTestBase |
||||
|
{ |
||||
|
private readonly ILocationResolveProvider _provider; |
||||
|
|
||||
|
public BaiduLocationResolveProviderTests() |
||||
|
{ |
||||
|
_provider = GetRequiredService<ILocationResolveProvider>(); |
||||
|
_provider.ShouldBeOfType<BaiduLocationResolveProvider>(); |
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData(39.906049, 116.398773, 1000)] |
||||
|
public async Task ReGeocode_Test(double lat, double lng, int radius = 50) |
||||
|
{ |
||||
|
var location = await _provider.ReGeocodeAsync(lat, lng, radius); |
||||
|
|
||||
|
location.ShouldNotBeNull(); |
||||
|
location.Address.ShouldBe("北京市西城区前门西大街正阳市场4号楼"); |
||||
|
location.FormattedAddress.ShouldBe("前门西大街正阳市场4号楼"); |
||||
|
|
||||
|
// TODO
|
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData("北京市东城区广场东侧路", "北京")] |
||||
|
public async Task Geocode_Test(string address, string city = "") |
||||
|
{ |
||||
|
var location = await _provider.GeocodeAsync(address, city); |
||||
|
|
||||
|
location.ShouldNotBeNull(); |
||||
|
location.Latitude.ShouldBe(39.91125781161926); |
||||
|
location.Longitude.ShouldBe(116.40588581321788); |
||||
|
location.Level.ShouldBe("道路"); |
||||
|
location.Pomprehension.ShouldBe(0); |
||||
|
|
||||
|
// TODO
|
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData("111.206.145.41")] |
||||
|
public async Task IPGeocode_Test(string ipAddress) |
||||
|
{ |
||||
|
var location = await _provider.IPGeocodeAsync(ipAddress); |
||||
|
|
||||
|
location.ShouldNotBeNull(); |
||||
|
location.Location.Latitude.ShouldBe(39.91489028930664); |
||||
|
location.Location.Longitude.ShouldBe(116.40387725830078); |
||||
|
|
||||
|
// TODO
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,27 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>net5.0</TargetFramework> |
||||
|
<RootNamespace /> |
||||
|
<IsPackable>false</IsPackable> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" /> |
||||
|
<PackageReference Include="xunit" Version="2.4.1" /> |
||||
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> |
||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
||||
|
<PrivateAssets>all</PrivateAssets> |
||||
|
</PackageReference> |
||||
|
<PackageReference Include="coverlet.collector" Version="1.3.0"> |
||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
||||
|
<PrivateAssets>all</PrivateAssets> |
||||
|
</PackageReference> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\..\modules\common\LINGYUN.Abp.Location.Tencent\LINGYUN.Abp.Location.Tencent.csproj" /> |
||||
|
<ProjectReference Include="..\LINGYUN.Abp.TestBase\LINGYUN.Abp.TestsBase.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,9 @@ |
|||||
|
using LINGYUN.Abp.Tests; |
||||
|
|
||||
|
namespace LINGYUN.Abp.Location.Tencent |
||||
|
{ |
||||
|
public class AbpLocationTencentTestBase : AbpTestsBase<AbpLocationTencentTestModule> |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,24 @@ |
|||||
|
using LINGYUN.Abp.Tests; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace LINGYUN.Abp.Location.Tencent |
||||
|
{ |
||||
|
[DependsOn( |
||||
|
typeof(AbpTencentLocationModule), |
||||
|
typeof(AbpTestsBaseModule))] |
||||
|
public class AbpLocationTencentTestModule : AbpModule |
||||
|
{ |
||||
|
public override void PreConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
var configurationOptions = new AbpConfigurationBuilderOptions |
||||
|
{ |
||||
|
BasePath = @"D:\Projects\Development\Abp\Location\Tencent", |
||||
|
EnvironmentName = "Development" |
||||
|
}; |
||||
|
|
||||
|
context.Services.ReplaceConfiguration(ConfigurationHelper.BuildConfiguration(configurationOptions)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,58 @@ |
|||||
|
using Shouldly; |
||||
|
using System.Threading.Tasks; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace LINGYUN.Abp.Location.Tencent |
||||
|
{ |
||||
|
public class TencentLocationResolveProviderTests : AbpLocationTencentTestBase |
||||
|
{ |
||||
|
private readonly ILocationResolveProvider _provider; |
||||
|
|
||||
|
public TencentLocationResolveProviderTests() |
||||
|
{ |
||||
|
_provider = GetRequiredService<ILocationResolveProvider>(); |
||||
|
_provider.ShouldBeOfType<TencentLocationResolveProvider>(); |
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData(39.906049, 116.398773, 1000)] |
||||
|
public async Task ReGeocode_Test(double lat, double lng, int radius = 50) |
||||
|
{ |
||||
|
var location = await _provider.ReGeocodeAsync(lat, lng, radius); |
||||
|
|
||||
|
location.ShouldNotBeNull(); |
||||
|
location.Address.ShouldBe("北京市东城区东长安街"); |
||||
|
location.FormattedAddress.ShouldBe("天安门广场"); |
||||
|
|
||||
|
// TODO
|
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData("北京市东城区广场东侧路")] |
||||
|
public async Task Geocode_Test(string address, string city = "") |
||||
|
{ |
||||
|
var location = await _provider.GeocodeAsync(address, city); |
||||
|
|
||||
|
location.ShouldNotBeNull(); |
||||
|
location.Latitude.ShouldBe(39.907631); |
||||
|
location.Longitude.ShouldBe(116.399384); |
||||
|
location.Level.ShouldBe("7"); |
||||
|
location.Pomprehension.ShouldBe(0); |
||||
|
|
||||
|
// TODO
|
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData("111.206.145.41")] |
||||
|
public async Task IPGeocode_Test(string ipAddress) |
||||
|
{ |
||||
|
var location = await _provider.IPGeocodeAsync(ipAddress); |
||||
|
|
||||
|
location.ShouldNotBeNull(); |
||||
|
location.Location.Latitude.ShouldBe(40.0403); |
||||
|
location.Location.Longitude.ShouldBe(116.2734); |
||||
|
|
||||
|
// TODO
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,11 +1,9 @@ |
|||||
. "./build-aspnetcore-common.ps1" |
. "./build-aspnetcore-common.ps1" |
||||
|
|
||||
# Build all solutions |
# Build all solutions |
||||
foreach ($batchCommandPath in $batchCommandPaths) { |
foreach ($service in $serviceArray) { |
||||
$file = [io.fileinfo]$batchCommandPath; |
Set-Location $service.Path |
||||
Write-Host $file.DirectoryName |
dotnet ef database update |
||||
Set-Location $file.DirectoryName |
|
||||
CMD /c $file.Name --ef-u -Wait |
|
||||
} |
} |
||||
|
|
||||
Set-Location $rootFolder |
Set-Location $rootFolder |
||||
@ -1,11 +1,10 @@ |
|||||
. "./build-aspnetcore-common.ps1" |
. "./build-aspnetcore-common.ps1" |
||||
|
|
||||
# Build all solutions |
# Build all solutions |
||||
foreach ($batchCommandPath in $batchCommandPaths) { |
foreach ($service in $serviceArray) { |
||||
$file = [io.fileinfo]$batchCommandPath; |
Set-Location $service.Path |
||||
Write-Host $file.DirectoryName |
$publishPath = $service.Path + "/../../Publish/" + $service.Service |
||||
Set-Location $file.DirectoryName |
dotnet publish -c Release -o $publishPath --no-cache --no-restore |
||||
CMD /c $file.Name --publish -Wait |
|
||||
} |
} |
||||
|
|
||||
Set-Location $rootFolder |
Set-Location $rootFolder |
||||
Loading…
Reference in new issue