forked from gongxuegit/tiku-backend.net
feat: add student profile endpoints
This commit is contained in:
@@ -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
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user