Files
2025-05-01 07:20:41 +09:00

112 lines
2.9 KiB
C#

using System;
using Newtonsoft.Json;
using ServerCore;
using ServerBase;
namespace ServerCommon;
public class ClaimAttrib : AttribBase
{
[JsonProperty("claim_type")]
public MetaAssets.ClaimType ClaimType { get; set; } = MetaAssets.ClaimType.None;
[JsonProperty("claim_id")]
public int ClaimId { get; set; } = 0;
[JsonProperty("active_reward_idx")]
public int ActiveRewardIdx { get; set; } = 0;
[JsonProperty("active_time")]
public DateTime ActiveTime { get; set; } = new();
[JsonProperty("create_time")]
public DateTime CreateTime { get; set; } = new();
[JsonProperty("complete_time")]
public DateTime CompleteTime { get; set; } = new();
[JsonProperty("is_complete")]
public int IsComplete { get; set; } = 0;
public ClaimAttrib()
: base(typeof(ClaimAttrib).Name)
{ }
}
//=============================================================================================
// PK(Partition Key) : "claim#owner_guid"
// SK(Sort Key) : "normal#claim_meta_id"
// DocType : ClaimDoc
// ClaimAttrib : {}
// ...
//=============================================================================================
public class ClaimDoc : DynamoDbDocBase
{
public ClaimDoc()
: base(typeof(ClaimDoc).Name)
{
appendAttribWrapper(new AttribWrapper<ClaimAttrib>());
}
public ClaimDoc(string userGuid)
: base(typeof(ClaimDoc).Name)
{
appendAttribWrapper(new AttribWrapper<ClaimAttrib>());
setCombinationKeyForPK(userGuid);
}
public ClaimDoc(string userGuid, MetaAssets.ClaimType type, Int32 claimId)
: base(typeof(ClaimDoc).Name)
{
appendAttribWrapper(new AttribWrapper<ClaimAttrib>());
var attrib = getAttrib<ClaimAttrib>();
NullReferenceCheckHelper.throwIfNull(attrib, () => $"attrib is null !!!");
attrib.ClaimType = type;
setCombinationKeyForPK(userGuid);
setCombinationKeyForSK(claimId.ToString());
fillUpPrimaryKey(onMakePK(), onMakeSK());
}
protected override string onGetPrefixOfPK()
{
return "claim#";
}
protected override string onGetPrefixOfSK()
{
var attrib = getAttrib<ClaimAttrib>();
NullReferenceCheckHelper.throwIfNull(attrib, () => $"attrib is null !!!");
return $"{attrib.ClaimType.ToString().ToLower()}#";
}
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;
}
}