Files
caliverse_server/ServerCommon/Doc/OwnerContents/CartDoc.cs
2025-05-01 07:20:41 +09:00

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();
}
}