feat: add student profile endpoints

This commit is contained in:
xiong
2026-07-26 18:36:28 +08:00
parent 5715869d29
commit 387b85342a
12 changed files with 16275 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ using Tiku.Application.Content;
using Tiku.Application.Storage;
using Tiku.Infrastructure.Content;
using Tiku.Infrastructure.Learning;
using Tiku.Infrastructure.Profile;
using Tiku.Infrastructure.QuestionBanks;
using Tiku.Infrastructure.Scoreline;
@@ -150,6 +151,16 @@ public sealed class ExceptionHandlingMiddleware(
return;
}
if (exception is ProfileException profileException)
{
await WriteProblemAsync(
context,
profileException.Message,
ProfileStatusCode(profileException.Code),
profileException.Code);
return;
}
if (exception is ObjectStorageException storageException)
{
await WriteProblemAsync(
@@ -263,4 +274,15 @@ public sealed class ExceptionHandlingMiddleware(
_ => StatusCodes.Status400BadRequest
};
}
private static int ProfileStatusCode(string code)
{
return code switch
{
"profile_access_denied" => StatusCodes.Status403Forbidden,
"profile_user_not_found" => StatusCodes.Status404NotFound,
"region_not_found" or "school_not_found" or "major_not_found" => StatusCodes.Status404NotFound,
_ => StatusCodes.Status400BadRequest
};
}
}