초기커밋
This commit is contained in:
143
ServerCommon/Doc/Global/CaliumEventDoc.cs
Normal file
143
ServerCommon/Doc/Global/CaliumEventDoc.cs
Normal file
@@ -0,0 +1,143 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
|
||||
public enum CaliumEventStatus
|
||||
{
|
||||
None = 0,
|
||||
Regist = 1,
|
||||
Sending = 2,
|
||||
Failed = 4,
|
||||
Success = 5
|
||||
}
|
||||
|
||||
public class CaliumEventData
|
||||
{
|
||||
// Event Id
|
||||
[JsonProperty("event_id")]
|
||||
public string m_event_id { get; set; } = Guid.NewGuid().ToString();
|
||||
|
||||
// 서버 타입
|
||||
[JsonProperty("server_type")]
|
||||
public string m_server_type { get; set; } = string.Empty;
|
||||
|
||||
// 이벤트 타입 : calium_get(교환소 칼리움 획득) , extra_get(교환소 외 사파이어 소각) , calium_burn(칼리움 소각)
|
||||
[JsonProperty("event_type")]
|
||||
public string m_event_type { get; set; } = string.Empty;
|
||||
|
||||
// 하위타입 (위치구분)
|
||||
[JsonProperty("sub_type")]
|
||||
public string m_sub_type { get; set; } = string.Empty;
|
||||
|
||||
// 대상 구분 타입 : "user_nickname" 고정값
|
||||
[JsonProperty("div_type")]
|
||||
public string m_div_type { get; set; } = "user_nickname";
|
||||
|
||||
// 대상 구분 ID (유저 Nickname)
|
||||
[JsonProperty("div_id")]
|
||||
public string m_div_id { get; set; } = string.Empty;
|
||||
|
||||
// 칼리움 변경량 ( 양수 : 획득 / 음수 : 소모 )
|
||||
[JsonProperty("calium_change_volume")]
|
||||
public double m_calium_delta { get; set; }
|
||||
|
||||
// 사파이어 변경량 ( 양수 : 획득 / 음수 : 소모 )
|
||||
[JsonProperty("sapphire_change_volume")]
|
||||
public double m_sapphire_delta { get; set; }
|
||||
|
||||
// 이벤트 해당일의 epoch
|
||||
[JsonProperty("seq")]
|
||||
public int m_current_epoch { get; set; }
|
||||
|
||||
// 이벤트 해당일의 인플레이션 가중치
|
||||
[JsonProperty("swap_rate")]
|
||||
public double m_current_inflation_rate { get; set; }
|
||||
|
||||
// 이벤트 전송 시간
|
||||
[JsonProperty("event_time")]
|
||||
public string? m_event_time { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class CaliumEventAttrib : AttribBase
|
||||
{
|
||||
[JsonProperty("user_guid")] public USER_GUID UserGuid { get; set; } = string.Empty;
|
||||
[JsonProperty("status")] public CaliumEventStatus Status { get; set; }
|
||||
[JsonProperty("update_date")] public DateTime UpdateTime { get; set; } = DateTimeHelper.Current;
|
||||
[JsonProperty("calium_event")] public CaliumEventData EventData { get; set; } = new();
|
||||
public CaliumEventAttrib() : base(nameof(CaliumEventAttrib), false) {}
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// PK(Partition Key) : "calium#event"
|
||||
// SK(Sort Key) : "event_guid"
|
||||
// DocType : CaliumEventDoc
|
||||
// CaliumEventAttrib : {}
|
||||
// ...
|
||||
//=============================================================================================
|
||||
public class CaliumEventDoc : DynamoDbDocBase
|
||||
{
|
||||
public static string pk = "calium#event";
|
||||
private readonly string m_event_guid;
|
||||
|
||||
private string getPrefixOfPK() => "";
|
||||
private string getPrefixOfSK() => "";
|
||||
|
||||
public CaliumEventDoc(string? eventGuid) : base(nameof(CaliumEventDoc))
|
||||
{
|
||||
m_event_guid = eventGuid ?? Guid.NewGuid().ToString();
|
||||
setCombinationKeyForSK(m_event_guid);
|
||||
|
||||
fillUpPrimaryKey(onMakePK(), onMakeSK());
|
||||
appendAttribWrapperAll();
|
||||
}
|
||||
|
||||
public CaliumEventDoc() : base(nameof(CaliumEventDoc))
|
||||
{
|
||||
m_event_guid = Guid.NewGuid().ToString();
|
||||
|
||||
fillUpPrimaryKey(onMakePK(), onMakeSK());
|
||||
appendAttribWrapperAll();
|
||||
}
|
||||
|
||||
private void appendAttribWrapperAll()
|
||||
{
|
||||
appendAttribWrapper(new AttribWrapper<CaliumEventAttrib>());
|
||||
}
|
||||
|
||||
protected override string onMakePK()
|
||||
{
|
||||
return pk;
|
||||
}
|
||||
|
||||
protected override string onGetPrefixOfPK()
|
||||
{
|
||||
return getPrefixOfPK();
|
||||
}
|
||||
|
||||
protected override string onMakeSK()
|
||||
{
|
||||
return $"{onGetPrefixOfSK()}{getCombinationKeyForSK()}";
|
||||
}
|
||||
|
||||
protected override string onGetPrefixOfSK()
|
||||
{
|
||||
return getPrefixOfSK();
|
||||
}
|
||||
|
||||
protected override ServerErrorCode onCheckAndSetSK(string sortKey)
|
||||
{
|
||||
getPrimaryKey().fillUpSK(sortKey);
|
||||
setCombinationKeyForSK(sortKey);
|
||||
|
||||
return ServerErrorCode.Success;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user