feat: add student points endpoints

This commit is contained in:
xiong
2026-07-26 19:59:20 +08:00
parent 77cac70344
commit a4621df728
7 changed files with 1017 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.Points;
using Tiku.Application.Storage;
using Tiku.Infrastructure.Content;
using Tiku.Infrastructure.Learning;
@@ -183,6 +184,16 @@ public sealed class ExceptionHandlingMiddleware(
return;
}
if (exception is PointException pointException)
{
await WriteProblemAsync(
context,
pointException.Message,
PointStatusCode(pointException.Code),
pointException.Code);
return;
}
if (exception is PaymentProviderException paymentProviderException)
{
await WriteProblemAsync(
@@ -342,4 +353,16 @@ public sealed class ExceptionHandlingMiddleware(
_ => StatusCodes.Status400BadRequest
};
}
private static int PointStatusCode(string code)
{
return code switch
{
"point_access_denied" or "tenant_access_denied" => StatusCodes.Status403Forbidden,
"point_task_not_found" or "point_exchange_item_not_found" => StatusCodes.Status404NotFound,
"point_task_claim_limit_reached" or "insufficient_points" or "point_exchange_item_sold_out" =>
StatusCodes.Status409Conflict,
_ => StatusCodes.Status400BadRequest
};
}
}