초기커밋
This commit is contained in:
45
UGQApiServer/ApiResponseFactory.cs
Normal file
45
UGQApiServer/ApiResponseFactory.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.Globalization;
|
||||
using UGQApiServer.Converter;
|
||||
using UGQApiServer.Models;
|
||||
using UGQDataAccess;
|
||||
using ServerCommon;
|
||||
using ServerCommon.UGQ.Models;
|
||||
using UGQApiServer.UGQData;
|
||||
|
||||
namespace UGQApiServer;
|
||||
|
||||
public static class ApiResponseFactory
|
||||
{
|
||||
public static ApiErrorResponse error(ServerErrorCode errorCode)
|
||||
{
|
||||
LangEnum langEnum = Culture.ToLangEnum(CultureInfo.CurrentCulture.Name);
|
||||
|
||||
var textId = errorCode.ToString().Replace("Ugq", "UGQ_Error_");
|
||||
var message = UGQDataHelper.getText(langEnum, textId);
|
||||
|
||||
return new ApiErrorResponse
|
||||
{
|
||||
ErrorCode = (int)errorCode,
|
||||
ErrorMessage = message ?? errorCode.ToString(),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public static ValidationErrorResponse validationError(ServerErrorCode errorCode, List<string> errors)
|
||||
{
|
||||
LangEnum langEnum = Culture.ToLangEnum(CultureInfo.CurrentCulture.Name);
|
||||
|
||||
var textId = errorCode.ToString().Replace("Ugq", "UGQ_Error_");
|
||||
var message = UGQDataHelper.getText(langEnum, textId);
|
||||
|
||||
return new ValidationErrorResponse
|
||||
{
|
||||
ErrorCode = (int)errorCode,
|
||||
ErrorMessage = message ?? errorCode.ToString(),
|
||||
ValidationErrorMessages = errors
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user