From cb21c20d485a58c3634093b0c1ade0449fa12f27 Mon Sep 17 00:00:00 2001 From: malik masis Date: Thu, 17 Mar 2022 11:34:43 +0300 Subject: [PATCH] Aggregated the 3 endpoints in one to decrease calling service aggregated the 3 endpoints into GetDashboard endpoint --- .../OrderItems/TopSellingDto.cs | 5 +- .../OrderItems/TopSellingInput.cs | 7 -- .../Orders/DashboardDto.cs | 13 +++ .../{PaymentInput.cs => DashboardInput.cs} | 2 +- .../Orders/IOrderAppService.cs | 7 +- .../Orders/OrderStatusDto.cs | 5 +- .../Orders/OrderStatusInput.cs | 7 -- .../Orders/PaymentDto.cs | 3 +- .../Orders/OrderAppService.cs | 23 +++-- .../OrderClientProxy.Generated.cs | 23 +---- .../ordering-generate-proxy.json | 92 ++----------------- 11 files changed, 50 insertions(+), 137 deletions(-) delete mode 100644 services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderItems/TopSellingInput.cs create mode 100644 services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/DashboardDto.cs rename services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/{PaymentInput.cs => DashboardInput.cs} (75%) delete mode 100644 services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/OrderStatusInput.cs diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderItems/TopSellingDto.cs b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderItems/TopSellingDto.cs index bbb6db56..2e9599d4 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderItems/TopSellingDto.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderItems/TopSellingDto.cs @@ -1,9 +1,8 @@ -using System; -using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Dtos; namespace EShopOnAbp.OrderingService.OrderItems { - public class TopSellingDto : EntityDto + public class TopSellingDto : EntityDto { public string ProductName { get; set; } public string PictureUrl { get; set; } diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderItems/TopSellingInput.cs b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderItems/TopSellingInput.cs deleted file mode 100644 index 43bfc299..00000000 --- a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderItems/TopSellingInput.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace EShopOnAbp.OrderingService.OrderItems -{ - public class TopSellingInput - { - public string Filter { get; set; } - } -} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/DashboardDto.cs b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/DashboardDto.cs new file mode 100644 index 00000000..2d44e0ee --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/DashboardDto.cs @@ -0,0 +1,13 @@ +using EShopOnAbp.OrderingService.OrderItems; +using System.Collections.Generic; +using Volo.Abp.Application.Dtos; + +namespace EShopOnAbp.OrderingService.Orders +{ + public class DashboardDto: EntityDto + { + public List TopSellings { get; set; } + public List Payments { get; set; } + public List OrderStatusDto { get; set; } + } +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/PaymentInput.cs b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/DashboardInput.cs similarity index 75% rename from services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/PaymentInput.cs rename to services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/DashboardInput.cs index a8239960..63f83b08 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/PaymentInput.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/DashboardInput.cs @@ -1,6 +1,6 @@ namespace EShopOnAbp.OrderingService.Orders { - public class PaymentInput + public class DashboardInput { public string Filter { get; set; } } diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/IOrderAppService.cs b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/IOrderAppService.cs index 4c6a4cec..c276bcb5 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/IOrderAppService.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/IOrderAppService.cs @@ -1,5 +1,4 @@ -using EShopOnAbp.OrderingService.OrderItems; -using System; +using System; using System.Collections.Generic; using System.Threading.Tasks; using Volo.Abp.Application.Dtos; @@ -17,8 +16,6 @@ public interface IOrderAppService : IApplicationService Task SetAsCancelledAsync(Guid id, SetAsCancelledDto input); Task SetAsShippedAsync(Guid id); Task> GetListPagedAsync(PagedAndSortedResultRequestDto input); - Task> GetTopSellingAsync(TopSellingInput input); - Task> GetPercentOfTotalPaymentAsync(PaymentInput input); - Task> GetCountOfTotalOrderStatusAsync(OrderStatusInput input); + Task GetDashboardAsync(DashboardInput input); } \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/OrderStatusDto.cs b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/OrderStatusDto.cs index 589dabad..01544f33 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/OrderStatusDto.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/OrderStatusDto.cs @@ -1,12 +1,11 @@ -using System; using Volo.Abp.Application.Dtos; namespace EShopOnAbp.OrderingService.Orders; -public class OrderStatusDto : EntityDto +public class OrderStatusDto : EntityDto { public int CountOfStatusOrder { get; set; } public string OrderStatus { get; set; } public int OrderStatusId { get; set; } - public decimal TotalIncome{ get; set; } + public decimal TotalIncome { get; set; } } \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/OrderStatusInput.cs b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/OrderStatusInput.cs deleted file mode 100644 index 107923bc..00000000 --- a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/OrderStatusInput.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace EShopOnAbp.OrderingService.Orders -{ - public class OrderStatusInput - { - public string Filter { get; set; } - } -} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/PaymentDto.cs b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/PaymentDto.cs index 9dc3cd1c..8b59a15c 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/PaymentDto.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/PaymentDto.cs @@ -1,9 +1,8 @@ -using System; using Volo.Abp.Application.Dtos; namespace EShopOnAbp.OrderingService.Orders; -public class PaymentDto : EntityDto +public class PaymentDto : EntityDto { public decimal RateOfPaymentMethod { get; set; } public string PaymentMethod { get; set; } diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Application/Orders/OrderAppService.cs b/services/ordering/src/EShopOnAbp.OrderingService.Application/Orders/OrderAppService.cs index bb494e40..a5b50d1a 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.Application/Orders/OrderAppService.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.Application/Orders/OrderAppService.cs @@ -71,23 +71,34 @@ public class OrderAppService : ApplicationService, IOrderAppService ); } - public async Task> GetTopSellingAsync(TopSellingInput input) + + public async Task GetDashboardAsync(DashboardInput input) { - ISpecification specification = SpecificationFactory.Create(input.Filter); + return new DashboardDto() + { + TopSellings = await GetTopSellingAsync(input.Filter), + OrderStatusDto = await GetCountOfTotalOrderStatusAsync(input.Filter), + Payments = await GetPercentOfTotalPaymentAsync(input.Filter) + }; + + } + private async Task> GetTopSellingAsync(string filter) + { + ISpecification specification = SpecificationFactory.Create(filter); var orderItems = await _orderRepository.GetTopSelling(specification, true); return ObjectMapper.Map, List>(orderItems); } - public async Task> GetPercentOfTotalPaymentAsync(PaymentInput input) + private async Task> GetPercentOfTotalPaymentAsync(string filter) { - ISpecification specification = SpecificationFactory.Create(input.Filter); + ISpecification specification = SpecificationFactory.Create(filter); var orders = await _orderRepository.GetPercentOfTotalPayment(specification); return CreatePaymentDtoMapping(orders); } - public async Task> GetCountOfTotalOrderStatusAsync(OrderStatusInput input) + private async Task> GetCountOfTotalOrderStatusAsync(string filter) { - ISpecification specification = SpecificationFactory.Create(input.Filter); + ISpecification specification = SpecificationFactory.Create(filter); var orders = await _orderRepository.GetCountOfTotalOrderStatus(specification, true); return CreateOrderStatusDtoMapping(orders); } diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/OrderClientProxy.Generated.cs b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/OrderClientProxy.Generated.cs index a0f492f8..3846497a 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/OrderClientProxy.Generated.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/OrderClientProxy.Generated.cs @@ -8,7 +8,6 @@ using Volo.Abp.DependencyInjection; using Volo.Abp.Http.Client.ClientProxying; using EShopOnAbp.OrderingService.Orders; using System.Collections.Generic; -using EShopOnAbp.OrderingService.OrderItems; // ReSharper disable once CheckNamespace namespace EShopOnAbp.OrderingService.Orders.ClientProxies; @@ -49,27 +48,11 @@ public partial class OrderClientProxy : ClientProxyBase, IOrde }); } - public virtual async Task> GetTopSellingAsync(TopSellingInput input) + public virtual async Task GetDashboardAsync(DashboardInput input) { - return await RequestAsync>(nameof(GetTopSellingAsync), new ClientProxyRequestTypeValue + return await RequestAsync(nameof(GetDashboardAsync), new ClientProxyRequestTypeValue { - { typeof(TopSellingInput), input } - }); - } - - public virtual async Task> GetPercentOfTotalPaymentAsync(PaymentInput input) - { - return await RequestAsync>(nameof(GetPercentOfTotalPaymentAsync), new ClientProxyRequestTypeValue - { - { typeof(PaymentInput), input } - }); - } - - public virtual async Task> GetCountOfTotalOrderStatusAsync(OrderStatusInput input) - { - return await RequestAsync>(nameof(GetCountOfTotalOrderStatusAsync), new ClientProxyRequestTypeValue - { - { typeof(OrderStatusInput), input } + { typeof(DashboardInput), input } }); } diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/ordering-generate-proxy.json b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/ordering-generate-proxy.json index 3f0e9a70..82fa0e2a 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/ordering-generate-proxy.json +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/ordering-generate-proxy.json @@ -195,18 +195,18 @@ "allowAnonymous": false, "implementFrom": "EShopOnAbp.OrderingService.Orders.IOrderAppService" }, - "GetTopSellingAsyncByInput": { - "uniqueName": "GetTopSellingAsyncByInput", - "name": "GetTopSellingAsync", + "GetDashboardAsyncByInput": { + "uniqueName": "GetDashboardAsyncByInput", + "name": "GetDashboardAsync", "httpMethod": "GET", - "url": "api/ordering/order/top-selling", + "url": "api/ordering/order/dashboard", "supportedVersions": [], "parametersOnMethod": [ { "name": "input", - "typeAsString": "EShopOnAbp.OrderingService.OrderItems.TopSellingInput, EShopOnAbp.OrderingService.Application.Contracts", - "type": "EShopOnAbp.OrderingService.OrderItems.TopSellingInput", - "typeSimple": "EShopOnAbp.OrderingService.OrderItems.TopSellingInput", + "typeAsString": "EShopOnAbp.OrderingService.Orders.DashboardInput, EShopOnAbp.OrderingService.Application.Contracts", + "type": "EShopOnAbp.OrderingService.Orders.DashboardInput", + "typeSimple": "EShopOnAbp.OrderingService.Orders.DashboardInput", "isOptional": false, "defaultValue": null } @@ -226,82 +226,8 @@ } ], "returnValue": { - "type": "System.Collections.Generic.List", - "typeSimple": "[EShopOnAbp.OrderingService.OrderItems.TopSellingDto]" - }, - "allowAnonymous": null, - "implementFrom": "EShopOnAbp.OrderingService.Orders.IOrderAppService" - }, - "GetPercentOfTotalPaymentAsyncByInput": { - "uniqueName": "GetPercentOfTotalPaymentAsyncByInput", - "name": "GetPercentOfTotalPaymentAsync", - "httpMethod": "GET", - "url": "api/ordering/order/percent-of-total-payment", - "supportedVersions": [], - "parametersOnMethod": [ - { - "name": "input", - "typeAsString": "EShopOnAbp.OrderingService.Orders.PaymentInput, EShopOnAbp.OrderingService.Application.Contracts", - "type": "EShopOnAbp.OrderingService.Orders.PaymentInput", - "typeSimple": "EShopOnAbp.OrderingService.Orders.PaymentInput", - "isOptional": false, - "defaultValue": null - } - ], - "parameters": [ - { - "nameOnMethod": "input", - "name": "Filter", - "jsonName": null, - "type": "System.String", - "typeSimple": "string", - "isOptional": false, - "defaultValue": null, - "constraintTypes": null, - "bindingSourceId": "ModelBinding", - "descriptorName": "input" - } - ], - "returnValue": { - "type": "System.Collections.Generic.List", - "typeSimple": "[EShopOnAbp.OrderingService.Orders.PaymentDto]" - }, - "allowAnonymous": null, - "implementFrom": "EShopOnAbp.OrderingService.Orders.IOrderAppService" - }, - "GetCountOfTotalOrderStatusAsyncByInput": { - "uniqueName": "GetCountOfTotalOrderStatusAsyncByInput", - "name": "GetCountOfTotalOrderStatusAsync", - "httpMethod": "GET", - "url": "api/ordering/order/count-of-total-order-status", - "supportedVersions": [], - "parametersOnMethod": [ - { - "name": "input", - "typeAsString": "EShopOnAbp.OrderingService.Orders.OrderStatusInput, EShopOnAbp.OrderingService.Application.Contracts", - "type": "EShopOnAbp.OrderingService.Orders.OrderStatusInput", - "typeSimple": "EShopOnAbp.OrderingService.Orders.OrderStatusInput", - "isOptional": false, - "defaultValue": null - } - ], - "parameters": [ - { - "nameOnMethod": "input", - "name": "Filter", - "jsonName": null, - "type": "System.String", - "typeSimple": "string", - "isOptional": false, - "defaultValue": null, - "constraintTypes": null, - "bindingSourceId": "ModelBinding", - "descriptorName": "input" - } - ], - "returnValue": { - "type": "System.Collections.Generic.List", - "typeSimple": "[EShopOnAbp.OrderingService.Orders.OrderStatusDto]" + "type": "EShopOnAbp.OrderingService.Orders.DashboardDto", + "typeSimple": "EShopOnAbp.OrderingService.Orders.DashboardDto" }, "allowAnonymous": null, "implementFrom": "EShopOnAbp.OrderingService.Orders.IOrderAppService"