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

93 lines
2.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using ServerCore;
using ServerBase;
namespace ServerCommon;
public class BuildingProfitAttrib : AttribBase
{
[JsonProperty("building_meta_id")]
public int BuildingMetaId { get; set; }
[JsonProperty("floor")]
public int Floor { get; set; }
[JsonProperty("profit")]
public Dictionary<CurrencyType, double> Profits { get; set; } = new();
public BuildingProfitAttrib()
: base(typeof(BuildingProfitAttrib).Name, false)
{ }
}
//=============================================================================================
// PK(Partition Key) : "building#building_meta_id"
// SK(Sort Key) : "profit#floor"
// DocType : BuildingProfitDoc
// BuildingAttrib : {}
// ...
//=============================================================================================
public class BuildingProfitDoc : DynamoDbDocBase
{
private static string getPrefixOfPK() { return "building#"; }
public static string getPrefixOfSK() { return "profit#"; }
public BuildingProfitDoc()
: base(typeof(BuildingProfitAttrib).Name)
{
appendAttribWrapperAll();
}
public BuildingProfitDoc(int buildingMetaId, int floor)
: base(typeof(BuildingProfitAttrib).Name)
{
setCombinationKeyForPK(buildingMetaId.ToString());
setCombinationKeyForSK(floor.ToString());
appendAttribWrapperAll();
fillUpPrimaryKey(onMakePK(), onMakeSK());
}
private void appendAttribWrapperAll()
{
appendAttribWrapper(new AttribWrapper<BuildingProfitAttrib>());
}
protected override string onGetPrefixOfPK()
{
return getPrefixOfPK();
}
protected override string onGetPrefixOfSK()
{
return getPrefixOfSK();
}
protected override string onMakeSK()
{
return $"{onGetPrefixOfSK()}{getCombinationKeyForSK()}";
}
protected override ServerErrorCode onCheckAndSetSK(string sortKey)
{
getPrimaryKey().fillUpSK(sortKey);
return ServerErrorCode.Success;
}
}