feat(esppApi): EsppResultBase

This commit is contained in:
Mikhail Trubnikov
2023-10-20 09:24:27 +10:00
parent f45fca9122
commit 61bfa5079a
5 changed files with 40 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
using Microsoft.Extensions.Logging;
using PARR.EsppApi.Models;
using PARR.EsppApi.Models.Query;
using PARR.EsppApi.Services;
using PARR.EsppApi.Settings;
@@ -18,7 +19,7 @@ namespace PARR.EsppApi
this.espp = espp;
}
public async Task<IEnumerable<EsppOrder>> FindOrdersByPrefixAsync(string prefix)
public async Task<EsppResultBase<IEnumerable<EsppOrder>>> FindOrdersByPrefixAsync(FindOrdersQuery query)
{
logger.LogInformation("Привет!");
@@ -26,7 +27,9 @@ namespace PARR.EsppApi
var aaa = await espp.Get();
logger.LogInformation($"asdasd: {aaa}");
return new List<EsppOrder>();
var esppOrders = new List<EsppOrder>();
return new EsppResultBase<IEnumerable<EsppOrder>>(esppOrders, true);
}
}

View File

@@ -1,4 +1,5 @@
using PARR.EsppApi.Models;
using PARR.EsppApi.Models.Query;
namespace PARR.EsppApi
{
@@ -8,6 +9,6 @@ namespace PARR.EsppApi
/// Найти наряды в ЕСПП по префиксу
/// </summary>
/// <returns></returns>
Task<IEnumerable<EsppOrder>> FindOrdersByPrefixAsync(string prefix);
Task<EsppResultBase<IEnumerable<EsppOrder>>> FindOrdersByPrefixAsync(FindOrdersQuery query);
}
}

View 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; }
}
}

View File

@@ -0,0 +1,7 @@
namespace PARR.EsppApi.Models.Query
{
public class FindOrdersQuery
{
//todo: тут поля для запроса списка нарядов из еспп
}
}