초기커밋
This commit is contained in:
105
ServerCommon/Doc/OwnerContents/FriendFolderDoc.cs
Normal file
105
ServerCommon/Doc/OwnerContents/FriendFolderDoc.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
|
||||
using Axion.Collections.Concurrent;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class FriendFolder
|
||||
{
|
||||
[JsonProperty("folder_name")]
|
||||
public string FolderName { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty("is_hold")]
|
||||
public Int16 IsHold { get; set; } = 0;
|
||||
|
||||
[JsonProperty("hold_time")]
|
||||
public DateTime HoldTime { get; set; } = DateTimeHelper.MinTime;
|
||||
|
||||
[JsonProperty("create_time")]
|
||||
public DateTime CreateTime { get; set; } = DateTimeHelper.MinTime;
|
||||
}
|
||||
|
||||
|
||||
public class FriendFolderAttrib : AttribBase
|
||||
{
|
||||
[JsonProperty("folder_order_type")]
|
||||
public Int16 FolderOrderType { get; set; } = 1; //1 : ALPHABETICAL, 2: STATEFUL
|
||||
|
||||
[JsonProperty("friend_folders")]
|
||||
public ConcurrentDictionary<string, FriendFolder> Folders { get; set; } = new ConcurrentDictionary<string, FriendFolder>();
|
||||
|
||||
public void cloneAttrib(ref FriendFolderAttrib attrib)
|
||||
{
|
||||
attrib.FolderOrderType = FolderOrderType;
|
||||
attrib.Folders = new();
|
||||
foreach (var folder in Folders)
|
||||
{
|
||||
FriendFolder clone_folder = new FriendFolder();
|
||||
clone_folder.FolderName = folder.Value.FolderName;
|
||||
clone_folder.IsHold = folder.Value.IsHold;
|
||||
clone_folder.HoldTime = folder.Value.HoldTime;
|
||||
clone_folder.CreateTime = folder.Value.CreateTime;
|
||||
|
||||
attrib.Folders.TryAdd(folder.Key, clone_folder);
|
||||
}
|
||||
}
|
||||
|
||||
public FriendFolderAttrib()
|
||||
: base(typeof(FriendFolderAttrib).Name)
|
||||
{ }
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// PK(Partition Key) : "friendfolder#owner_guid"
|
||||
// SK(Sort Key) : ""
|
||||
// DocType : FriendFolderDoc
|
||||
// FriendFolderAttrib : {}
|
||||
// ...
|
||||
//=============================================================================================
|
||||
public class FriendFolderDoc : DynamoDbDocBase
|
||||
{
|
||||
public FriendFolderDoc()
|
||||
: base(typeof(FriendFolderDoc).Name)
|
||||
{
|
||||
appendAttribWrapper(new AttribWrapper<FriendFolderAttrib>());
|
||||
}
|
||||
|
||||
public FriendFolderDoc(string ownerGuid)
|
||||
: base(typeof(FriendFolderDoc).Name)
|
||||
{
|
||||
setCombinationKeyForPK(ownerGuid);
|
||||
appendAttribWrapper(new AttribWrapper<FriendFolderAttrib>());
|
||||
}
|
||||
|
||||
|
||||
protected override string onGetPrefixOfPK()
|
||||
{
|
||||
return "friend_folder#";
|
||||
}
|
||||
|
||||
protected override string onMakePK()
|
||||
{
|
||||
return $"{onGetPrefixOfPK()}{getCombinationKeyForPK()}";
|
||||
}
|
||||
|
||||
protected override string onMakeSK()
|
||||
{
|
||||
return $"{onGetPrefixOfSK()}{getCombinationKeyForSK()}";
|
||||
|
||||
}
|
||||
|
||||
protected override ServerErrorCode onCheckAndSetSK(string sortKey)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user