62 lines
1.5 KiB
C#
62 lines
1.5 KiB
C#
using Newtonsoft.Json;
|
|
|
|
|
|
using ServerCore;
|
|
using ServerBase;
|
|
|
|
|
|
using META_ID = System.UInt32;
|
|
|
|
|
|
namespace ServerCommon;
|
|
|
|
public class CartAttrib : AttribBase
|
|
{
|
|
[JsonProperty("cart_items")]
|
|
public Dictionary<CurrencyType, Dictionary<META_ID/*ItemMetaID*/, Int32/*Count*/>> CartItems { get; set; } = new();
|
|
|
|
public CartAttrib()
|
|
: base(typeof(CartAttrib).Name)
|
|
{ }
|
|
}
|
|
|
|
//=============================================================================================
|
|
// PK(Partition Key) : "cart#user_guid"
|
|
// SK(Sort Key) : ""
|
|
// DocType : CartDoc
|
|
// CartAttrib : {}
|
|
// ...
|
|
//=============================================================================================
|
|
public class CartDoc : DynamoDbDocBase
|
|
{
|
|
private static string getPrefixOfPK() { return "cart#"; }
|
|
|
|
public CartDoc()
|
|
: base(typeof(CartDoc).Name)
|
|
{
|
|
appendAttribWrapperAll();
|
|
}
|
|
|
|
public CartDoc(string ownerGuid)
|
|
: base(typeof(CartDoc).Name)
|
|
{
|
|
setCombinationKeyForPK(ownerGuid);
|
|
|
|
appendAttribWrapperAll();
|
|
|
|
fillUpPrimaryKey(onMakePK(), onMakeSK());
|
|
|
|
setExceptionHandler(new DynamoDbQueryExceptionNotifier.ExceptionHandler(DynamoDbQueryExceptionNotifier.ConditionalCheckFailed, ServerErrorCode.CartDocException));
|
|
}
|
|
|
|
private void appendAttribWrapperAll()
|
|
{
|
|
appendAttribWrapper(new AttribWrapper<CartAttrib>());
|
|
}
|
|
|
|
protected override string onGetPrefixOfPK()
|
|
{
|
|
return getPrefixOfPK();
|
|
}
|
|
}
|