81 lines
2.3 KiB
C#
81 lines
2.3 KiB
C#
using Newtonsoft.Json;
|
|
|
|
|
|
using ServerBase;
|
|
|
|
|
|
namespace ServerCommon;
|
|
|
|
public class UgcNpcRankAttrib : AttribBase
|
|
{
|
|
/// <summary>
|
|
/// rank 정보
|
|
/// key: {ownerGuid}_{ugcnpcMetaGuid}
|
|
/// value: score
|
|
/// </summary>
|
|
/// <remarks> UgcNpcRankHelper.makeRankKey() </remarks>
|
|
[JsonProperty("data")] public Dictionary<string, long> ranks { get; set; } = new();
|
|
|
|
public UgcNpcRankAttrib() : base(nameof(UgcNpcRankAttrib), false)
|
|
{
|
|
}
|
|
}
|
|
|
|
//=============================================================================================
|
|
// Primary Key
|
|
// PK(Partition Key) : ugcnpcrank#{state}
|
|
// SK(Sort Key) : ""
|
|
// DocType : UgcNpcRankDoc
|
|
// Attrib : UgcNpcRankAttrib
|
|
// ...
|
|
//=============================================================================================
|
|
public class UgcNpcRankDoc : DynamoDbDocBase
|
|
{
|
|
public static string getPrefixOfPK() => "ugcnpcrank#";
|
|
|
|
public UgcNpcRankDoc() : base(nameof(UgcNpcRankDoc))
|
|
{
|
|
appendAttribWrapperAll();
|
|
}
|
|
|
|
public UgcNpcRankDoc(UgcNpcRankState state, UgcNpcRankType type, string? rankDate) : base(nameof(UgcNpcRankDoc))
|
|
{
|
|
setCombinationKeyForPK(state.ToString());
|
|
|
|
var sk = null == rankDate ? type.ToString() : $"{type}#{rankDate}";
|
|
setCombinationKeyForSK(sk);
|
|
fillUpPrimaryKey(onMakePK(), onMakeSK());
|
|
|
|
appendAttribWrapperAll();
|
|
}
|
|
|
|
public UgcNpcRankDoc(UgcNpcRankState state, UgcNpcRankType type, string? rankDate, Int64 ttlSeconds) : base(nameof(UgcNpcRankDoc), ttlSeconds)
|
|
{
|
|
setCombinationKeyForPK(state.ToString());
|
|
|
|
var sk = null == rankDate ? type.ToString() : $"{type}#{rankDate}";
|
|
setCombinationKeyForSK(sk);
|
|
fillUpPrimaryKey(onMakePK(), onMakeSK());
|
|
|
|
appendAttribWrapperAll();
|
|
}
|
|
|
|
private void appendAttribWrapperAll()
|
|
{
|
|
appendAttribWrapper(new AttribWrapper<UgcNpcRankAttrib>());
|
|
}
|
|
|
|
protected override string onGetPrefixOfPK() => getPrefixOfPK();
|
|
|
|
protected override string onMakeSK()
|
|
{
|
|
return $"{onGetPrefixOfSK()}{getCombinationKeyForSK()}";
|
|
}
|
|
|
|
protected override ServerErrorCode onCheckAndSetSK(string sortKey)
|
|
{
|
|
getPrimaryKey().fillUpSK(sortKey);
|
|
setCombinationKeyForSK(sortKey);
|
|
return ServerErrorCode.Success;
|
|
}
|
|
} |