forked from gongxuegit/tiku-backend.net
feat: complete phase six backoffice operations
This commit is contained in:
@@ -7,6 +7,7 @@ using Tiku.Application.Commerce;
|
||||
using Tiku.Application.Content;
|
||||
using Tiku.Application.Growth;
|
||||
using Tiku.Application.Points;
|
||||
using Tiku.Application.PlatformAdmin;
|
||||
using Tiku.Application.QuestionBanks;
|
||||
using Tiku.Application.Storage;
|
||||
using Tiku.Infrastructure.Content;
|
||||
@@ -235,6 +236,16 @@ public sealed class ExceptionHandlingMiddleware(
|
||||
return;
|
||||
}
|
||||
|
||||
if (exception is PlatformAdminException platformAdminException)
|
||||
{
|
||||
await WriteProblemAsync(
|
||||
context,
|
||||
platformAdminException.Message,
|
||||
PlatformAdminStatusCode(platformAdminException.Code),
|
||||
platformAdminException.Code);
|
||||
return;
|
||||
}
|
||||
|
||||
if (exception is CommerceException commerceException)
|
||||
{
|
||||
await WriteProblemAsync(
|
||||
@@ -469,6 +480,17 @@ public sealed class ExceptionHandlingMiddleware(
|
||||
};
|
||||
}
|
||||
|
||||
private static int PlatformAdminStatusCode(string code)
|
||||
{
|
||||
return code switch
|
||||
{
|
||||
"platform_access_denied" => StatusCodes.Status403Forbidden,
|
||||
"tenant_slug_exists" => 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