feat(esppApi): EsppResultBase
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.EsppApi.Models;
|
using PARR.EsppApi.Models;
|
||||||
|
using PARR.EsppApi.Models.Query;
|
||||||
using PARR.EsppApi.Services;
|
using PARR.EsppApi.Services;
|
||||||
using PARR.EsppApi.Settings;
|
using PARR.EsppApi.Settings;
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ namespace PARR.EsppApi
|
|||||||
this.espp = espp;
|
this.espp = espp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<EsppOrder>> FindOrdersByPrefixAsync(string prefix)
|
public async Task<EsppResultBase<IEnumerable<EsppOrder>>> FindOrdersByPrefixAsync(FindOrdersQuery query)
|
||||||
{
|
{
|
||||||
logger.LogInformation("Привет!");
|
logger.LogInformation("Привет!");
|
||||||
|
|
||||||
@@ -26,7 +27,9 @@ namespace PARR.EsppApi
|
|||||||
var aaa = await espp.Get();
|
var aaa = await espp.Get();
|
||||||
logger.LogInformation($"asdasd: {aaa}");
|
logger.LogInformation($"asdasd: {aaa}");
|
||||||
|
|
||||||
return new List<EsppOrder>();
|
var esppOrders = new List<EsppOrder>();
|
||||||
|
|
||||||
|
return new EsppResultBase<IEnumerable<EsppOrder>>(esppOrders, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using PARR.EsppApi.Models;
|
using PARR.EsppApi.Models;
|
||||||
|
using PARR.EsppApi.Models.Query;
|
||||||
|
|
||||||
namespace PARR.EsppApi
|
namespace PARR.EsppApi
|
||||||
{
|
{
|
||||||
@@ -8,6 +9,6 @@ namespace PARR.EsppApi
|
|||||||
/// Найти наряды в ЕСПП по префиксу
|
/// Найти наряды в ЕСПП по префиксу
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IEnumerable<EsppOrder>> FindOrdersByPrefixAsync(string prefix);
|
Task<EsppResultBase<IEnumerable<EsppOrder>>> FindOrdersByPrefixAsync(FindOrdersQuery query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
PARR.EsppApi/Models/EsppResultBase.cs
Normal file
18
PARR.EsppApi/Models/EsppResultBase.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
namespace PARR.EsppApi.Models
|
||||||
|
{
|
||||||
|
public class EsppResultBase<T> where T : class
|
||||||
|
{
|
||||||
|
public EsppResultBase(T? data, bool isSuccess, Exception? exception = null)
|
||||||
|
{
|
||||||
|
Data = data;
|
||||||
|
IsSuccess = isSuccess;
|
||||||
|
Exception = exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T? Data { get; private set; }
|
||||||
|
|
||||||
|
public bool IsSuccess { get; private set; }
|
||||||
|
|
||||||
|
public Exception? Exception { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
7
PARR.EsppApi/Models/Query/FindOrdersQuery.cs
Normal file
7
PARR.EsppApi/Models/Query/FindOrdersQuery.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace PARR.EsppApi.Models.Query
|
||||||
|
{
|
||||||
|
public class FindOrdersQuery
|
||||||
|
{
|
||||||
|
//todo: тут поля для запроса списка нарядов из еспп
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using PARR.EsppApi;
|
using PARR.EsppApi;
|
||||||
|
using PARR.EsppApi.Models.Query;
|
||||||
|
|
||||||
namespace PARR.Test
|
namespace PARR.Test
|
||||||
{
|
{
|
||||||
@@ -27,7 +28,13 @@ namespace PARR.Test
|
|||||||
|
|
||||||
private async Task TestEsppApi()
|
private async Task TestEsppApi()
|
||||||
{
|
{
|
||||||
var orders = await esppApiService.FindOrdersByPrefixAsync("ПАРР__");
|
// var orders = await esppApiService.FindOrdersByPrefixAsync("ПАРР__");
|
||||||
|
var result = await esppApiService.FindOrdersByPrefixAsync(new FindOrdersQuery { });
|
||||||
|
|
||||||
|
if (result.IsSuccess)
|
||||||
|
{
|
||||||
|
var orders = result.Data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user