116 lines
3.1 KiB
C#
116 lines
3.1 KiB
C#
|
|
|
|
using Amazon.DynamoDBv2.Model;
|
|
using Google.Protobuf.WellKnownTypes;
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
using ServerCore; using ServerBase;
|
|
|
|
|
|
using OWNER_GUID = System.String;
|
|
|
|
|
|
namespace ServerCommon;
|
|
|
|
public class QuestMailAttrib : AttribBase
|
|
{
|
|
[JsonProperty("is_read")]
|
|
public Int32 IsRead { get; set; } = 0;
|
|
|
|
[JsonProperty("quest_id")]
|
|
public UInt32 QuestId { get; set; } = 0;
|
|
[JsonProperty("quest_revision")]
|
|
public UInt32 QuestRevision { get; set; } = 0;
|
|
|
|
[JsonProperty("ugq_state")]
|
|
public UgqStateType UgqState { get; set; } = UgqStateType.None;
|
|
[JsonProperty("create_time")] public DateTime CreateTime { get; set; } = DateTimeHelper.Current;
|
|
|
|
[JsonProperty("expire_time")] public DateTime? ExpireTime { get; set; }
|
|
|
|
public void cloneAttrib(ref QuestMailAttrib attrib)
|
|
{
|
|
attrib.IsRead = IsRead;
|
|
attrib.QuestId = QuestId;
|
|
attrib.CreateTime = CreateTime;
|
|
attrib.ExpireTime = ExpireTime;
|
|
attrib.UgqState = UgqState;
|
|
}
|
|
|
|
public QuestMailAttrib()
|
|
: base(typeof(QuestMailAttrib).Name)
|
|
{ }
|
|
}
|
|
|
|
//=============================================================================================
|
|
// PK(Partition Key) : "quest_mail#owner_guid"
|
|
// SK(Sort Key) : "quest_meta_id"
|
|
// DocType : QuestMailDoc
|
|
// Attrib : QuestMailAttrib
|
|
// ...
|
|
//=============================================================================================
|
|
public class QuestMailDoc : DynamoDbDocBase
|
|
{
|
|
|
|
public QuestMailDoc(string userGuid, UInt32 questId, UInt32 questRevision)
|
|
: base(typeof(QuestMailDoc).Name)
|
|
{
|
|
setCombinationKeyForPK(userGuid);
|
|
setCombinationKeyForSK(makeQuestMailSKString(questId, questRevision));
|
|
appendAttribWrapperAll();
|
|
}
|
|
|
|
public QuestMailDoc(string userGuid, UInt32 questId, UInt32 questRevision, Int64 quest_mail_ttl_seconds)
|
|
: base(typeof(QuestMailDoc).Name, quest_mail_ttl_seconds)
|
|
{
|
|
setCombinationKeyForPK(userGuid);
|
|
setCombinationKeyForSK(makeQuestMailSKString(questId, questRevision));
|
|
appendAttribWrapperAll();
|
|
}
|
|
|
|
public QuestMailDoc()
|
|
: base(typeof(QuestMailDoc).Name)
|
|
{
|
|
appendAttribWrapperAll();
|
|
}
|
|
|
|
private void appendAttribWrapperAll()
|
|
{
|
|
appendAttribWrapper(new AttribWrapper<QuestMailAttrib>());
|
|
}
|
|
|
|
protected override string onGetPrefixOfPK()
|
|
{
|
|
return "quest_mail#";
|
|
}
|
|
|
|
protected override string onMakePK()
|
|
{
|
|
return $"{onGetPrefixOfPK()}{getCombinationKeyForPK()}";
|
|
}
|
|
|
|
protected override string onMakeSK()
|
|
{
|
|
return $"{onGetPrefixOfSK()}{getCombinationKeyForSK()}";
|
|
|
|
}
|
|
|
|
protected override ServerErrorCode onCheckAndSetPK(string pk)
|
|
{
|
|
getPrimaryKey().fillUpPK(pk);
|
|
return ServerErrorCode.Success;
|
|
}
|
|
|
|
protected override ServerErrorCode onCheckAndSetSK(string sortKey)
|
|
{
|
|
getPrimaryKey().fillUpSK(sortKey);
|
|
return ServerErrorCode.Success;
|
|
}
|
|
|
|
public static string makeQuestMailSKString(UInt32 questId, UInt32 questRevision)
|
|
{
|
|
return $"{questId}#{questRevision}";
|
|
}
|
|
}
|