feat: add tenant content navigation management endpoints

This commit is contained in:
xiong
2026-07-26 17:25:08 +08:00
parent 3c0acebbbe
commit 1d7e09b1f0
8 changed files with 2066 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc;
using Tiku.Api.Controllers;
using Tiku.Application.Assets;
using Tiku.Application.Auth;
using Tiku.Application.Content;
using Tiku.Application.Storage;
using Tiku.Infrastructure.Content;
using Tiku.Infrastructure.Learning;
@@ -98,6 +99,16 @@ public sealed class ExceptionHandlingMiddleware(
return;
}
if (exception is ContentManagementException contentManagementException)
{
await WriteProblemAsync(
context,
contentManagementException.Message,
ContentManagementStatusCode(contentManagementException.Code),
contentManagementException.Code);
return;
}
if (exception is LearningValidationException learningValidationException)
{
await WriteProblemAsync(
@@ -230,4 +241,15 @@ public sealed class ExceptionHandlingMiddleware(
_ => StatusCodes.Status400BadRequest
};
}
private static int ContentManagementStatusCode(string code)
{
return code switch
{
"entry_not_found" or "node_not_found" or "collection_not_found" or "question_not_found" or
"import_type_invalid" => StatusCodes.Status404NotFound,
"tenant_content_access_denied" => StatusCodes.Status403Forbidden,
_ => StatusCodes.Status400BadRequest
};
}
}