forked from gongxuegit/tiku-backend.net
feat(platform): add CRM SMS and payment settings
This commit is contained in:
56
Tiku.Api/Controllers/PlatformPaymentSettingsController.cs
Normal file
56
Tiku.Api/Controllers/PlatformPaymentSettingsController.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Tiku.Api.Contracts;
|
||||
using Tiku.Application.PlatformAdmin;
|
||||
using Tiku.Application.Security;
|
||||
using Tiku.Domain.Platform;
|
||||
|
||||
namespace Tiku.Api.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Authorize(Policy = TikuPolicies.PlatformBackofficeBootstrap)]
|
||||
[Produces("application/json")]
|
||||
[Route("api/platform-admin/payment-settings")]
|
||||
public sealed class PlatformPaymentSettingsController(
|
||||
IPlatformPaymentSettingsService paymentSettingsService,
|
||||
ICurrentUser currentUser) : ControllerBase
|
||||
{
|
||||
[HttpGet("apps")]
|
||||
[Authorize(Policy = BackendPermissions.PlatformPaymentRead)]
|
||||
public Task<IReadOnlyCollection<PlatformPaymentApp>> Apps(string? status, int limit = 100, CancellationToken cancellationToken = default) =>
|
||||
paymentSettingsService.GetAppsAsync(Actor(), status, limit, cancellationToken);
|
||||
|
||||
[HttpPut("apps")]
|
||||
[Authorize(Policy = BackendPermissions.PlatformPaymentWrite)]
|
||||
public Task<PlatformPaymentApp> UpsertApp(UpsertPlatformPaymentAppDto request, CancellationToken cancellationToken) =>
|
||||
paymentSettingsService.UpsertAppAsync(Actor(), request.ToCommand(), cancellationToken);
|
||||
|
||||
[HttpGet("channels")]
|
||||
[Authorize(Policy = BackendPermissions.PlatformPaymentRead)]
|
||||
public Task<IReadOnlyCollection<PlatformPaymentChannel>> Channels(Guid? appId, string? status, int limit = 100, CancellationToken cancellationToken = default) =>
|
||||
paymentSettingsService.GetChannelsAsync(Actor(), appId, status, limit, cancellationToken);
|
||||
|
||||
[HttpPut("channels")]
|
||||
[Authorize(Policy = BackendPermissions.PlatformPaymentWrite)]
|
||||
public Task<PlatformPaymentChannel> UpsertChannel(UpsertPlatformPaymentChannelDto request, CancellationToken cancellationToken) =>
|
||||
paymentSettingsService.UpsertChannelAsync(Actor(), request.ToCommand(), cancellationToken);
|
||||
|
||||
[HttpPost("channels/{id:guid}/disable")]
|
||||
[Authorize(Policy = BackendPermissions.PlatformPaymentWrite)]
|
||||
public Task<PlatformPaymentChannel> DisableChannel(Guid id, CancellationToken cancellationToken) =>
|
||||
paymentSettingsService.DisableChannelAsync(Actor(), id, cancellationToken);
|
||||
|
||||
[HttpGet("events")]
|
||||
[Authorize(Policy = BackendPermissions.PlatformPaymentRead)]
|
||||
public Task<IReadOnlyCollection<PlatformBillingPaymentEvent>> Events(string? status, int limit = 100, CancellationToken cancellationToken = default) =>
|
||||
paymentSettingsService.GetEventsAsync(Actor(), status, limit, cancellationToken);
|
||||
|
||||
[HttpGet("rebates/summary")]
|
||||
[Authorize(Policy = BackendPermissions.PlatformPaymentRead)]
|
||||
public Task<PlatformRebateSummary> RebateSummary(CancellationToken cancellationToken) =>
|
||||
paymentSettingsService.GetRebateSummaryAsync(Actor(), cancellationToken);
|
||||
|
||||
private PlatformCapabilityActor Actor() => currentUser.UserId is { } userId
|
||||
? new PlatformCapabilityActor(userId)
|
||||
: throw new PlatformCapabilityException("Platform actor was not resolved.", "platform_access_denied");
|
||||
}
|
||||
Reference in New Issue
Block a user