초기커밋
This commit is contained in:
92
ServerCommon/Doc/BuildingBase/BuildingProfitDoc.cs
Normal file
92
ServerCommon/Doc/BuildingBase/BuildingProfitDoc.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user