78 lines
2.0 KiB
C#
78 lines
2.0 KiB
C#
using Newtonsoft.Json;
|
|
|
|
|
|
using ServerCore;
|
|
using ServerBase;
|
|
|
|
|
|
using META_ID = System.UInt32;
|
|
|
|
|
|
namespace ServerCommon;
|
|
|
|
public class PackageRepeatAttrib : AttribBase
|
|
{
|
|
[JsonProperty]
|
|
public string OrderGuid { get; set; } = string.Empty;
|
|
|
|
[JsonProperty]
|
|
public META_ID ProductMetaId { get; set; } = 0;
|
|
|
|
[JsonProperty]
|
|
public int LeftCount { get; set; } = 0;
|
|
|
|
[JsonProperty]
|
|
public DateTime NextGiveTime { get; set; } = new();
|
|
|
|
public PackageRepeatAttrib()
|
|
: base(typeof(PackageRepeatAttrib).Name)
|
|
{ }
|
|
}
|
|
|
|
//=============================================================================================
|
|
// PK(Partition Key) : "package_repeat#user_guid"
|
|
// SK(Sort Key) : "order_guid"
|
|
// DocType : PackageRepeatDoc
|
|
// Attrib : PackageRepeatAttrib
|
|
// ...
|
|
//=============================================================================================
|
|
public class PackageRepeatDoc : DynamoDbDocBase
|
|
{
|
|
private static string getPrefixOfPK() { return "package_repeat#"; }
|
|
|
|
public PackageRepeatDoc()
|
|
: base(typeof(PackageRepeatDoc).Name)
|
|
{
|
|
appendAttribWrapperAll();
|
|
}
|
|
|
|
public PackageRepeatDoc(string ownerGuid, string orderGuid)
|
|
: base(typeof(PackageRepeatDoc).Name)
|
|
{
|
|
setCombinationKeyForPKSK(ownerGuid, orderGuid);
|
|
|
|
appendAttribWrapperAll();
|
|
|
|
fillUpPrimaryKey(onMakePK(), onMakeSK());
|
|
|
|
setExceptionHandler(new DynamoDbQueryExceptionNotifier.ExceptionHandler(DynamoDbQueryExceptionNotifier.ConditionalCheckFailed, ServerErrorCode.PackageRepeatDocException));
|
|
}
|
|
|
|
private void appendAttribWrapperAll()
|
|
{
|
|
appendAttribWrapper(new AttribWrapper<PackageRepeatAttrib>());
|
|
}
|
|
|
|
protected override string onGetPrefixOfPK()
|
|
{
|
|
return getPrefixOfPK();
|
|
}
|
|
|
|
protected override ServerErrorCode onCheckAndSetSK(string sortKey)
|
|
{
|
|
getPrimaryKey().fillUpSK(sortKey);
|
|
setCombinationKeyForSK(sortKey);
|
|
return ServerErrorCode.Success;
|
|
}
|
|
}
|