Browse Source

Expose PaymentMethods via endpoints

pull/64/head
enisn 5 years ago
parent
commit
a423d54430
  1. 10
      services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentMethods/IPaymentMethodAppService.cs
  2. 6
      services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentMethods/PaymentMethodDto.cs
  3. 24
      services/payment/src/EShopOnAbp.PaymentService.Application/PaymentMethods/PaymentMethodAppService.cs
  4. 25
      services/payment/src/EShopOnAbp.PaymentService.HttpApi/Controllers/PaymentMethodController.cs

10
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<List<PaymentMethodDto>> GetListAsync();
}

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

24
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<IPaymentMethod> _paymentMethods;
public PaymentMethodAppService(IEnumerable<IPaymentMethod> paymentMethods)
{
this._paymentMethods = paymentMethods;
}
public Task<List<PaymentMethodDto>> GetListAsync()
{
return Task.FromResult(
_paymentMethods
.Select(p => new PaymentMethodDto { PaymentType = p.PaymentType })
.ToList()
);
}
}

25
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<List<PaymentMethodDto>> GetListAsync()
{
return PaymentMethodAppService.GetListAsync();
}
}
Loading…
Cancel
Save