forked from xiongyuxing/tiku-backend.net
feat: add tenant admin direct operations endpoints
This commit is contained in:
@@ -9,6 +9,7 @@ using Tiku.Infrastructure.Learning;
|
||||
using Tiku.Infrastructure.Profile;
|
||||
using Tiku.Infrastructure.QuestionBanks;
|
||||
using Tiku.Infrastructure.Scoreline;
|
||||
using Tiku.Application.TenantAdmin;
|
||||
|
||||
namespace Tiku.Api.Middleware;
|
||||
|
||||
@@ -161,6 +162,16 @@ public sealed class ExceptionHandlingMiddleware(
|
||||
return;
|
||||
}
|
||||
|
||||
if (exception is TenantAdminDirectException tenantAdminDirectException)
|
||||
{
|
||||
await WriteProblemAsync(
|
||||
context,
|
||||
tenantAdminDirectException.Message,
|
||||
TenantAdminDirectStatusCode(tenantAdminDirectException.Code),
|
||||
tenantAdminDirectException.Code);
|
||||
return;
|
||||
}
|
||||
|
||||
if (exception is ObjectStorageException storageException)
|
||||
{
|
||||
await WriteProblemAsync(
|
||||
@@ -285,4 +296,16 @@ public sealed class ExceptionHandlingMiddleware(
|
||||
_ => StatusCodes.Status400BadRequest
|
||||
};
|
||||
}
|
||||
|
||||
private static int TenantAdminDirectStatusCode(string code)
|
||||
{
|
||||
return code switch
|
||||
{
|
||||
"tenant_admin_access_denied" => StatusCodes.Status403Forbidden,
|
||||
"class_not_found" or "class_member_not_found" or "student_not_found" or "user_not_found" => StatusCodes.Status404NotFound,
|
||||
"tenant_member_not_found" => StatusCodes.Status400BadRequest,
|
||||
_ when code.EndsWith("_not_found", StringComparison.Ordinal) => StatusCodes.Status400BadRequest,
|
||||
_ => StatusCodes.Status400BadRequest
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user