초기커밋
This commit is contained in:
77
ServerCommon/Doc/Global/CaliumContentDoc.cs
Normal file
77
ServerCommon/Doc/Global/CaliumContentDoc.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user