From a423d54430f4d807215357a0a2cfa2391da6bd36 Mon Sep 17 00:00:00 2001 From: enisn Date: Tue, 18 Jan 2022 09:29:18 +0300 Subject: [PATCH] Expose PaymentMethods via endpoints --- .../IPaymentMethodAppService.cs | 10 ++++++++ .../PaymentMethods/PaymentMethodDto.cs | 6 +++++ .../PaymentMethods/PaymentMethodAppService.cs | 24 ++++++++++++++++++ .../Controllers/PaymentMethodController.cs | 25 +++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentMethods/IPaymentMethodAppService.cs create mode 100644 services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentMethods/PaymentMethodDto.cs create mode 100644 services/payment/src/EShopOnAbp.PaymentService.Application/PaymentMethods/PaymentMethodAppService.cs create mode 100644 services/payment/src/EShopOnAbp.PaymentService.HttpApi/Controllers/PaymentMethodController.cs diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentMethods/IPaymentMethodAppService.cs b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentMethods/IPaymentMethodAppService.cs new file mode 100644 index 00000000..eb7177af --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentMethods/IPaymentMethodAppService.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp.Application.Services; + +namespace EShopOnAbp.PaymentService.PaymentMethods; + +public interface IPaymentMethodAppService : IApplicationService +{ + Task> GetListAsync(); +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentMethods/PaymentMethodDto.cs b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentMethods/PaymentMethodDto.cs new file mode 100644 index 00000000..93ba6ceb --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentMethods/PaymentMethodDto.cs @@ -0,0 +1,6 @@ +namespace EShopOnAbp.PaymentService.PaymentMethods; + +public class PaymentMethodDto +{ + public string PaymentType { get; set; } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentMethods/PaymentMethodAppService.cs b/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentMethods/PaymentMethodAppService.cs new file mode 100644 index 00000000..f787fb82 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentMethods/PaymentMethodAppService.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace EShopOnAbp.PaymentService.PaymentMethods; + +public class PaymentMethodAppService : PaymentServiceAppService, IPaymentMethodAppService +{ + private readonly IEnumerable _paymentMethods; + + public PaymentMethodAppService(IEnumerable paymentMethods) + { + this._paymentMethods = paymentMethods; + } + + public Task> GetListAsync() + { + return Task.FromResult( + _paymentMethods + .Select(p => new PaymentMethodDto { PaymentType = p.PaymentType }) + .ToList() + ); + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi/Controllers/PaymentMethodController.cs b/services/payment/src/EShopOnAbp.PaymentService.HttpApi/Controllers/PaymentMethodController.cs new file mode 100644 index 00000000..9a805315 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi/Controllers/PaymentMethodController.cs @@ -0,0 +1,25 @@ +using EShopOnAbp.PaymentService.PaymentMethods; +using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp; + +namespace EShopOnAbp.PaymentService.Controllers; + +[RemoteService(Name = PaymentServiceRemoteServiceConsts.RemoteServiceName)] +[Area("payment")] +[Route("api/payment/methods")] +public class PaymentMethodController : PaymentServiceController, IPaymentMethodAppService +{ + protected IPaymentMethodAppService PaymentMethodAppService { get; } + + public PaymentMethodController(IPaymentMethodAppService paymentMethodAppService) + { + PaymentMethodAppService = paymentMethodAppService; + } + + public Task> GetListAsync() + { + return PaymentMethodAppService.GetListAsync(); + } +}