73 lines
1.8 KiB
C#
73 lines
1.8 KiB
C#
using Newtonsoft.Json;
|
|
|
|
|
|
using ServerBase;
|
|
|
|
|
|
using META_ID = System.UInt32;
|
|
|
|
|
|
namespace ServerCommon;
|
|
|
|
public class OwnedBuildingAttrib : AttribBase
|
|
{
|
|
[JsonProperty("building_meta_id")]
|
|
public META_ID BuildingMetaId { get; set; } = 0;
|
|
|
|
[JsonProperty("owned_type")]
|
|
public OwnedType OwnedType { get; set; } = OwnedType.None;
|
|
|
|
public OwnedBuildingAttrib()
|
|
: base(typeof(OwnedBuildingAttrib).Name)
|
|
{ }
|
|
}
|
|
|
|
//=============================================================================================
|
|
// PK(Partition Key) : "owned_building#user_guid"
|
|
// SK(Sort Key) : "building_meta_id"
|
|
// DocType : OwnedBuildingDoc
|
|
// OwnedBuildingAttrib : {}
|
|
// ...
|
|
//=============================================================================================
|
|
|
|
public class OwnedBuildingDoc : DynamoDbDocBase
|
|
{
|
|
private static string getPrefixOfPK() { return "owned_building#"; }
|
|
private static string getPrefixOfSK() { return ""; }
|
|
|
|
public OwnedBuildingDoc()
|
|
: base(typeof(OwnedBuildingDoc).Name)
|
|
{
|
|
appendAttribWrapperAll();
|
|
}
|
|
|
|
public OwnedBuildingDoc(string userGuid, META_ID buildingMetaId)
|
|
: base(typeof(OwnedBuildingDoc).Name)
|
|
{
|
|
setCombinationKeyForPK(userGuid);
|
|
setCombinationKeyForSK(buildingMetaId.ToString());
|
|
|
|
appendAttribWrapperAll();
|
|
|
|
fillUpPrimaryKey(onMakePK(), onMakeSK());
|
|
}
|
|
|
|
private void appendAttribWrapperAll()
|
|
{
|
|
appendAttribWrapper(new AttribWrapper<OwnedBuildingAttrib>());
|
|
}
|
|
|
|
protected override string onGetPrefixOfPK()
|
|
{
|
|
return getPrefixOfPK();
|
|
}
|
|
|
|
protected override ServerErrorCode onCheckAndSetSK(string sortKey)
|
|
{
|
|
getPrimaryKey().fillUpSK(sortKey);
|
|
setCombinationKeyForSK(sortKey);
|
|
|
|
return ServerErrorCode.Success;
|
|
}
|
|
}
|