초기커밋
This commit is contained in:
@@ -0,0 +1,148 @@
|
||||
using Amazon.DynamoDBv2.DocumentModel;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class DBQBeaconShopSoldReadAll : QueryExecutorBase
|
||||
{
|
||||
private string m_combination_key_for_pk = string.Empty;
|
||||
|
||||
private string m_recoed_pk = string.Empty;
|
||||
private string m_price_pk = string.Empty;
|
||||
|
||||
private List<BeaconShopSoldRecordDoc> m_to_read_beacon_shop_sold_record_docs = new();
|
||||
private List<BeaconShopSoldPriceDoc> m_to_read_beacon_shop_sold_price_docs = new();
|
||||
|
||||
public DBQBeaconShopSoldReadAll(string combinationKeyForPK)
|
||||
: base(typeof(DBQBeaconShopSoldReadAll).Name)
|
||||
{
|
||||
m_combination_key_for_pk = combinationKeyForPK;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// DB 쿼리 직전에 준비해야 할 로직들을 작성한다.
|
||||
//=====================================================================================
|
||||
public override Task<Result> onPrepareQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
var record_doc = new BeaconShopSoldRecordDoc();
|
||||
record_doc.setCombinationKeyForPK(m_combination_key_for_pk);
|
||||
|
||||
var error_code = record_doc.onApplyPKSK();
|
||||
if (error_code.isFail())
|
||||
{
|
||||
err_msg = $"Failed to onApplyPKSK() !!! : {error_code.toBasicString()} - {toBasicString()}, {owner.toBasicString()}";
|
||||
result.setFail(error_code, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
m_recoed_pk = record_doc.getPK();
|
||||
|
||||
var price_doc = new BeaconShopSoldPriceDoc();
|
||||
price_doc.setCombinationKeyForPK(m_combination_key_for_pk);
|
||||
|
||||
error_code = price_doc.onApplyPKSK();
|
||||
if (error_code.isFail())
|
||||
{
|
||||
err_msg = $"Failed to onApplyPKSK() !!! : {error_code.toBasicString()} - {toBasicString()}, {owner.toBasicString()}";
|
||||
result.setFail(error_code, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
m_price_pk = price_doc.getPK();
|
||||
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// onPrepareQuery()를 성공할 경우 호출된다.
|
||||
//=====================================================================================
|
||||
public override async Task<Result> onQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
var query_batch = getQueryBatch();
|
||||
NullReferenceCheckHelper.throwIfNull(query_batch, () => "query_batch is null !!!");
|
||||
|
||||
var db_connector = query_batch.getDynamoDbConnector();
|
||||
var query_config = db_connector.makeQueryConfigForReadByPKOnly(m_recoed_pk);
|
||||
|
||||
(result, var record_read_docs) = await db_connector.simpleQueryDocTypesWithQueryOperationConfig<BeaconShopSoldRecordDoc>(query_config, eventTid: query_batch.getTransId());
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
var beacon_shop_inventory_action = owner.getEntityAction<BeaconShopAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(beacon_shop_inventory_action, () => "beacon_shop_inventory_action is null !!!");
|
||||
|
||||
result = await beacon_shop_inventory_action.AddBeaconShopSoldRecordsFromDocs(record_read_docs);
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
var price_query_config = db_connector.makeQueryConfigForReadByPKOnly(m_price_pk);
|
||||
|
||||
(result, var price_read_docs) = await db_connector.simpleQueryDocTypesWithQueryOperationConfig<BeaconShopSoldPriceDoc>(price_query_config, eventTid: query_batch.getTransId());
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
result = await beacon_shop_inventory_action.AddBeaconShopSoldPriceFromDocs(price_read_docs);
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
result = await beacon_shop_inventory_action.ProcessBeaconShopDeleteRecord();
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
m_to_read_beacon_shop_sold_record_docs = record_read_docs;
|
||||
m_to_read_beacon_shop_sold_price_docs = price_read_docs;
|
||||
|
||||
return await Task.FromResult(result);
|
||||
}
|
||||
|
||||
public List<BeaconShopSoldRecordDoc> getToReadItemDocs() => m_to_read_beacon_shop_sold_record_docs;
|
||||
|
||||
//=====================================================================================
|
||||
// DB 쿼리를 성공하고, doFnCommit()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//=====================================================================================
|
||||
public override async Task onQueryResponseCommit()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
return;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// DB 쿼리를 실패하고, doFnRollback()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//=====================================================================================
|
||||
public override async Task onQueryResponseRollback(Result errorResult)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
return;
|
||||
}
|
||||
|
||||
public new Player? getOwner() => getQueryBatch()?.getLogActor() as Player;
|
||||
}
|
||||
Reference in New Issue
Block a user