feat : RDB 기능 추가 (라이브러리, base 코드 구현)
This commit is contained in:
22
MMOTestServer/ServerLib/RDB/Handlers/HelperHandler.cs
Normal file
22
MMOTestServer/ServerLib/RDB/Handlers/HelperHandler.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Text.Json;
|
||||
|
||||
namespace ServerLib.RDB.Handlers;
|
||||
|
||||
public static class HandlerHelper
|
||||
{
|
||||
public static string Success<T>(T data)
|
||||
{
|
||||
return JsonSerializer.Serialize(new Response<T> { Success = true, Data = data });
|
||||
}
|
||||
|
||||
public static string Error(string message)
|
||||
{
|
||||
return JsonSerializer.Serialize(new Response<object> { Success = false, Error = message });
|
||||
}
|
||||
|
||||
public static T? Deserialize<T>(string payload)
|
||||
{
|
||||
try { return JsonSerializer.Deserialize<T>(payload); }
|
||||
catch { return default; }
|
||||
}
|
||||
}
|
||||
8
MMOTestServer/ServerLib/RDB/Handlers/Response.cs
Normal file
8
MMOTestServer/ServerLib/RDB/Handlers/Response.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace ServerLib.RDB.Handlers;
|
||||
|
||||
public class Response<T>
|
||||
{
|
||||
public bool Success { get; init; }
|
||||
public T? Data { get; init; }
|
||||
public string? Error { get; init; }
|
||||
}
|
||||
Reference in New Issue
Block a user