AcaMate_API/Program/Common/Model/Status.cs

79 lines
1.8 KiB
C#

using System.Text.Json;
namespace AcaMate.Common.Models;
public class APIResponseStatus<T>
{
public Status status { get; set; }
public T? data { get; set; }
public string JsonToString()
{
return JsonSerializer.Serialize(this);
}
}
public class Status
{
public string code { get; set; }
public string message { get; set; }
}
public static class DefaultResponse
{
// private static readonly Lazy<ErrorResponse> _instance = new Lazy<ErrorResponse>();
// public static ErrorResponse Instace => _instance.Value;
// private ErrorResponse()
// {
// // 외부 초기화 방지
// }
public static APIResponseStatus<string> Success = new APIResponseStatus<string>
{
status = new Status()
{
code = "000",
message = "정상"
}
};
public static APIResponseStatus<string> InvalidInputError = new APIResponseStatus<string>
{
status = new Status()
{
code = "001",
message = "입력 값이 유효하지 않습니다."
}
};
public static APIResponseStatus<string> NotFoundError = new APIResponseStatus<string>
{
status = new Status()
{
code = "002",
message = "알맞은 값을 찾을 수 없습니다."
}
};
public static APIResponseStatus<string> InternalSeverError = new APIResponseStatus<string>
{
status = new Status
{
code = "003",
message = "통신에 오류가 발생하였습니다."
}
};
public static APIResponseStatus<string> UnknownError = new APIResponseStatus<string>
{
status = new Status()
{
code = "999",
message = "알 수 없는 오류가 발생하였습니다.."
}
};
}