초기커밋
This commit is contained in:
92
ServerCommon/Doc/UserBase/ShopProductTradingMeterDoc.cs
Normal file
92
ServerCommon/Doc/UserBase/ShopProductTradingMeterDoc.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Newtonsoft.Json;
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
using USER_GUID = System.String;
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class ShopProductTradingMeterSubAttrib
|
||||
{
|
||||
[JsonProperty("product_id")]
|
||||
public int ProductId { get; set; }
|
||||
|
||||
[JsonProperty("left_count")]
|
||||
public double LeftCount { get; set; }
|
||||
}
|
||||
|
||||
public class ShopProductTradingMeterAttrib : AttribBase
|
||||
{
|
||||
[JsonProperty("shop_id")]
|
||||
public int ShopId { get; set; }
|
||||
|
||||
[JsonProperty("shop_product_trading_meter_subs")]
|
||||
public List<ShopProductTradingMeterSubAttrib> ShopProductTradingMeterSubs { get; set; }= new();
|
||||
|
||||
[JsonProperty("end_time")]
|
||||
public Timestamp EndTime { get; set; } = DateTimeHelper.MinTime.ToTimestamp();
|
||||
|
||||
[JsonProperty("current_renewal_count")]
|
||||
public Int32 CurrentRenewalCount { get; set; } = 0;
|
||||
|
||||
public void onClear()
|
||||
{
|
||||
ShopId = 0;
|
||||
EndTime = DateTimeHelper.MinTime.ToTimestamp();
|
||||
CurrentRenewalCount = 0;
|
||||
ShopProductTradingMeterSubs.Clear();
|
||||
}
|
||||
|
||||
public ShopProductTradingMeterAttrib()
|
||||
: base(typeof(ShopProductTradingMeterAttrib).Name)
|
||||
{ }
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// PK(Partition Key) : "shop_product_trading_meter#user_guid"
|
||||
// SK(Sort Key) : "shop_id"
|
||||
// DocType : ShopProductTradingMeterDoc
|
||||
// ShopProductTradingMeterAttrib : {}
|
||||
// ...
|
||||
//=============================================================================================
|
||||
public class ShopProductTradingMeterDoc : DynamoDbDocBase
|
||||
{
|
||||
public ShopProductTradingMeterDoc() : base(nameof(ShopProductTradingMeterDoc))
|
||||
{
|
||||
appendAttribWrapperAll();
|
||||
}
|
||||
|
||||
public ShopProductTradingMeterDoc(USER_GUID userGuid, int shop_id) : base(nameof(ShopProductTradingMeterDoc))
|
||||
{
|
||||
onCustomCreate(userGuid, shop_id);
|
||||
}
|
||||
|
||||
private void onCustomCreate(USER_GUID userGuid, int shop_id)
|
||||
{
|
||||
setCombinationKeyForPK(userGuid);
|
||||
setCombinationKeyForSK(shop_id.ToString());
|
||||
|
||||
appendAttribWrapperAll();
|
||||
|
||||
fillUpPrimaryKey(onMakePK(), onMakeSK());
|
||||
}
|
||||
|
||||
private void appendAttribWrapperAll()
|
||||
{
|
||||
appendAttribWrapper(new AttribWrapper<ShopProductTradingMeterAttrib>());
|
||||
}
|
||||
|
||||
protected override string onGetPrefixOfPK()
|
||||
{
|
||||
return "shop_product_trading_meter#";
|
||||
}
|
||||
|
||||
protected override ServerErrorCode onCheckAndSetSK(string sortKey)
|
||||
{
|
||||
getPrimaryKey().fillUpSK(sortKey);
|
||||
setCombinationKeyForSK(sortKey);
|
||||
|
||||
return ServerErrorCode.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user