forked from gongxuegit/tiku-backend.net
feat: modularize external providers
This commit is contained in:
@@ -453,16 +453,18 @@ public sealed class CreateTenantDomainDto
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class UpsertTenantAuthProviderDto
|
||||
public sealed class UpsertTenantIdentityProviderDto
|
||||
{
|
||||
public required string Provider { get; set; }
|
||||
public string? Status { get; set; }
|
||||
public string? DisplayName { get; set; }
|
||||
public string? SecretRef { get; set; }
|
||||
public int? Priority { get; set; }
|
||||
public JsonElement ConfigPublic { get; set; } = JsonDefaults.Object();
|
||||
|
||||
public UpsertTenantAuthProviderCommand ToCommand()
|
||||
public UpsertTenantIdentityProviderCommand ToCommand()
|
||||
{
|
||||
return new UpsertTenantAuthProviderCommand(Provider, Status, DisplayName, ConfigPublic);
|
||||
return new UpsertTenantIdentityProviderCommand(Provider, Status, DisplayName, SecretRef, Priority, ConfigPublic);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,18 +29,24 @@ public sealed class UpsertPaymentAccountDto
|
||||
[StringLength(50)]
|
||||
public string Provider { get; set; } = string.Empty;
|
||||
|
||||
public TenantPaymentMode Mode { get; set; } = TenantPaymentMode.TenantCollect;
|
||||
[StringLength(50)]
|
||||
public string? Mode { get; set; } = "TenantCollect";
|
||||
|
||||
[StringLength(200)]
|
||||
public string? DisplayName { get; set; }
|
||||
|
||||
public TenantPaymentAccountStatus Status { get; set; } = TenantPaymentAccountStatus.Disabled;
|
||||
public TenantExternalProviderStatus Status { get; set; } = TenantExternalProviderStatus.Disabled;
|
||||
|
||||
[StringLength(300)]
|
||||
public string? SecretRef { get; set; }
|
||||
|
||||
public int? Priority { get; set; }
|
||||
|
||||
public JsonElement ConfigPublic { get; set; } = JsonDefaults.Object();
|
||||
|
||||
public UpsertPaymentAccountCommand ToCommand()
|
||||
{
|
||||
return new UpsertPaymentAccountCommand(Provider, Mode, DisplayName, Status, ConfigPublic);
|
||||
return new UpsertPaymentAccountCommand(Provider, Mode, DisplayName, Status, SecretRef, Priority, ConfigPublic);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -302,17 +302,17 @@ public sealed class TenantAdminDirectController(
|
||||
|
||||
[HttpGet("auth-providers")]
|
||||
[EndpointSummary("查询租户登录 Provider 公开配置")]
|
||||
[ProducesResponseType<CatalogList<TenantAuthProviderItem>>(StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult<CatalogList<TenantAuthProviderItem>>> GetAuthProviders(CancellationToken cancellationToken)
|
||||
[ProducesResponseType<CatalogList<TenantIdentityProviderItem>>(StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult<CatalogList<TenantIdentityProviderItem>>> GetAuthProviders(CancellationToken cancellationToken)
|
||||
{
|
||||
return Ok(await tenantAdminService.GetAuthProvidersAsync(ResolveActor(), cancellationToken));
|
||||
}
|
||||
|
||||
[HttpPut("auth-providers")]
|
||||
[EndpointSummary("新增或更新租户登录 Provider")]
|
||||
[ProducesResponseType<ContentManagementResult<TenantAuthProviderItem>>(StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult<ContentManagementResult<TenantAuthProviderItem>>> UpsertAuthProvider(
|
||||
UpsertTenantAuthProviderDto request,
|
||||
[ProducesResponseType<ContentManagementResult<TenantIdentityProviderItem>>(StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult<ContentManagementResult<TenantIdentityProviderItem>>> UpsertAuthProvider(
|
||||
UpsertTenantIdentityProviderDto request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
return Ok(await tenantAdminService.UpsertAuthProviderAsync(ResolveActor(), request.ToCommand(), cancellationToken));
|
||||
|
||||
@@ -17,8 +17,8 @@ public sealed class TenantCommerceController(
|
||||
{
|
||||
[HttpGet("payment-accounts")]
|
||||
[EndpointSummary("查询租户支付账号")]
|
||||
[ProducesResponseType<IReadOnlyCollection<TenantPaymentAccountItem>>(StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult<IReadOnlyCollection<TenantPaymentAccountItem>>> PaymentAccounts(
|
||||
[ProducesResponseType<IReadOnlyCollection<TenantPaymentProviderItem>>(StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult<IReadOnlyCollection<TenantPaymentProviderItem>>> PaymentAccounts(
|
||||
[FromQuery] TenantCommerceQueryDto query,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -30,8 +30,8 @@ public sealed class TenantCommerceController(
|
||||
|
||||
[HttpPut("payment-accounts")]
|
||||
[EndpointSummary("新增或更新租户支付账号")]
|
||||
[ProducesResponseType<TenantPaymentAccountItem>(StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult<TenantPaymentAccountItem>> UpsertPaymentAccount(
|
||||
[ProducesResponseType<TenantPaymentProviderItem>(StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult<TenantPaymentProviderItem>> UpsertPaymentAccount(
|
||||
UpsertPaymentAccountDto request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
@@ -284,6 +284,16 @@ public sealed class ExceptionHandlingMiddleware(
|
||||
return;
|
||||
}
|
||||
|
||||
if (exception is TenantExternalProviderException externalProviderException)
|
||||
{
|
||||
await WriteProblemAsync(
|
||||
context,
|
||||
externalProviderException.Message,
|
||||
StatusCodes.Status400BadRequest,
|
||||
externalProviderException.Code);
|
||||
return;
|
||||
}
|
||||
|
||||
if (exception is ObjectStorageException storageException)
|
||||
{
|
||||
await WriteProblemAsync(
|
||||
|
||||
Reference in New Issue
Block a user