fix(wxapi): 修复订阅消息事件通知模型在 JSON 模式下反序列化的错误

This commit is contained in:
Fu Diwei
2022-10-12 21:19:37 +08:00
parent 686ef31f73
commit 496fcf1e1f
6 changed files with 141 additions and 12 deletions

View File

@@ -35,19 +35,48 @@
/// <summary>
/// 获取或设置用户管理订阅通知数据列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("List")]
[System.Text.Json.Serialization.JsonPropertyName("List")]
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
[System.Xml.Serialization.XmlElement("List", typeof(Types.EventItem))]
public Types.EventItem[] EventList { get; set; } = default!;
}
}
private readonly object _lockObj = new object();
/// <summary>
/// 获取或设置事件数据。
/// </summary>
[Newtonsoft.Json.JsonProperty("SubscribeMsgChangeEvent")]
[System.Text.Json.Serialization.JsonPropertyName("SubscribeMsgChangeEvent")]
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
[System.Xml.Serialization.XmlElement("SubscribeMsgChangeEvent")]
public Types.EventData EventData { get; set; } = default!;
/// <summary>
/// 获取或设置用户管理订阅通知数据列表。
/// <para>等效于 <see cref="EventData.List"/> </para>
/// </summary>
[Newtonsoft.Json.JsonProperty("List")]
[System.Text.Json.Serialization.JsonPropertyName("List")]
[System.Xml.Serialization.XmlIgnore]
public Types.EventData.Types.EventItem[]? EventDataList
{
get { return this.EventData?.EventList; }
set
{
if (this.EventData == null)
{
lock (_lockObj)
{
if (this.EventData == null)
{
this.EventData = new Types.EventData();
}
}
}
this.EventData.EventList = value!;
}
}
}
}

View File

@@ -43,19 +43,48 @@
/// <summary>
/// 获取或设置用户订阅通知弹窗数据列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("List")]
[System.Text.Json.Serialization.JsonPropertyName("List")]
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
[System.Xml.Serialization.XmlElement("List", typeof(Types.EventItem))]
public Types.EventItem[] EventList { get; set; } = default!;
}
}
private readonly object _lockObj = new object();
/// <summary>
/// 获取或设置事件数据。
/// </summary>
[Newtonsoft.Json.JsonProperty("SubscribeMsgPopupEvent")]
[System.Text.Json.Serialization.JsonPropertyName("SubscribeMsgPopupEvent")]
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
[System.Xml.Serialization.XmlElement("SubscribeMsgPopupEvent")]
public Types.EventData EventData { get; set; } = default!;
/// <summary>
/// 获取或设置用户订阅通知弹窗数据列表。
/// <para>等效于 <see cref="EventData.List"/> </para>
/// </summary>
[Newtonsoft.Json.JsonProperty("List")]
[System.Text.Json.Serialization.JsonPropertyName("List")]
[System.Xml.Serialization.XmlIgnore]
public Types.EventData.Types.EventItem[]? EventDataList
{
get { return this.EventData?.EventList; }
set
{
if (this.EventData == null)
{
lock (_lockObj)
{
if (this.EventData == null)
{
this.EventData = new Types.EventData();
}
}
}
this.EventData.EventList = value!;
}
}
}
}

View File

@@ -51,19 +51,48 @@
/// <summary>
/// 获取或设置发送订阅通知数据列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("List")]
[System.Text.Json.Serialization.JsonPropertyName("List")]
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
[System.Xml.Serialization.XmlElement("List", typeof(Types.EventItem))]
public Types.EventItem[] EventList { get; set; } = default!;
}
}
private readonly object _lockObj = new object();
/// <summary>
/// 获取或设置事件数据。
/// </summary>
[Newtonsoft.Json.JsonProperty("SubscribeMsgSentEvent")]
[System.Text.Json.Serialization.JsonPropertyName("SubscribeMsgSentEvent")]
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
[System.Xml.Serialization.XmlElement("SubscribeMsgSentEvent")]
public Types.EventData EventData { get; set; } = default!;
/// <summary>
/// 获取或设置发送订阅通知数据列表。
/// <para>等效于 <see cref="EventData.List"/> </para>
/// </summary>
[Newtonsoft.Json.JsonProperty("List")]
[System.Text.Json.Serialization.JsonPropertyName("List")]
[System.Xml.Serialization.XmlIgnore]
public Types.EventData.Types.EventItem[]? EventDataList
{
get { return this.EventData?.EventList; }
set
{
if (this.EventData == null)
{
lock (_lockObj)
{
if (this.EventData == null)
{
this.EventData = new Types.EventData();
}
}
}
this.EventData.EventList = value!;
}
}
}
}

View File

@@ -0,0 +1,13 @@
{
"ToUserName": "gh_123456789abc",
"FromUserName": "o7esq5OI1Uej6Xixw1lA2H7XDVbc",
"CreateTime": "1610968440",
"MsgType": "event",
"Event": "subscribe_msg_change_event",
"List": [
{
"TemplateId": "BEwX0BOT3MqK3Uc5oTU3CGBqzjpndk2jzUf7VfExd8",
"SubscribeStatusString": "reject"
}
]
}

View File

@@ -0,0 +1,14 @@
{
"ToUserName": "gh_123456789abc",
"FromUserName": "o7esq5OI1Uej6Xixw1lA2H7XDVbc",
"CreateTime": "1620973045",
"MsgType": "event",
"Event": "subscribe_msg_popup_event",
"List": [
{
"TemplateId": "hD-ixGOhYmUfjOnI8MCzQMPshzGVeux_2vzyvQu7O68",
"SubscribeStatusString": "accept",
"PopupScene": "0"
}
]
}

View File

@@ -0,0 +1,15 @@
{
"ToUserName": "gh_123456789abc",
"FromUserName": "o7esq5PHRGBQYmeNyfG064wEFVpQ",
"CreateTime": "1620963428",
"MsgType": "event",
"Event": "subscribe_msg_sent_event",
"List": [
{
"TemplateId": "BEwX0BO-T3MqK3Uc5oTU3CGBqzjpndk2jzUf7VfExd8",
"MsgID": "1864323726461255680",
"ErrorCode": "0",
"ErrorStatus": "success"
}
]
}