using Newtonsoft.Json; using BEACON_GUID = System.String; using META_ID = System.UInt32; using USER_GUID = System.String; using ITEM_GUID = System.String; using ServerCore; using ServerBase; using Google.Protobuf.WellKnownTypes; namespace ServerCommon { public class BeaconShopItemAttrib : ItemAttrib { [JsonProperty("user_guid")] public USER_GUID UserGuid { get; set; } = string.Empty; [JsonProperty("beacon_guid")] public BEACON_GUID BeaconGuid { get; set; } = string.Empty; [JsonProperty("selling_finish_time")] public DateTime SellingFinishTime { get; set; } = new(); [JsonProperty("price_for_unit")] public double PriceForUnit { get; set; } = 0; public BeaconShopItemAttrib() : base(typeof(BeaconShopItemAttrib).Name, false) { } } //============================================================================================= // PK(Partition Key) : "beacon_shop_item#beacon_guid" // SK(Sort Key) : "item_guid" // DocType : BeaconShopItemDoc // Attrib : BeaconShopItemAttrib // ... //============================================================================================= public class BeaconShopItemDoc : ItemDoc { private static string getPrefixOfPK() { return "beacon_shop_item#"; } private static string getPrefixOfSK() { return ""; } public BeaconShopItemDoc() : base(typeof(BeaconShopItemDoc).Name) { appendAttribWrapperAll(); } public BeaconShopItemDoc(OwnerEntityType ownerEntityType, string beaconGuid, string userGuid, ITEM_GUID itemGuid) : base(typeof(BeaconShopItemDoc).Name) { setCombinationKeyForPKSK(beaconGuid, itemGuid); appendAttribWrapperAll(); fillUpPrimaryKey(onMakePK(), onMakeSK()); setExceptionHandler(new DynamoDbQueryExceptionNotifier.ExceptionHandler(DynamoDbQueryExceptionNotifier.ConditionalCheckFailed, ServerErrorCode.BeaconShopException)); var doc_beacon_shop_item_attrib = getAttrib(); NullReferenceCheckHelper.throwIfNull(doc_beacon_shop_item_attrib, () => $"doc_beacon_shop_item_attrib is null !!! - beaconGuid:{beaconGuid}, itemGuid:{itemGuid}, userGuid:{userGuid}, ownerEntityType:{ownerEntityType}"); doc_beacon_shop_item_attrib.BeaconGuid = beaconGuid; doc_beacon_shop_item_attrib.UserGuid = userGuid; doc_beacon_shop_item_attrib.OwnerGuid = beaconGuid; doc_beacon_shop_item_attrib.OwnerEntityType = ownerEntityType; doc_beacon_shop_item_attrib.ItemGuid = itemGuid; } private void appendAttribWrapperAll() { appendAttribWrapper(new AttribWrapper()); } protected override string onGetPrefixOfPK() { return getPrefixOfPK(); } protected override string onGetPrefixOfSK() { return getPrefixOfSK(); } protected override ServerErrorCode onCheckAndSetSK(string sortKey) { getPrimaryKey().fillUpSK(sortKey); setCombinationKeyForSK(sortKey); return ServerErrorCode.Success; } } }