添加项目文件。

This commit is contained in:
2026-05-09 17:06:30 +08:00
parent c60f5fe117
commit 720ef957d4
378 changed files with 14843 additions and 0 deletions
@@ -0,0 +1,37 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace MessageService.Domain.KeyObjects
{
public class MessageContent
{
// 兜底文本
[JsonPropertyName("fallback")]
public string Fallback { get; init; }
// 核心 Payload,反序列化时根据外层 MessageType 转换为具体子类
public string RawBody { get; init; }
public string RawExt { get; set; } = string.Empty;
[JsonPropertyName("body")]
// 业务代码使用的对象
[NotMapped]
public object Body => string.IsNullOrEmpty(RawBody) ? null : JsonSerializer.Deserialize<object>(RawBody);
[NotMapped]
public Dictionary<string, string> Ext => string.IsNullOrEmpty(RawExt)
? new()
: JsonSerializer.Deserialize<Dictionary<string, string>>(RawExt);
// 引用信息
[JsonPropertyName("quote")]
public QuoteInfo Quote { get; set; } = new();
private MessageContent() { }
public MessageContent(string fallback, object body)
{
Fallback = fallback;
RawBody = body == null ? null : JsonSerializer.Serialize(body);
}
}
}