using Google.Protobuf; using Google.Protobuf.WellKnownTypes; using ServerCore; using ServerBase; using ServerCommon; using ServerCommon.BusinessLogDomain; using MetaAssets; namespace GameServer; public class ReqCreateCaliumContentStorageHandler { public async Task createCaliumContentStorage(string contentId, double calium) { var server_logic = GameServerApp.getServerLogic(); var calium_storage_entity = server_logic.findGlobalEntity(); NullReferenceCheckHelper.throwIfNull(calium_storage_entity, () => "calium_storage_entity is null !!!"); // 1. contentId 검사 // Todo(sangyeob.kim) : calium content Id 를 위한 xlxs 등록되면 추가한다. // 2. calium content storage 생성 var result = await calium_storage_entity.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "CreateCaliumContentStorage", createCaliumContentStorageDelegate); if (result.isFail()) { var err_msg = $"Failed to runTransactionRunnerSafely() !!! : {result.toBasicString()} - {calium_storage_entity.toBasicString()}"; Log.getLogger().error(err_msg); } return result; async Task createCaliumContentStorageDelegate() => await createCaliumContentStorage(calium_storage_entity, contentId, calium); } private async Task createCaliumContentStorage(CaliumStorageEntity caliumStorageEntity, string contentId, double calium) { var dynamoDb_client = GameServerApp.getServerLogic().getDynamoDbClient(); NullReferenceCheckHelper.throwIfNull(dynamoDb_client, () => $"dynamoDb_client is null !!! - {caliumStorageEntity.toBasicString()}"); var batch = new QueryBatchEx(caliumStorageEntity, LogActionType.CreateCaliumContent, dynamoDb_client, true); batch.addQuery(new DBQStorageCaliumUpdate(CaliumStorageType.Operator, -1 * calium)); batch.addQuery(new DBQContentCaliumCreate(contentId, calium)); var result = await QueryHelper.sendQueryAndBusinessLog(batch); return result; } }