Files
caliverse_server/ServerCommon/Doc/OwnerContents/BeaconShopItemDoc.cs
2025-05-01 07:23:28 +09:00

96 lines
3.4 KiB
C#

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;
[JsonProperty("is_active_selling")]
public bool IsActiveSelling { get; set; } = false;
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<BeaconShopItemAttrib>();
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<BeaconShopItemAttrib>());
}
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;
}
}
}