feat: add referral growth endpoints

This commit is contained in:
xiong
2026-07-26 20:18:09 +08:00
parent 4efccf8355
commit 9fff468bd7
7 changed files with 1105 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ using Tiku.Application.Assets;
using Tiku.Application.Auth;
using Tiku.Application.Commerce;
using Tiku.Application.Content;
using Tiku.Application.Growth;
using Tiku.Application.Points;
using Tiku.Application.Storage;
using Tiku.Infrastructure.Content;
@@ -194,6 +195,16 @@ public sealed class ExceptionHandlingMiddleware(
return;
}
if (exception is ReferralException referralException)
{
await WriteProblemAsync(
context,
referralException.Message,
ReferralStatusCode(referralException.Code),
referralException.Code);
return;
}
if (exception is PaymentProviderException paymentProviderException)
{
await WriteProblemAsync(
@@ -367,4 +378,15 @@ public sealed class ExceptionHandlingMiddleware(
_ => StatusCodes.Status400BadRequest
};
}
private static int ReferralStatusCode(string code)
{
return code switch
{
"referral_access_denied" or "tenant_access_denied" => StatusCodes.Status403Forbidden,
"referral_code_not_found" => StatusCodes.Status404NotFound,
"referral_lead_protected" or "self_referral_not_allowed" => StatusCodes.Status409Conflict,
_ => StatusCodes.Status400BadRequest
};
}
}