105 lines
2.8 KiB
C#
105 lines
2.8 KiB
C#
using Newtonsoft.Json;
|
|
using ServerCore; using ServerBase;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Numerics;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
using OWNER_GUID = System.String;
|
|
|
|
namespace ServerCommon
|
|
{
|
|
public class RentalAttrib : AttribBase
|
|
{
|
|
[JsonProperty("land_meta_id")]
|
|
public int LandMetaId { get; set; }
|
|
|
|
[JsonProperty("building_meta_id")]
|
|
public int BuildingMetaId { get; set; }
|
|
|
|
[JsonProperty("floor")]
|
|
public int Floor { get; set; }
|
|
|
|
[JsonProperty("myhome_guid")]
|
|
public string MyhomeGuid { get; set; } = string.Empty;
|
|
|
|
[JsonProperty("rental_finish_time")]
|
|
public DateTime RentalFinishTime { get; set; } = new();
|
|
|
|
public RentalAttrib()
|
|
: base(typeof(RentalAttrib).Name, false)
|
|
{ }
|
|
}
|
|
|
|
//=============================================================================================
|
|
// PK(Partition Key) : "rental#user_guid"
|
|
// SK(Sort Key) : "address#landId#buidlingId#floor"
|
|
// DocType : RentalDoc
|
|
// RentalAttrib : {}
|
|
// ...
|
|
//=============================================================================================
|
|
|
|
public class RentalDoc : DynamoDbDocBase
|
|
{
|
|
private static string getPrefixOfPK() { return "rental#"; }
|
|
|
|
private static string getPrefixOfSK() { return "address#"; }
|
|
public RentalDoc()
|
|
: base(typeof(RentalDoc).Name)
|
|
{
|
|
appendAttribWrapperAll();
|
|
}
|
|
|
|
public RentalDoc(string userGuid, string address)
|
|
: base(typeof(RentalDoc).Name)
|
|
{
|
|
setCombinationKeyForPK(userGuid);
|
|
setCombinationKeyForSK(address);
|
|
|
|
appendAttribWrapperAll();
|
|
|
|
fillUpPrimaryKey(onMakePK(), onMakeSK());
|
|
}
|
|
|
|
public RentalDoc(string userGuid, string address, long ttlSeconds)
|
|
: base(typeof(RentalDoc).Name, ttlSeconds)
|
|
{
|
|
setCombinationKeyForPK(userGuid);
|
|
setCombinationKeyForSK(address);
|
|
|
|
appendAttribWrapperAll();
|
|
|
|
fillUpPrimaryKey(onMakePK(), onMakeSK());
|
|
}
|
|
|
|
private void appendAttribWrapperAll()
|
|
{
|
|
appendAttribWrapper(new AttribWrapper<RentalAttrib>());
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|