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

77 lines
2.1 KiB
C#

using Newtonsoft.Json;
using ServerCore;
using ServerBase;
namespace ServerCommon;
public class CaliumContentAttrib : AttribBase
{
[JsonProperty("calium_content_id")]
public string ContentId { get; set; } = string.Empty;
[JsonProperty("calium")]
public double TotalCalium { get; set; } = 0.0;
public CaliumContentAttrib() : base(nameof(CaliumContentAttrib), false) {}
}
//=============================================================================================
// PK(Partition Key) : "calium#content"
// SK(Sort Key) : "contentId"
// DocType : CaliumEventDoc
// CaliumContentAttrib : {}
// ...
//=============================================================================================
public class CaliumContentDoc : DynamoDbDocBase
{
public static string pk = "calium#content";
private readonly string m_content_id;
private string getPrefixOfPK() => pk;
private string getPrefixOfSK() => m_content_id;
public CaliumContentDoc(string contentId) : base(nameof(CaliumContentDoc))
{
m_content_id = contentId;
setCombinationKeyForSK(contentId);
fillUpPrimaryKey(onMakePK(), onMakeSK());
appendAttribWrapperAll();
var doc_attrib = getAttrib<CaliumContentAttrib>();
NullReferenceCheckHelper.throwIfNull(doc_attrib, () => $"doc_attrib is null !!! - contentId:{contentId}");
doc_attrib.ContentId = contentId;
}
private void appendAttribWrapperAll()
{
appendAttribWrapper(new AttribWrapper<CaliumContentAttrib>());
}
protected override string onGetPrefixOfPK()
{
return getPrefixOfPK();
}
protected override string onGetPrefixOfSK()
{
return getPrefixOfSK();
}
protected override ServerErrorCode onCheckAndSetPK(string sortKey)
{
getPrimaryKey().fillUpPK(sortKey);
return ServerErrorCode.Success;
}
protected override ServerErrorCode onCheckAndSetSK(string sortKey)
{
getPrimaryKey().fillUpSK(sortKey);
setCombinationKeyForSK(sortKey);
return ServerErrorCode.Success;
}
}