forked from gongxuegit/tiku-backend.net
feat: add tenant content asset management endpoints
This commit is contained in:
@@ -88,6 +88,16 @@ public sealed class ExceptionHandlingMiddleware(
|
||||
return;
|
||||
}
|
||||
|
||||
if (exception is AssetManagementException assetManagementException)
|
||||
{
|
||||
await WriteProblemAsync(
|
||||
context,
|
||||
assetManagementException.Message,
|
||||
AssetManagementStatusCode(assetManagementException.Code),
|
||||
assetManagementException.Code);
|
||||
return;
|
||||
}
|
||||
|
||||
if (exception is LearningValidationException learningValidationException)
|
||||
{
|
||||
await WriteProblemAsync(
|
||||
@@ -209,4 +219,15 @@ public sealed class ExceptionHandlingMiddleware(
|
||||
_ => StatusCodes.Status400BadRequest
|
||||
};
|
||||
}
|
||||
|
||||
private static int AssetManagementStatusCode(string code)
|
||||
{
|
||||
return code switch
|
||||
{
|
||||
"asset_not_found" or "import_job_not_found" => StatusCodes.Status404NotFound,
|
||||
"asset_upload_missing" => StatusCodes.Status409Conflict,
|
||||
"tenant_content_access_denied" => StatusCodes.Status403Forbidden,
|
||||
_ => StatusCodes.Status400BadRequest
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user