Files
2025-05-01 07:20:41 +09:00

67 lines
1.8 KiB
C#

using Newtonsoft.Json;
using ServerCore;
using ServerBase;
namespace ServerCommon;
public class RoomAttrib : AttribBase
{
[JsonProperty("room_id")] public int RoomId { get; set; }
[JsonProperty("owner")] public string Owner { get; set; } = string.Empty;
[JsonProperty("name")] public string Name { get; set; } = string.Empty;
[JsonProperty("description")] public string Description { get; set; } = string.Empty;
[JsonProperty("prop_info")] public Dictionary<string, AnchorProp> PropInfo = new();
public RoomAttrib()
: base(typeof(RoomAttrib).Name)
{ }
}
//=============================================================================================
// PK(Partition Key) : "room#owner_guid"
// SK(Sort Key) : "room_id"
// DocType : IndividualRoomDoc
// RoomAttrib : {}
// ...
//=============================================================================================
public class RoomDoc : DynamoDbDocBase
{
public RoomDoc() : base(nameof(RoomDoc))
{
}
public RoomDoc(string owner_guid, int room_id) : base(nameof(RoomDoc))
{
onInit(owner_guid, room_id);
}
public void onInit(string owner_guid, int room_id)
{
setCombinationKeyForPK(owner_guid);
setCombinationKeyForSK(room_id.ToString());
appendAttribWrapperAll();
fillUpPrimaryKey(onMakePK(), onMakeSK());
}
private void appendAttribWrapperAll()
{
appendAttribWrapper(new AttribWrapper<RoomAttrib>());
}
protected override string onGetPrefixOfPK()
{
return "room#";
}
protected override ServerErrorCode onCheckAndSetSK(string sortKey)
{
getPrimaryKey().fillUpSK(sortKey);
setCombinationKeyForSK(sortKey);
return ServerErrorCode.Success;
}
}