초기커밋
This commit is contained in:
139
ServerCommon/Doc/OwnerContents/EntityAlertRecordDoc.cs
Normal file
139
ServerCommon/Doc/OwnerContents/EntityAlertRecordDoc.cs
Normal file
@@ -0,0 +1,139 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
|
||||
|
||||
using ALERT_KEY = System.String;
|
||||
using META_ID = System.UInt32;
|
||||
using OWNER_GUID = System.String;
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class EntityAlertRecordAttrib : AttribBase
|
||||
{
|
||||
[JsonProperty("alert_key")]
|
||||
public ALERT_KEY AlertKey { get; set; } = string.Empty;
|
||||
[JsonProperty("alerted_time")]
|
||||
public DateTime AlertedTime { get; set; } = DateTimeHelper.MinTime;
|
||||
|
||||
[JsonProperty("owner_entity_type")]
|
||||
public OwnerEntityType OwnerEntityType { get; set; } = OwnerEntityType.None;
|
||||
[JsonProperty("owner_guid")]
|
||||
public OWNER_GUID OwnerGuid { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty("entity_alert_type")]
|
||||
public EntityAlertTriggerType EntityAlertTriggerType { get; set; } = EntityAlertTriggerType.None;
|
||||
[JsonProperty("meta_id")]
|
||||
public META_ID MetaId { get; set; } = 0;
|
||||
|
||||
public EntityAlertRecordAttrib()
|
||||
: base(typeof(EntityAlertRecordAttrib).Name, false)
|
||||
{ }
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// Primary Key
|
||||
// PK(Partition Key) : "entity_alert_record#{owner_guid}" [owner_guid : item_guid, ]
|
||||
// SK(Sort Key) : "{entity_alert_type}#{alert_key}"
|
||||
// DocType : EntityAlertRecordDoc
|
||||
// EntityAlertRecordAttrib :
|
||||
// ...
|
||||
//=============================================================================================
|
||||
public class EntityAlertRecordDoc : DynamoDbDocBase, ICopyDocFromEntityAttribute
|
||||
{
|
||||
private static string getPrefixOfPK() { return "entity_alert_record#"; }
|
||||
private static string getPrefixOfSK() { return ""; }
|
||||
|
||||
public EntityAlertRecordDoc()
|
||||
: base(typeof(EntityAlertRecordDoc).Name)
|
||||
{
|
||||
appendAttribWrapperAll();
|
||||
}
|
||||
|
||||
public EntityAlertRecordDoc( OWNER_GUID ownerGuid, ALERT_KEY alertKey, DateTime alertedTime
|
||||
, OwnerEntityType ownerEntityType
|
||||
, EntityAlertTriggerType triggerType, META_ID metaId )
|
||||
: base(typeof(EntityAlertRecordDoc).Name)
|
||||
{
|
||||
setCombinationKeyForPK(ownerGuid);
|
||||
setCombinationKeyForSK(makeALERT_KEY(triggerType, metaId));
|
||||
|
||||
appendAttribWrapperAll();
|
||||
|
||||
fillUpPrimaryKey(onMakePK(), onMakeSK());
|
||||
|
||||
var doc_entity_alert_record_attrib = getAttrib<EntityAlertRecordAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull( doc_entity_alert_record_attrib
|
||||
, () => $"doc_entity_alert_record_attrib is null !!! - ownerGuid:{ownerGuid}, alertKey:{alertKey}, ownerEntityType:{ownerEntityType}, alertTriggerType:{triggerType}, metaId:{metaId}");
|
||||
|
||||
doc_entity_alert_record_attrib.AlertKey = alertKey;
|
||||
doc_entity_alert_record_attrib.AlertedTime = alertedTime;
|
||||
doc_entity_alert_record_attrib.OwnerEntityType = ownerEntityType;
|
||||
doc_entity_alert_record_attrib.OwnerGuid = ownerGuid;
|
||||
doc_entity_alert_record_attrib.EntityAlertTriggerType = triggerType;
|
||||
doc_entity_alert_record_attrib.MetaId = metaId;
|
||||
}
|
||||
|
||||
private void appendAttribWrapperAll()
|
||||
{
|
||||
appendAttribWrapper(new AttribWrapper<EntityAlertRecordAttrib>());
|
||||
}
|
||||
|
||||
protected override string onGetPrefixOfPK()
|
||||
{
|
||||
return getPrefixOfPK();
|
||||
}
|
||||
|
||||
protected override string onGetPrefixOfSK()
|
||||
{
|
||||
return getPrefixOfSK();
|
||||
}
|
||||
|
||||
protected override ServerErrorCode onCheckAndSetSK(ALERT_KEY sortKey)
|
||||
{
|
||||
getPrimaryKey().fillUpSK(sortKey);
|
||||
setCombinationKeyForSK(sortKey);
|
||||
|
||||
return ServerErrorCode.Success;
|
||||
}
|
||||
|
||||
// override ICopyDocFromEntityAttribute
|
||||
public bool copyDocFromEntityAttribute(EntityAttributeBase entityAttributeBase)
|
||||
{
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(entityAttributeBase, () => $"entityAttributeBase is null !!! - {toBasicString()}");
|
||||
|
||||
var entity_alert_record_attribute = entityAttributeBase as EntityAlertRecordAttribute;
|
||||
if (null == entity_alert_record_attribute)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var to_copy_doc_entity_alert_record_attrib = getAttrib<EntityAlertRecordAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_entity_alert_record_attrib, () => $"to_copy_doc_entity_alert_record_attrib is null !!! - {toBasicString()}");
|
||||
|
||||
to_copy_doc_entity_alert_record_attrib.AlertKey = entity_alert_record_attribute.AlertKey;
|
||||
to_copy_doc_entity_alert_record_attrib.AlertedTime = entity_alert_record_attribute.AlertedTime;
|
||||
to_copy_doc_entity_alert_record_attrib.OwnerEntityType = entity_alert_record_attribute.OwnerEntityType;
|
||||
to_copy_doc_entity_alert_record_attrib.OwnerGuid = entity_alert_record_attribute.OwnerGuid;
|
||||
to_copy_doc_entity_alert_record_attrib.EntityAlertTriggerType = entity_alert_record_attribute.EntityAlertTriggerType;
|
||||
to_copy_doc_entity_alert_record_attrib.MetaId = entity_alert_record_attribute.MetaId;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static ALERT_KEY makeALERT_KEY(EntityAlertTriggerType entityAlertyTriggerType, META_ID metaId)
|
||||
{
|
||||
return $"{entityAlertyTriggerType}#{metaId}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user