초기커밋

This commit is contained in:
2025-05-01 07:20:41 +09:00
commit 98bb2e3c5c
2747 changed files with 646947 additions and 0 deletions

View File

@@ -0,0 +1,242 @@
using System;
using System.Threading.Tasks;
using Amazon.S3.Model;
using Newtonsoft.Json;
using ServerCore; using ServerBase;
using ServerControlCenter;
namespace ServerCommon
{
public class ClaimAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
{
[JsonProperty]
public MetaAssets.ClaimType ClaimType { get; set; } = MetaAssets.ClaimType.None;
[JsonProperty]
public int ClaimId { get; set; } = 0;
[JsonProperty]
public int ActiveRewardIdx { get; set; } = 0;
public DateTime ActiveTime { get; set; } = new();
[JsonProperty]
public DateTime CreateTime { get; set; } = new();
[JsonProperty]
public DateTime CompleteTime { get; set; } = new();
public int IsComplete { get; set; } = 0;
public ClaimAttribute( EntityBase owner, MetaAssets.ClaimType type
, EntityBase entityOfOwnerEntityType )
: base(owner, entityOfOwnerEntityType)
{
ClaimType = type;
}
public override void onClear()
{
ClaimType = MetaAssets.ClaimType.None;
ClaimId = 0;
ActiveRewardIdx = 0;
ActiveTime = DateTimeHelper.MinTime;
CreateTime = DateTimeHelper.MinTime;
CompleteTime = DateTimeHelper.MaxTime;
IsComplete = 0;
}
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
{
var result = new Result();
var owner = getOwner();
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
var user_attribute = owner.getRootParent().getEntityAttribute<UserAttribute>();
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!!");
//=====================================================================================
// Attribute => try pending Doc
//=====================================================================================
var try_pending_doc = getTryPendingDocBase() as ClaimDoc;
if (null == try_pending_doc)
{
var to_copy_doc = new ClaimDoc(user_attribute.UserGuid, ClaimType, ClaimId);
var origin_doc = getOriginDocBase<ClaimAttribute>();
if (null != origin_doc)
{
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
}
try_pending_doc = to_copy_doc;
setTryPendingDocBase(try_pending_doc);
}
var to_copy_claim_attrib = try_pending_doc.getAttrib<ClaimAttrib>();
NullReferenceCheckHelper.throwIfNull(to_copy_claim_attrib, () => $"to_copy_claim_attrib is null !!!");
to_copy_claim_attrib.ClaimType = ClaimType;
to_copy_claim_attrib.ClaimId = ClaimId;
to_copy_claim_attrib.ActiveRewardIdx = ActiveRewardIdx;
to_copy_claim_attrib.ActiveTime = ActiveTime;
to_copy_claim_attrib.CreateTime = CreateTime;
to_copy_claim_attrib.CompleteTime = CompleteTime;
to_copy_claim_attrib.IsComplete = IsComplete;
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 override EntityAttributeBase onCloned()
{
var owner = getOwner();
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
var entity_of_owner_entity_type = getEntityOfOwnerEntityType();
NullReferenceCheckHelper.throwIfNull(entity_of_owner_entity_type, () => $"entity_of_owner_entity_type is null !!!");
var cloned = new ClaimAttribute(owner, ClaimType, entity_of_owner_entity_type);
cloned.deepCopyFromBase(this);
cloned.ActiveTime = ActiveTime;
cloned.ClaimType = ClaimType;
cloned.ClaimId = ClaimId;
cloned.ActiveRewardIdx = ActiveRewardIdx;
cloned.CompleteTime = CompleteTime;
cloned.IsComplete = IsComplete;
return cloned;
}
public Result onMerge(EntityAttributeBase otherEntityAttribute)
{
var owner = getOwner();
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
var result = new Result();
var other_attribute = otherEntityAttribute as ClaimAttribute;
if (null == other_attribute)
{
var err_msg = $"Failed to cast ClaimAttribute !!!, other_attribute is null";
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
Log.getLogger().error(result.toBasicString());
return result;
}
//=====================================================================================
// OtherAttribute => Attribute
//=====================================================================================
ClaimType = other_attribute.ClaimType;
ClaimId = other_attribute.ClaimId;
ActiveRewardIdx = other_attribute.ActiveRewardIdx;
ActiveTime = other_attribute.ActiveTime;
CreateTime = other_attribute.CreateTime;
CompleteTime = other_attribute.CompleteTime;
IsComplete = other_attribute.IsComplete;
//=====================================================================================
// Attribute Try Pending Doc => Origin Doc
//=====================================================================================
var try_pending_doc = other_attribute.getTryPendingDocBase() as ClaimDoc;
if (null != try_pending_doc)
{
other_attribute.resetTryPendingDocBase();
syncOriginDocBaseWithNewDoc<ClaimAttribute>(try_pending_doc);
}
var origin_doc_base = getOriginDocBase<ClaimAttribute>();
if (null == origin_doc_base)
{
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
return result;
}
var claim_attrib = origin_doc_base.getAttrib<ClaimAttrib>();
NullReferenceCheckHelper.throwIfNull(claim_attrib, () => $"claim_attrib is null !!! - {owner.toBasicString()}");
claim_attrib.ClaimType = ClaimType;
claim_attrib.ClaimId = ClaimId;
claim_attrib.ActiveRewardIdx = ActiveRewardIdx;
claim_attrib.ActiveTime = ActiveTime;
claim_attrib.CreateTime = CreateTime;
claim_attrib.CompleteTime = CompleteTime;
claim_attrib.IsComplete = IsComplete;
return result;
}
public bool copyEntityAttributeFromDoc(DynamoDbDocBase customDoc)
{
var claim_doc_base = customDoc as ClaimDoc;
if (null == claim_doc_base)
{
var to_cast_string = typeof(ClaimDoc).Name;
var err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, claime_doc_base is null :{to_cast_string}";
Log.getLogger().error(err_msg);
return false;
}
//=====================================================================================
// New Doc => Origin Doc
//=====================================================================================
syncOriginDocBaseWithNewDoc<ClaimAttribute>(claim_doc_base);
var claim_attrib = claim_doc_base.getAttrib<ClaimAttrib>();
NullReferenceCheckHelper.throwIfNull(claim_attrib, () => $"claim_attrib is null !!!");
ClaimType = claim_attrib.ClaimType;
ClaimId = claim_attrib.ClaimId;
ActiveRewardIdx = claim_attrib.ActiveRewardIdx;
ActiveTime = claim_attrib.ActiveTime;
CreateTime = claim_attrib.CreateTime;
CompleteTime = claim_attrib.CompleteTime;
IsComplete = claim_attrib.IsComplete;
return true;
}
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
{
return new ClaimAtrributeTransactor(getOwner());
}
}
public class ClaimAtrributeTransactor : EntityAttributeTransactorBase<ClaimAttribute>
{
public ClaimAtrributeTransactor(EntityBase owner)
: base(owner)
{
}
public bool copyEntityAttributeTransactorBaseFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
{
//아직 미사용
Log.getLogger().info("copyEntityAttributeTransactorBaseFromEntityAttribute call");
return true;
}
}
}