Files
caliverse_server/ServerCommon/Doc/OwnerContents/CraftDoc.cs
2025-05-01 07:20:41 +09:00

87 lines
2.2 KiB
C#

using Newtonsoft.Json;
using ServerCore;
using ServerBase;
using META_ID = System.UInt32;
using ANCHOR_GUID = System.String;
using BEACON_GUID = System.String;
namespace ServerCommon;
public class CraftAttrib : AttribBase
{
[JsonProperty("anchor_guid")]
public ANCHOR_GUID AnchorGuid { get; set; } = string.Empty;
[JsonProperty("craft_meta_id")]
public META_ID CraftMetaId { get; set; } = 0;
[JsonProperty("craft_start_time")]
public DateTime CraftStartTime { get; set; } = new();
[JsonProperty("craft_finish_time")]
public DateTime CraftFinishTime { get; set; } = new();
[JsonProperty("beacon_guid")]
public BEACON_GUID BeaconGuid { get; set; } = string.Empty;
[JsonProperty("craft_count")]
public int CraftCount { get; set; } = 1;
public CraftAttrib()
: base(typeof(CraftAttrib).Name)
{ }
}
//=============================================================================================
// PK(Partition Key) : "craft#user_guid"
// SK(Sort Key) : "anchor_guid"
// DocType : CraftDoc
// Attrib : CraftAttrib
// ...
//=============================================================================================
public class CraftDoc : DynamoDbDocBase
{
private static string getPrefixOfPK() { return "craft#"; }
public CraftDoc()
: base(typeof(CraftDoc).Name)
{
appendAttribWrapperAll();
}
public CraftDoc(string ownerGuid, ANCHOR_GUID anchorGuid)
: base(typeof(CraftDoc).Name)
{
setCombinationKeyForPKSK(ownerGuid, anchorGuid);
appendAttribWrapperAll();
fillUpPrimaryKey(onMakePK(), onMakeSK());
setExceptionHandler(new DynamoDbQueryExceptionNotifier.ExceptionHandler(DynamoDbQueryExceptionNotifier.ConditionalCheckFailed, ServerErrorCode.CraftDocException));
}
private void appendAttribWrapperAll()
{
appendAttribWrapper(new AttribWrapper<CraftAttrib>());
}
protected override string onGetPrefixOfPK()
{
return getPrefixOfPK();
}
protected override ServerErrorCode onCheckAndSetSK(string sortKey)
{
getPrimaryKey().fillUpSK(sortKey);
setCombinationKeyForSK(sortKey);
return ServerErrorCode.Success;
}
}