초기커밋
This commit is contained in:
@@ -0,0 +1,445 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Amazon.DynamoDBv2;
|
||||
using Amazon.DynamoDBv2.Model;
|
||||
using Amazon.DynamoDBv2.DocumentModel;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
using ServerCommon.Cache;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using LAND_AUCTION_NUMBER = System.Int32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
using System.Runtime.InteropServices;
|
||||
using ServerControlCenter;
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class LandAuctionHighestBidUserAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute, ICopyEntityAttributeFromCache
|
||||
{
|
||||
[JsonProperty]
|
||||
public META_ID LandMetaId { get; set; } = 0; // 경매 대상 LandData Meta Id
|
||||
|
||||
[JsonProperty]
|
||||
public LAND_AUCTION_NUMBER AuctionNumber { get; set; } = 0; // 경매 번호
|
||||
|
||||
[JsonProperty]
|
||||
public CurrencyType BidCurrencyType { get; set; } = 0; // 입찰 재화의 종류
|
||||
|
||||
|
||||
//=============================================================================================
|
||||
// 현재 최고 입찰자 정보
|
||||
//=============================================================================================
|
||||
[JsonProperty]
|
||||
public double HighestBidPrice { get; set; } = 0; // 입찰 최고가
|
||||
|
||||
[JsonProperty]
|
||||
public string HighestBidUserGuid { get; set; } = string.Empty; // 입찰 최고가 유저 식별키
|
||||
|
||||
[JsonProperty]
|
||||
public string HighestBidUserNickname { get; set; } = string.Empty; // 입찰 최고가 유저 닉네임
|
||||
|
||||
|
||||
//=============================================================================================
|
||||
// 일반 입찰 최고 입찰자 정보
|
||||
//=============================================================================================
|
||||
[JsonProperty]
|
||||
public double NormalHighestBidPrice { get; set; } = 0; // 일반 입찰 최고가
|
||||
|
||||
[JsonProperty]
|
||||
public string NormalHighestBidUserGuid { get; set; } = string.Empty; // 일반 입찰 최고가 유저 식별키
|
||||
|
||||
[JsonProperty]
|
||||
public string NormalHighestBidUserNickname { get; set; } = string.Empty; // 일반 입찰 최고가 유저 닉네임
|
||||
|
||||
|
||||
|
||||
[JsonProperty]
|
||||
public DateTime HighestRankVersionTime { get; set; } = DateTimeHelper.MinTime; // 최고 입찰자 순위 버전 정보
|
||||
|
||||
|
||||
public LandAuctionHighestBidUserAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new LandAuctionHighestBidUserAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
LandMetaId = 0;
|
||||
AuctionNumber = 0;
|
||||
|
||||
BidCurrencyType = CurrencyType.None;
|
||||
|
||||
HighestBidPrice = 0;
|
||||
HighestBidUserGuid = string.Empty;
|
||||
HighestBidUserNickname = string.Empty;
|
||||
|
||||
NormalHighestBidPrice = 0;
|
||||
NormalHighestBidUserGuid = string.Empty;
|
||||
NormalHighestBidUserNickname = string.Empty;
|
||||
|
||||
HighestRankVersionTime = DateTimeHelper.MinTime;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new LandAuctionHighestBidUserAttribute(getOwner());
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.LandMetaId = LandMetaId;
|
||||
cloned.AuctionNumber = AuctionNumber;
|
||||
|
||||
cloned.BidCurrencyType = BidCurrencyType;
|
||||
|
||||
cloned.HighestBidPrice = HighestBidPrice;
|
||||
cloned.HighestBidUserGuid = HighestBidUserGuid;
|
||||
cloned.HighestBidUserNickname = HighestBidUserNickname;
|
||||
|
||||
cloned.NormalHighestBidPrice = NormalHighestBidPrice;
|
||||
cloned.NormalHighestBidUserGuid = NormalHighestBidUserGuid;
|
||||
cloned.NormalHighestBidUserNickname = NormalHighestBidUserNickname;
|
||||
|
||||
cloned.HighestRankVersionTime = HighestRankVersionTime;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as LandAuctionHighestBidUserDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new LandAuctionHighestBidUserDoc(LandMetaId, AuctionNumber);
|
||||
|
||||
var origin_doc = getOriginDocBase<LandAuctionHighestBidUserAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var highest_bid_user_attrib = try_pending_doc.getAttrib<LandAuctionHighestBidUserAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(highest_bid_user_attrib, () => $"highest_bid_user_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
highest_bid_user_attrib.LandMetaId = LandMetaId;
|
||||
highest_bid_user_attrib.AuctionNumber = AuctionNumber;
|
||||
|
||||
highest_bid_user_attrib.BidCurrencyType = BidCurrencyType;
|
||||
|
||||
highest_bid_user_attrib.HighestBidPrice = HighestBidPrice;
|
||||
highest_bid_user_attrib.HighestBidUserGuid = HighestBidUserGuid;
|
||||
highest_bid_user_attrib.HighestBidUserNickname = HighestBidUserNickname;
|
||||
|
||||
highest_bid_user_attrib.NormalHighestBidPrice = NormalHighestBidPrice;
|
||||
highest_bid_user_attrib.NormalHighestBidUserGuid = NormalHighestBidUserGuid;
|
||||
highest_bid_user_attrib.NormalHighestBidUserNickname = NormalHighestBidUserNickname;
|
||||
|
||||
highest_bid_user_attrib.HighestRankVersionTime = HighestRankVersionTime;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(LandAuctionHighestBidUserDoc).Name;
|
||||
|
||||
var highest_bid_user_doc = docBase as LandAuctionHighestBidUserDoc;
|
||||
if (null == highest_bid_user_doc)
|
||||
{
|
||||
err_msg = $"Failed to cast LandAuctionHighestBidUserDoc, highest_bid_user_doc is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<LandAuctionHighestBidUserAttribute>(highest_bid_user_doc);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var hightest_bid_user_attrib = highest_bid_user_doc.getAttrib<LandAuctionHighestBidUserAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(hightest_bid_user_attrib, () => "hightest_bid_user_attrib is null !!!");
|
||||
|
||||
LandMetaId = hightest_bid_user_attrib.LandMetaId;
|
||||
AuctionNumber = hightest_bid_user_attrib.AuctionNumber;
|
||||
|
||||
BidCurrencyType = hightest_bid_user_attrib.BidCurrencyType;
|
||||
|
||||
HighestBidPrice = hightest_bid_user_attrib.HighestBidPrice;
|
||||
HighestBidUserGuid = hightest_bid_user_attrib.HighestBidUserGuid;
|
||||
HighestBidUserNickname = hightest_bid_user_attrib.HighestBidUserNickname;
|
||||
|
||||
NormalHighestBidPrice = hightest_bid_user_attrib.NormalHighestBidPrice;
|
||||
NormalHighestBidUserGuid = hightest_bid_user_attrib.NormalHighestBidUserGuid;
|
||||
NormalHighestBidUserNickname = hightest_bid_user_attrib.NormalHighestBidUserNickname;
|
||||
|
||||
HighestRankVersionTime = hightest_bid_user_attrib.HighestRankVersionTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromCache(CacheBase cacheBase)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = string.Empty;
|
||||
|
||||
to_cast_string = typeof(LandAuctionTopBidderCache).Name;
|
||||
var top_bidder_cache = cacheBase as LandAuctionTopBidderCache;
|
||||
if (null != top_bidder_cache)
|
||||
{
|
||||
//=====================================================================================
|
||||
// LandAuctionTopBidderCache -> LandAuctionAttribute
|
||||
//=====================================================================================
|
||||
if (LandMetaId != top_bidder_cache.LandMetaId)
|
||||
{
|
||||
err_msg = $"Failed to copy from LandAuctionTopBidderCache !!!, Invalid LandMetaId !!! : currLandMetaId:{LandMetaId} == LandAuctionTopBidderCache.LandMetaId:{top_bidder_cache.LandMetaId} - {toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
HighestBidPrice = top_bidder_cache.HighestBidPrice;
|
||||
|
||||
if (HighestBidUserGuid != top_bidder_cache.HighestBidUserGuid)
|
||||
{
|
||||
HighestBidUserGuid = top_bidder_cache.HighestBidUserGuid;
|
||||
(var result, var nickname_attrib) = NicknameDoc.findNicknameFromGuid(HighestBidUserGuid).GetAwaiter().GetResult();
|
||||
if (result.isFail()) { Log.getLogger().error($"Failed to NicknameDoc.findNicknameFromGuid() !!! : {result.toBasicString()}, highestBidUserGuid:{HighestBidUserGuid} - {owner.toBasicString()}"); }
|
||||
else
|
||||
{
|
||||
NullReferenceCheckHelper.throwIfNull(nickname_attrib, () => $"nickname_attrib is null !!! - {owner.toBasicString()}");
|
||||
HighestBidUserNickname = nickname_attrib.Nickname;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
to_cast_string = typeof(NormalBidHighestUserCache).Name;
|
||||
var normal_bid_highest_user_cache = cacheBase as NormalBidHighestUserCache;
|
||||
if (null != normal_bid_highest_user_cache)
|
||||
{
|
||||
//=====================================================================================
|
||||
// LandAuctionTopBidderCache -> LandAuctionAttribute
|
||||
//=====================================================================================
|
||||
if (LandMetaId != normal_bid_highest_user_cache.LandMetaId)
|
||||
{
|
||||
err_msg = $"Failed to copy from NormalBidHighestUserCache !!!, Invalid LandMetaId !!! : currLandMetaId:{LandMetaId} == NormalBidHighestUserCache.LandMetaId:{normal_bid_highest_user_cache.LandMetaId} - {toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
NormalHighestBidPrice = normal_bid_highest_user_cache.NormalHighestBidPrice;
|
||||
NormalHighestBidUserGuid = normal_bid_highest_user_cache.NormalHighestBidUserGuid;
|
||||
NormalHighestBidUserNickname = normal_bid_highest_user_cache.NormalHighestBidUserNickname;
|
||||
|
||||
HighestRankVersionTime = normal_bid_highest_user_cache.HighestRankVersionTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var highest_bid_user_attribute = otherEntityAttribute as LandAuctionHighestBidUserAttribute;
|
||||
if (null == highest_bid_user_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast LandAuctionHighestBidUserAttribute !!!, highest_bid_user_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
LandMetaId = highest_bid_user_attribute.LandMetaId;
|
||||
AuctionNumber = highest_bid_user_attribute.AuctionNumber;
|
||||
|
||||
BidCurrencyType = highest_bid_user_attribute.BidCurrencyType;
|
||||
|
||||
HighestBidPrice = highest_bid_user_attribute.HighestBidPrice;
|
||||
HighestBidUserGuid = highest_bid_user_attribute.HighestBidUserGuid;
|
||||
HighestBidUserNickname = highest_bid_user_attribute.HighestBidUserNickname;
|
||||
|
||||
NormalHighestBidPrice = highest_bid_user_attribute.NormalHighestBidPrice;
|
||||
NormalHighestBidUserGuid = highest_bid_user_attribute.NormalHighestBidUserGuid;
|
||||
NormalHighestBidUserNickname = highest_bid_user_attribute.NormalHighestBidUserNickname;
|
||||
|
||||
HighestRankVersionTime = highest_bid_user_attribute.HighestRankVersionTime;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = highest_bid_user_attribute.getTryPendingDocBase() as LandAuctionHighestBidUserDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
highest_bid_user_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<LandAuctionHighestBidUserAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<LandAuctionHighestBidUserAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var highest_bid_user_attrib = origin_doc_base.getAttrib<LandAuctionHighestBidUserAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(highest_bid_user_attrib, () => $"highest_bid_user_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
highest_bid_user_attrib.LandMetaId = LandMetaId;
|
||||
highest_bid_user_attrib.AuctionNumber = AuctionNumber;
|
||||
|
||||
highest_bid_user_attrib.BidCurrencyType = BidCurrencyType;
|
||||
|
||||
highest_bid_user_attrib.HighestBidPrice = HighestBidPrice;
|
||||
highest_bid_user_attrib.HighestBidUserGuid = HighestBidUserGuid;
|
||||
highest_bid_user_attrib.HighestBidUserNickname = HighestBidUserNickname;
|
||||
|
||||
highest_bid_user_attrib.NormalHighestBidPrice = NormalHighestBidPrice;
|
||||
highest_bid_user_attrib.NormalHighestBidUserGuid = NormalHighestBidUserGuid;
|
||||
highest_bid_user_attrib.NormalHighestBidUserNickname = NormalHighestBidUserNickname;
|
||||
|
||||
highest_bid_user_attrib.HighestRankVersionTime = HighestRankVersionTime;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override string toBasicString()
|
||||
{
|
||||
return base.toBasicString()
|
||||
+ $" LandMetaId:{LandMetaId}, AuctionNumber:{AuctionNumber}"
|
||||
+ $", BidCurrencyType:{BidCurrencyType}"
|
||||
+ $", HighestBidPrice:{HighestBidPrice}, HighestBidUserGuid:{HighestBidUserGuid}, HighestBidUserNickname:{HighestBidUserNickname}"
|
||||
+ $", registeredVersion:{HighestRankVersionTime}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class LandAuctionHighestBidUserAttributeTransactor : EntityAttributeTransactorBase<LandAuctionHighestBidUserAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public LandAuctionHighestBidUserAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(LandAuctionHighestBidUserAttribute).Name;
|
||||
|
||||
var copy_from_highest_bid_user_attribute = entityAttributeBase as LandAuctionHighestBidUserAttribute;
|
||||
if (null == copy_from_highest_bid_user_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast LandAuctionHighestBidUserAttribute !!!, copy_from_highest_bid_user_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_highest_bid_user_attribute = getClonedEntityAttribute() as LandAuctionHighestBidUserAttribute;
|
||||
if (null == copy_to_highest_bid_user_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast LandAuctionHighestBidUserAttribute() !!!, copy_to_highest_bid_user_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_highest_bid_user_attribute.LandMetaId = copy_from_highest_bid_user_attribute.LandMetaId;
|
||||
copy_to_highest_bid_user_attribute.AuctionNumber = copy_from_highest_bid_user_attribute.AuctionNumber;
|
||||
|
||||
copy_to_highest_bid_user_attribute.BidCurrencyType = copy_from_highest_bid_user_attribute.BidCurrencyType;
|
||||
|
||||
copy_to_highest_bid_user_attribute.HighestBidPrice = copy_from_highest_bid_user_attribute.HighestBidPrice;
|
||||
copy_to_highest_bid_user_attribute.HighestBidUserGuid = copy_from_highest_bid_user_attribute.HighestBidUserGuid;
|
||||
copy_to_highest_bid_user_attribute.HighestBidUserNickname = copy_from_highest_bid_user_attribute.HighestBidUserNickname;
|
||||
|
||||
copy_to_highest_bid_user_attribute.NormalHighestBidPrice = copy_from_highest_bid_user_attribute.NormalHighestBidPrice;
|
||||
copy_to_highest_bid_user_attribute.NormalHighestBidUserGuid = copy_from_highest_bid_user_attribute.NormalHighestBidUserGuid;
|
||||
copy_to_highest_bid_user_attribute.NormalHighestBidUserNickname = copy_from_highest_bid_user_attribute.NormalHighestBidUserNickname;
|
||||
|
||||
copy_to_highest_bid_user_attribute.HighestRankVersionTime = copy_from_highest_bid_user_attribute.HighestRankVersionTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user