forked from gongxuegit/tiku-backend.net
feat: add student points endpoints
This commit is contained in:
@@ -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
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user