forked from xiongyuxing/tiku-backend.net
feat(saas): implement marketplace and tenant onboarding
This commit is contained in:
@@ -8,6 +8,7 @@ using Tiku.Application.Content;
|
||||
using Tiku.Application.Growth;
|
||||
using Tiku.Application.Points;
|
||||
using Tiku.Application.PlatformAdmin;
|
||||
using Tiku.Application.PlatformBilling;
|
||||
using Tiku.Application.QuestionBanks;
|
||||
using Tiku.Application.Storage;
|
||||
using Tiku.Infrastructure.Content;
|
||||
@@ -56,6 +57,18 @@ public sealed class ExceptionHandlingMiddleware(
|
||||
return;
|
||||
}
|
||||
|
||||
if (exception is FeatureAccessException featureAccessException)
|
||||
{
|
||||
await WriteProblemAsync(
|
||||
context,
|
||||
featureAccessException.Message,
|
||||
featureAccessException.Code == "feature_quota_exhausted"
|
||||
? StatusCodes.Status409Conflict
|
||||
: StatusCodes.Status403Forbidden,
|
||||
featureAccessException.Code);
|
||||
return;
|
||||
}
|
||||
|
||||
if (exception is TenantContextConflictException)
|
||||
{
|
||||
await WriteProblemAsync(
|
||||
@@ -262,6 +275,16 @@ public sealed class ExceptionHandlingMiddleware(
|
||||
return;
|
||||
}
|
||||
|
||||
if (exception is PlatformBillingException platformBillingException)
|
||||
{
|
||||
await WriteProblemAsync(
|
||||
context,
|
||||
platformBillingException.Message,
|
||||
PlatformBillingStatusCode(platformBillingException.Code),
|
||||
platformBillingException.Code);
|
||||
return;
|
||||
}
|
||||
|
||||
if (exception is CommerceException commerceException)
|
||||
{
|
||||
await WriteProblemAsync(
|
||||
@@ -518,6 +541,22 @@ public sealed class ExceptionHandlingMiddleware(
|
||||
};
|
||||
}
|
||||
|
||||
private static int PlatformBillingStatusCode(string code)
|
||||
{
|
||||
return code switch
|
||||
{
|
||||
"tenant_not_found" => StatusCodes.Status404NotFound,
|
||||
"platform_billing_public_url_missing" or "payment_provider_not_configured" or
|
||||
"payment_secret_not_configured" => StatusCodes.Status503ServiceUnavailable,
|
||||
"saas_offering_version_immutable" or "saas_offering_version_status_invalid" or
|
||||
"platform_billing_quote_expired" or "platform_billing_order_status_invalid" or
|
||||
"platform_billing_payment_status_invalid" or "platform_billing_payment_amount_mismatch" =>
|
||||
StatusCodes.Status409Conflict,
|
||||
_ when code.EndsWith("_not_found", StringComparison.Ordinal) => StatusCodes.Status404NotFound,
|
||||
_ => StatusCodes.Status400BadRequest
|
||||
};
|
||||
}
|
||||
|
||||
private static int PointStatusCode(string code)
|
||||
{
|
||||
return code switch
|
||||
|
||||
Reference in New Issue
Block a user