From 61bfa5079aab75938ffea688cde60af9c46bf5cd Mon Sep 17 00:00:00 2001 From: Mikhail Trubnikov Date: Fri, 20 Oct 2023 09:24:27 +1000 Subject: [PATCH] feat(esppApi): EsppResultBase --- PARR.EsppApi/EsppApiService.cs | 7 +++++-- PARR.EsppApi/IEsppApiService.cs | 3 ++- PARR.EsppApi/Models/EsppResultBase.cs | 18 ++++++++++++++++++ PARR.EsppApi/Models/Query/FindOrdersQuery.cs | 7 +++++++ PARR.Test/Worker.cs | 9 ++++++++- 5 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 PARR.EsppApi/Models/EsppResultBase.cs create mode 100644 PARR.EsppApi/Models/Query/FindOrdersQuery.cs diff --git a/PARR.EsppApi/EsppApiService.cs b/PARR.EsppApi/EsppApiService.cs index 891d2f7b..bc3f9d61 100644 --- a/PARR.EsppApi/EsppApiService.cs +++ b/PARR.EsppApi/EsppApiService.cs @@ -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> FindOrdersByPrefixAsync(string prefix) + public async Task>> FindOrdersByPrefixAsync(FindOrdersQuery query) { logger.LogInformation("Привет!"); @@ -26,7 +27,9 @@ namespace PARR.EsppApi var aaa = await espp.Get(); logger.LogInformation($"asdasd: {aaa}"); - return new List(); + var esppOrders = new List(); + + return new EsppResultBase>(esppOrders, true); } } diff --git a/PARR.EsppApi/IEsppApiService.cs b/PARR.EsppApi/IEsppApiService.cs index 34115fdd..72e74f5d 100644 --- a/PARR.EsppApi/IEsppApiService.cs +++ b/PARR.EsppApi/IEsppApiService.cs @@ -1,4 +1,5 @@ using PARR.EsppApi.Models; +using PARR.EsppApi.Models.Query; namespace PARR.EsppApi { @@ -8,6 +9,6 @@ namespace PARR.EsppApi /// Найти наряды в ЕСПП по префиксу /// /// - Task> FindOrdersByPrefixAsync(string prefix); + Task>> FindOrdersByPrefixAsync(FindOrdersQuery query); } } diff --git a/PARR.EsppApi/Models/EsppResultBase.cs b/PARR.EsppApi/Models/EsppResultBase.cs new file mode 100644 index 00000000..0e611d53 --- /dev/null +++ b/PARR.EsppApi/Models/EsppResultBase.cs @@ -0,0 +1,18 @@ +namespace PARR.EsppApi.Models +{ + public class EsppResultBase 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; } + } +} diff --git a/PARR.EsppApi/Models/Query/FindOrdersQuery.cs b/PARR.EsppApi/Models/Query/FindOrdersQuery.cs new file mode 100644 index 00000000..40197b6c --- /dev/null +++ b/PARR.EsppApi/Models/Query/FindOrdersQuery.cs @@ -0,0 +1,7 @@ +namespace PARR.EsppApi.Models.Query +{ + public class FindOrdersQuery + { + //todo: тут поля для запроса списка нарядов из еспп + } +} diff --git a/PARR.Test/Worker.cs b/PARR.Test/Worker.cs index 8d1cff3a..8c80b4fc 100644 --- a/PARR.Test/Worker.cs +++ b/PARR.Test/Worker.cs @@ -1,4 +1,5 @@ using PARR.EsppApi; +using PARR.EsppApi.Models.Query; namespace PARR.Test { @@ -27,7 +28,13 @@ namespace PARR.Test 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; + } } }