Browse Source

Aggregated the 3 endpoints in one

to decrease calling service aggregated the 3 endpoints into GetDashboard  endpoint
pull/110/head
malik masis 5 years ago
parent
commit
cb21c20d48
  1. 5
      services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderItems/TopSellingDto.cs
  2. 7
      services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderItems/TopSellingInput.cs
  3. 13
      services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/DashboardDto.cs
  4. 2
      services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/DashboardInput.cs
  5. 7
      services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/IOrderAppService.cs
  6. 5
      services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/OrderStatusDto.cs
  7. 7
      services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/OrderStatusInput.cs
  8. 3
      services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/PaymentDto.cs
  9. 23
      services/ordering/src/EShopOnAbp.OrderingService.Application/Orders/OrderAppService.cs
  10. 23
      services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/OrderClientProxy.Generated.cs
  11. 92
      services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/ordering-generate-proxy.json

5
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<Guid>
public class TopSellingDto : EntityDto
{
public string ProductName { get; set; }
public string PictureUrl { get; set; }

7
services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderItems/TopSellingInput.cs

@ -1,7 +0,0 @@
namespace EShopOnAbp.OrderingService.OrderItems
{
public class TopSellingInput
{
public string Filter { get; set; }
}
}

13
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<TopSellingDto> TopSellings { get; set; }
public List<PaymentDto> Payments { get; set; }
public List<OrderStatusDto> OrderStatusDto { get; set; }
}
}

2
services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/PaymentInput.cs → 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; }
}

7
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<PagedResultDto<OrderDto>> GetListPagedAsync(PagedAndSortedResultRequestDto input);
Task<List<TopSellingDto>> GetTopSellingAsync(TopSellingInput input);
Task<List<PaymentDto>> GetPercentOfTotalPaymentAsync(PaymentInput input);
Task<List<OrderStatusDto>> GetCountOfTotalOrderStatusAsync(OrderStatusInput input);
Task<DashboardDto> GetDashboardAsync(DashboardInput input);
}

5
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<Guid>
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; }
}

7
services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Orders/OrderStatusInput.cs

@ -1,7 +0,0 @@
namespace EShopOnAbp.OrderingService.Orders
{
public class OrderStatusInput
{
public string Filter { get; set; }
}
}

3
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<Guid>
public class PaymentDto : EntityDto
{
public decimal RateOfPaymentMethod { get; set; }
public string PaymentMethod { get; set; }

23
services/ordering/src/EShopOnAbp.OrderingService.Application/Orders/OrderAppService.cs

@ -71,23 +71,34 @@ public class OrderAppService : ApplicationService, IOrderAppService
);
}
public async Task<List<TopSellingDto>> GetTopSellingAsync(TopSellingInput input)
public async Task<DashboardDto> GetDashboardAsync(DashboardInput input)
{
ISpecification<Order> 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<List<TopSellingDto>> GetTopSellingAsync(string filter)
{
ISpecification<Order> specification = SpecificationFactory.Create(filter);
var orderItems = await _orderRepository.GetTopSelling(specification, true);
return ObjectMapper.Map<List<OrderItem>, List<TopSellingDto>>(orderItems);
}
public async Task<List<PaymentDto>> GetPercentOfTotalPaymentAsync(PaymentInput input)
private async Task<List<PaymentDto>> GetPercentOfTotalPaymentAsync(string filter)
{
ISpecification<Order> specification = SpecificationFactory.Create(input.Filter);
ISpecification<Order> specification = SpecificationFactory.Create(filter);
var orders = await _orderRepository.GetPercentOfTotalPayment(specification);
return CreatePaymentDtoMapping(orders);
}
public async Task<List<OrderStatusDto>> GetCountOfTotalOrderStatusAsync(OrderStatusInput input)
private async Task<List<OrderStatusDto>> GetCountOfTotalOrderStatusAsync(string filter)
{
ISpecification<Order> specification = SpecificationFactory.Create(input.Filter);
ISpecification<Order> specification = SpecificationFactory.Create(filter);
var orders = await _orderRepository.GetCountOfTotalOrderStatus(specification, true);
return CreateOrderStatusDtoMapping(orders);
}

23
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<IOrderAppService>, IOrde
});
}
public virtual async Task<List<TopSellingDto>> GetTopSellingAsync(TopSellingInput input)
public virtual async Task<DashboardDto> GetDashboardAsync(DashboardInput input)
{
return await RequestAsync<List<TopSellingDto>>(nameof(GetTopSellingAsync), new ClientProxyRequestTypeValue
return await RequestAsync<DashboardDto>(nameof(GetDashboardAsync), new ClientProxyRequestTypeValue
{
{ typeof(TopSellingInput), input }
});
}
public virtual async Task<List<PaymentDto>> GetPercentOfTotalPaymentAsync(PaymentInput input)
{
return await RequestAsync<List<PaymentDto>>(nameof(GetPercentOfTotalPaymentAsync), new ClientProxyRequestTypeValue
{
{ typeof(PaymentInput), input }
});
}
public virtual async Task<List<OrderStatusDto>> GetCountOfTotalOrderStatusAsync(OrderStatusInput input)
{
return await RequestAsync<List<OrderStatusDto>>(nameof(GetCountOfTotalOrderStatusAsync), new ClientProxyRequestTypeValue
{
{ typeof(OrderStatusInput), input }
{ typeof(DashboardInput), input }
});
}

92
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<EShopOnAbp.OrderingService.OrderItems.TopSellingDto>",
"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<EShopOnAbp.OrderingService.Orders.PaymentDto>",
"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<EShopOnAbp.OrderingService.Orders.OrderStatusDto>",
"typeSimple": "[EShopOnAbp.OrderingService.Orders.OrderStatusDto]"
"type": "EShopOnAbp.OrderingService.Orders.DashboardDto",
"typeSimple": "EShopOnAbp.OrderingService.Orders.DashboardDto"
},
"allowAnonymous": null,
"implementFrom": "EShopOnAbp.OrderingService.Orders.IOrderAppService"

Loading…
Cancel
Save