feat(esppApi): Заготовка для api
This commit is contained in:
@@ -1,21 +1,33 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.EsppApi.Models;
|
using PARR.EsppApi.Models;
|
||||||
|
using PARR.EsppApi.Services;
|
||||||
|
using PARR.EsppApi.Settings;
|
||||||
|
|
||||||
namespace PARR.EsppApi
|
namespace PARR.EsppApi
|
||||||
{
|
{
|
||||||
internal class EsppApiService : IEsppApiService
|
internal class EsppApiService : IEsppApiService
|
||||||
{
|
{
|
||||||
private readonly ILogger<EsppApiService> logger;
|
private readonly ILogger<EsppApiService> logger;
|
||||||
|
private readonly EsppOrderSettings esppOrderSettings;
|
||||||
|
private readonly Espp espp;
|
||||||
|
|
||||||
public EsppApiService(ILogger<EsppApiService> logger)
|
public EsppApiService(ILogger<EsppApiService> logger, EsppOrderSettings esppOrderSettings, Espp espp)
|
||||||
{
|
{
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
|
this.esppOrderSettings = esppOrderSettings;
|
||||||
|
this.espp = espp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<EsppOrder>> FindOrdersByPrefixAsync(string prefix)
|
public async Task<IEnumerable<EsppOrder>> FindOrdersByPrefixAsync(string prefix)
|
||||||
{
|
{
|
||||||
logger.LogInformation("Привет!");
|
logger.LogInformation("Привет!");
|
||||||
throw new NotImplementedException();
|
|
||||||
|
// var url = esppOrderSettings.Url;
|
||||||
|
var aaa = await espp.Get();
|
||||||
|
logger.LogInformation($"asdasd: {aaa}");
|
||||||
|
|
||||||
|
return new List<EsppOrder>();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,12 +10,8 @@
|
|||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.4" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.4" />
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Settings\" />
|
|
||||||
<Folder Include="Services\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using PARR.EsppApi.Services;
|
||||||
|
using PARR.EsppApi.Settings;
|
||||||
|
|
||||||
namespace PARR.EsppApi
|
namespace PARR.EsppApi
|
||||||
{
|
{
|
||||||
@@ -8,12 +10,14 @@ namespace PARR.EsppApi
|
|||||||
public static void InstallEsppApiServices(this IServiceCollection services, IConfiguration configuration)
|
public static void InstallEsppApiServices(this IServiceCollection services, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
// settings
|
// settings
|
||||||
//SettingsFromDb configuration
|
var esppSettings = new EsppOrderSettings();
|
||||||
//var settingsFromDb = new SettingsFromDb();
|
configuration.GetSection(nameof(EsppOrderSettings)).Bind(esppSettings);
|
||||||
//configuration.GetSection(nameof(SettingsFromDb)).Bind(settingsFromDb);
|
services.AddSingleton(esppSettings);
|
||||||
//services.AddSingleton(settingsFromDb);
|
|
||||||
|
|
||||||
services.AddTransient<IEsppApiService, EsppApiService>();
|
services.AddTransient<IEsppApiService, EsppApiService>();
|
||||||
|
|
||||||
|
services.AddHttpClient<Espp>();
|
||||||
//add other services
|
//add other services
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
27
PARR.EsppApi/Services/Espp.cs
Normal file
27
PARR.EsppApi/Services/Espp.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
namespace PARR.EsppApi.Services
|
||||||
|
{
|
||||||
|
internal class Espp
|
||||||
|
{
|
||||||
|
private readonly HttpClient httpClient;
|
||||||
|
|
||||||
|
public Espp(HttpClient httpClient)
|
||||||
|
{
|
||||||
|
this.httpClient = httpClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<string> Get()
|
||||||
|
{
|
||||||
|
//var req = new HttpRequestMessage(HttpMethod.Get, "https://www.google.com");
|
||||||
|
|
||||||
|
//if (req == null)
|
||||||
|
// return;
|
||||||
|
|
||||||
|
var response = await httpClient.GetAsync("http://dvocor.dvgd.rzd");
|
||||||
|
var content = await response.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
10
PARR.EsppApi/Settings/EsppOrderSettings.cs
Normal file
10
PARR.EsppApi/Settings/EsppOrderSettings.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
namespace PARR.EsppApi.Settings
|
||||||
|
{
|
||||||
|
internal class EsppOrderSettings
|
||||||
|
{
|
||||||
|
public string Url { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
//login, pass
|
||||||
|
//todo: add othe
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
namespace PARR.EsppOrderLoader
|
|
||||||
{
|
|
||||||
public class Class1
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,4 +6,10 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\PARR.BLL\PARR.BLL.csproj" />
|
||||||
|
<ProjectReference Include="..\PARR.DAL\PARR.DAL.csproj" />
|
||||||
|
<ProjectReference Include="..\PARR.EsppApi\PARR.EsppApi.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
22
PARR.EsppOrderLoader/ParrEsppOrderLoaderInstaller.cs
Normal file
22
PARR.EsppOrderLoader/ParrEsppOrderLoaderInstaller.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace PARR.EsppOrderLoader
|
||||||
|
{
|
||||||
|
public static class ParrEsppOrderLoaderInstaller
|
||||||
|
{
|
||||||
|
public static void InstallEsppOrderLoaderServices(this IServiceCollection services, IConfiguration configuration)
|
||||||
|
{
|
||||||
|
//TODO: добавить настройи bll и dal и espp api
|
||||||
|
|
||||||
|
// settings
|
||||||
|
//SettingsFromDb configuration
|
||||||
|
//var settingsFromDb = new SettingsFromDb();
|
||||||
|
//configuration.GetSection(nameof(SettingsFromDb)).Bind(settingsFromDb);
|
||||||
|
//services.AddSingleton(settingsFromDb);
|
||||||
|
|
||||||
|
//add other services
|
||||||
|
//services.AddTransient<IEsppApiService, EsppApiService>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
namespace PARR.EsppOrderManager
|
|
||||||
{
|
|
||||||
public class Class1
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,4 +6,9 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\PARR.DAL\PARR.DAL.csproj" />
|
||||||
|
<ProjectReference Include="..\PARR.EsppApi\PARR.EsppApi.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
namespace PARR.Master
|
|
||||||
{
|
|
||||||
public class Class1
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,4 +6,9 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\PARR.BLL\PARR.BLL.csproj" />
|
||||||
|
<ProjectReference Include="..\PARR.DAL\PARR.DAL.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace PARR.Test
|
|||||||
|
|
||||||
private async Task TestEsppApi()
|
private async Task TestEsppApi()
|
||||||
{
|
{
|
||||||
// var orders = await esppApiService.FindOrdersByPrefixAsync("ПАРР__");
|
var orders = await esppApiService.FindOrdersByPrefixAsync("ПАРР__");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,5 +4,8 @@
|
|||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
"Microsoft.Hosting.Lifetime": "Information"
|
"Microsoft.Hosting.Lifetime": "Information"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"EsppOrderSettings": {
|
||||||
|
"Url": "http://dafsdf"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user