134 lines
5.1 KiB
C#
134 lines
5.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using Amazon.DynamoDBv2;
|
|
using Amazon.DynamoDBv2.DocumentModel;
|
|
using ServerCore; using ServerBase;
|
|
|
|
|
|
namespace ServerBase;
|
|
|
|
//=============================================================================================
|
|
// DB 쿼리 ItemRequest 타입 구현 하기위한 추상 + 제네릭 클래스 이다.
|
|
//=============================================================================================
|
|
public abstract partial class QueryDbRequesterWithItemRequestBase<TDbRequestType> : IQueryDbRequester
|
|
where TDbRequestType : AmazonDynamoDBRequest, new()
|
|
{
|
|
private QueryBatchBase? m_query_batch;
|
|
private readonly TDbRequestType m_db_request;
|
|
|
|
private DynamoDbQueryExceptionNotifier m_exception_notifier = new();
|
|
|
|
public QueryDbRequesterWithItemRequestBase()
|
|
{
|
|
m_db_request = new TDbRequestType();
|
|
}
|
|
|
|
public abstract Task<Result> doDbRequestAsync();
|
|
|
|
public DynamoDbQueryExceptionNotifier getDynamoDbQueryExceptionNotifier() => m_exception_notifier;
|
|
}
|
|
|
|
|
|
//=============================================================================================
|
|
// DB 쿼리 DocumentBatchWrite 타입 구현 하기위한 추상 + 제네릭 클래스 이다.
|
|
//=============================================================================================
|
|
public abstract partial class QueryDbRequesterWithDocumentBatchWriteBase<TDbRequestType> : IQueryDbRequester, IWithDocumentModel
|
|
where TDbRequestType : DocumentBatchWrite
|
|
{
|
|
private QueryBatchBase? m_query_batch;
|
|
private TDbRequestType? m_db_request;
|
|
private Table? m_table;
|
|
|
|
private DynamoDbQueryExceptionNotifier m_exception_notifier = new();
|
|
|
|
public void onCreateDocumentModel(Table table)
|
|
{
|
|
m_table = table;
|
|
|
|
var db_request_type = table.CreateBatchWrite() as TDbRequestType;
|
|
NullReferenceCheckHelper.throwIfNull(db_request_type, () => $"db_request_type is null !!!");
|
|
|
|
m_db_request = db_request_type;
|
|
}
|
|
|
|
public abstract Task<Result> doDbRequestAsync();
|
|
|
|
public DynamoDbQueryExceptionNotifier getDynamoDbQueryExceptionNotifier() => m_exception_notifier;
|
|
}
|
|
|
|
|
|
//=============================================================================================
|
|
// DB 쿼리 DocumentBatchGet 타입 구현 하기위한 추상 + 제네릭 클래스 이다.
|
|
//=============================================================================================
|
|
public abstract partial class QueryDbRequesterWithDocumentBatchGetBase<TDbRequestType> : IQueryDbRequester, IWithDocumentModel
|
|
where TDbRequestType : DocumentBatchGet
|
|
{
|
|
private QueryBatchBase? m_query_batch;
|
|
private TDbRequestType? m_db_request;
|
|
private Table? m_table;
|
|
|
|
private DynamoDbQueryExceptionNotifier m_exception_notifier = new();
|
|
|
|
public void onCreateDocumentModel(Table table)
|
|
{
|
|
m_table = table;
|
|
m_db_request = table.CreateBatchGet() as TDbRequestType;
|
|
}
|
|
|
|
public abstract Task<Result> doDbRequestAsync();
|
|
|
|
public DynamoDbQueryExceptionNotifier getDynamoDbQueryExceptionNotifier() => m_exception_notifier;
|
|
}
|
|
|
|
|
|
//=============================================================================================
|
|
// DB 쿼리 DocumentTransactWrite 타입 구현 하기위한 추상 + 제네릭 클래스 이다.
|
|
//=============================================================================================
|
|
public abstract partial class QueryDbRequesterWithDocumentTransactWriteBase<TDbRequestType> : IQueryDbRequester, IWithDocumentModel
|
|
where TDbRequestType : DocumentTransactWrite
|
|
{
|
|
private QueryBatchBase? m_query_batch = null;
|
|
private TDbRequestType? m_db_request;
|
|
private Table? m_table;
|
|
|
|
private DynamoDbQueryExceptionNotifier m_exception_notifier = new();
|
|
|
|
public void onCreateDocumentModel(Table table)
|
|
{
|
|
m_table = table;
|
|
m_db_request = table.CreateTransactWrite() as TDbRequestType;
|
|
}
|
|
|
|
public abstract Task<Result> doDbRequestAsync();
|
|
|
|
public DynamoDbQueryExceptionNotifier getDynamoDbQueryExceptionNotifier() => m_exception_notifier;
|
|
}
|
|
|
|
//=============================================================================================
|
|
// DB 쿼리 DocumentTransactGet 타입 구현 하기위한 추상 + 제네릭 클래스 이다.
|
|
//=============================================================================================
|
|
public abstract partial class QueryDbRequesterWithDocumentTransactGetBase<TDbRequestType> : IQueryDbRequester, IWithDocumentModel
|
|
where TDbRequestType : DocumentTransactGet
|
|
{
|
|
private QueryBatchBase? m_query_batch = null;
|
|
private TDbRequestType? m_db_request;
|
|
private Table? m_table;
|
|
|
|
private DynamoDbQueryExceptionNotifier m_exception_notifier = new();
|
|
|
|
public void onCreateDocumentModel(Table table)
|
|
{
|
|
m_table = table;
|
|
m_db_request = table.CreateTransactGet() as TDbRequestType;
|
|
}
|
|
|
|
public abstract Task<Result> doDbRequestAsync();
|
|
|
|
public DynamoDbQueryExceptionNotifier getDynamoDbQueryExceptionNotifier() => m_exception_notifier;
|
|
}
|