feat : RDB 기능 추가 (라이브러리, base 코드 구현)
This commit is contained in:
48
MMOTestServer/MMOserver/RDB/Handlers/TestHandlers.cs
Normal file
48
MMOTestServer/MMOserver/RDB/Handlers/TestHandlers.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using MMOserver.RDB.Models;
|
||||
using MMOserver.RDB.Services;
|
||||
using ServerLib.RDB.Handlers;
|
||||
|
||||
namespace MMOserver.RDB.Handlers;
|
||||
|
||||
public class TestHandler
|
||||
{
|
||||
private readonly TestService _testService;
|
||||
|
||||
public TestHandler(TestService testService) => _testService = testService;
|
||||
|
||||
public async Task<string> GetTestAsync(int id)
|
||||
{
|
||||
Test? result = await _testService.GetTestAsync(id);
|
||||
return result is null
|
||||
? HandlerHelper.Error("Test not found")
|
||||
: HandlerHelper.Success(result);
|
||||
}
|
||||
|
||||
public async Task<string> GetTestByUuidAsync(string uuid)
|
||||
{
|
||||
Test? result = await _testService.GetTestByUuidAsync(uuid);
|
||||
return result is null
|
||||
? HandlerHelper.Error("Test not found")
|
||||
: HandlerHelper.Success(result);
|
||||
}
|
||||
|
||||
public async Task<string> GetAllTestsAsync()
|
||||
{
|
||||
return HandlerHelper.Success(await _testService.GetAllTestsAsync());
|
||||
}
|
||||
|
||||
public async Task<string> CreateTestAsync(int testA, string testB, double testC)
|
||||
{
|
||||
return HandlerHelper.Success(await _testService.CreateTestAsync(testA, testB, testC));
|
||||
}
|
||||
|
||||
public async Task<string> UpdateTestAsync(int id, int? testA, string? testB, double? testC)
|
||||
{
|
||||
return HandlerHelper.Success(await _testService.UpdateTestAsync(id, testA, testB, testC));
|
||||
}
|
||||
|
||||
public async Task<string> DeleteTestAsync(int id)
|
||||
{
|
||||
return HandlerHelper.Success(await _testService.DeleteTestAsync(id));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user