110 lines
3.1 KiB
C#
110 lines
3.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
using ServerCore;
|
|
using ServerBase;
|
|
|
|
|
|
using SESSION_ID = System.Int32;
|
|
using META_ID = System.UInt32;
|
|
using ENTITY_GUID = System.String;
|
|
using ACCOUNT_ID = System.String;
|
|
using OWNER_GUID = System.String;
|
|
using USER_GUID = System.String;
|
|
using CHARACTER_GUID = System.String;
|
|
using ITEM_GUID = System.String;
|
|
|
|
|
|
|
|
namespace ServerCommon;
|
|
|
|
public class CustomDefinedDataAttrib : AttribBase
|
|
{
|
|
[JsonProperty("owner_guid")]
|
|
public string OwnerGuid { get; set; } = string.Empty;
|
|
|
|
[JsonProperty("owner_entity_type")]
|
|
public OwnerEntityType OwnerEntityType { get; set; } = OwnerEntityType.None;
|
|
|
|
[JsonProperty("data_key")]
|
|
public string DataKey { get; set; } = string.Empty;
|
|
|
|
[JsonProperty("custom_defined_data")]
|
|
public string CustomDefinedData { get; set; } = string.Empty;
|
|
|
|
public CustomDefinedDataAttrib()
|
|
: base(typeof(CustomDefinedDataAttrib).Name)
|
|
{ }
|
|
}
|
|
|
|
//=============================================================================================
|
|
// Primary Key
|
|
// PK(Partition Key) : "custom_defined_data#owner_guid" [owner_guid : user_guid]
|
|
// SK(Sort Key) : "data_key#custom_data_key"
|
|
// DocType : CustomDefinedDataDoc
|
|
// CustomDefinedDataAttrib : {}
|
|
// ...
|
|
//=============================================================================================
|
|
public class CustomDefinedDataDoc : DynamoDbDocBase
|
|
{
|
|
private static string getPrefixOfPK() { return "custom_defined_data#"; }
|
|
private static string getPrefixOfSK() { return "data_key#"; }
|
|
|
|
public CustomDefinedDataDoc()
|
|
: base(typeof(CustomDefinedDataDoc).Name)
|
|
{
|
|
appendAttribWrapperAll();
|
|
}
|
|
|
|
public CustomDefinedDataDoc(OwnerEntityType ownerEntityType, string ownerGuid, string customDataKey)
|
|
: base(typeof(CustomDefinedDataDoc).Name)
|
|
{
|
|
setCombinationKeyForPK(ownerGuid);
|
|
setCombinationKeyForSK(customDataKey);
|
|
|
|
appendAttribWrapperAll();
|
|
|
|
fillUpPrimaryKey(onMakePK(), onMakeSK());
|
|
|
|
var doc_custom_defined_data_attrib = getAttrib<CustomDefinedDataAttrib>();
|
|
NullReferenceCheckHelper.throwIfNull(doc_custom_defined_data_attrib, () => $"doc_custom_defined_data_attrib is null !!!");
|
|
|
|
doc_custom_defined_data_attrib.OwnerGuid = ownerGuid;
|
|
doc_custom_defined_data_attrib.OwnerEntityType = ownerEntityType;
|
|
doc_custom_defined_data_attrib.DataKey = customDataKey;
|
|
}
|
|
|
|
private void appendAttribWrapperAll()
|
|
{
|
|
appendAttribWrapper(new AttribWrapper<CustomDefinedDataAttrib>());
|
|
}
|
|
|
|
protected override string onGetPrefixOfPK()
|
|
{
|
|
return getPrefixOfPK();
|
|
}
|
|
|
|
protected override string onGetPrefixOfSK()
|
|
{
|
|
return getPrefixOfSK();
|
|
}
|
|
|
|
protected override string onMakeSK()
|
|
{
|
|
return $"{onGetPrefixOfSK()}{getCombinationKeyForSK()}";
|
|
}
|
|
|
|
protected override ServerErrorCode onCheckAndSetSK(string sortKey)
|
|
{
|
|
getPrimaryKey().fillUpSK(sortKey);
|
|
return ServerErrorCode.Success;
|
|
}
|
|
}
|