diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCard.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCard.cs similarity index 92% rename from aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCard.cs rename to aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCard.cs index 2434e5989..b46a65a83 100644 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCard.cs +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCard.cs @@ -2,7 +2,7 @@ using Newtonsoft.Json; using System.Text.Json.Serialization; -namespace LINGYUN.Abp.WeChat.Work.Messages.Templates; +namespace LINGYUN.Abp.WeChat.Work.Messages.Models; public abstract class TemplateCard { diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardAction.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardAction.cs index cde2e2b6c..eab336981 100644 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardAction.cs +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardAction.cs @@ -1,75 +1,31 @@ using JetBrains.Annotations; using Newtonsoft.Json; using System.Text.Json.Serialization; -using Volo.Abp; namespace LINGYUN.Abp.WeChat.Work.Messages.Models; /// -/// 卡片的点击跳转事件 +/// 卡片操作按钮 /// public class TemplateCardAction { - /// - /// 卡片跳转类型,1 代表跳转url,2 代表打开小程序。text_notice模版卡片中该字段取值范围为[1,2] - /// - [NotNull] - [JsonProperty("type")] - [JsonPropertyName("type")] - public int Type { get; set; } - /// - /// 跳转链接的url,type是1时必填 - /// - [CanBeNull] - [JsonProperty("url")] - [JsonPropertyName("url")] - public string Url { get; set; } - /// - /// 点击跳转的小程序的appid,type是2时必填 - /// - [CanBeNull] - [JsonProperty("appid")] - [JsonPropertyName("appid")] - public string AppId { get; set; } - /// - /// 点击跳转的小程序的pagepath,type是2时选填 - /// - [CanBeNull] - [JsonProperty("pagepath")] - [JsonPropertyName("pagepath")] - public string PagePath { get; set; } - private TemplateCardAction( - int type, - string url = null, - string appId = null, - string pagePath = null) + public TemplateCardAction(string key, string text) { - Type = type; - Url = url; - AppId = appId; - PagePath = pagePath; + Key = key; + Text = text; } + /// - /// 创建一个跳转链接卡片事件 + /// 操作key值,用户点击后,会产生回调事件将本参数作为EventKey返回,回调事件会带上该key值,最长支持1024字节,不可重复 /// - /// 跳转链接的url - /// - public static TemplateCardAction Link(string url) - { - Check.NotNullOrWhiteSpace(url, nameof(url)); - - return new TemplateCardAction(1, url); - } + [NotNull] + [JsonProperty("key")] + [JsonPropertyName("key")] + public string Key { get; set; } /// - /// 创建一个跳转小程序卡片事件 + /// 操作的描述文案 /// - /// 小程序的appid - /// 小程序的pagePath - /// - public static TemplateCardAction MiniProgram(string appId, string pagePath) - { - Check.NotNullOrWhiteSpace(appId, nameof(appId)); - Check.NotNullOrWhiteSpace(pagePath, nameof(pagePath)); - - return new TemplateCardAction(2, appId: appId, pagePath: pagePath); - } -} + [NotNull] + [JsonProperty("text")] + [JsonPropertyName("text")] + public string Text { get; set; } +} \ No newline at end of file diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardActionMenu.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardActionMenu.cs similarity index 93% rename from aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardActionMenu.cs rename to aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardActionMenu.cs index 155b62601..ea44e33dc 100644 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardActionMenu.cs +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardActionMenu.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json; using System.Collections.Generic; using System.Text.Json.Serialization; -namespace LINGYUN.Abp.WeChat.Work.Messages.Templates; +namespace LINGYUN.Abp.WeChat.Work.Messages.Models; /// /// 卡片右上角更多操作按钮 /// diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardCardAction.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardCardAction.cs similarity index 96% rename from aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardCardAction.cs rename to aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardCardAction.cs index 205b9b87d..3710ea510 100644 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardCardAction.cs +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardCardAction.cs @@ -2,7 +2,7 @@ using Newtonsoft.Json; using System.Text.Json.Serialization; -namespace LINGYUN.Abp.WeChat.Work.Messages.Templates; +namespace LINGYUN.Abp.WeChat.Work.Messages.Models; /// /// 整体卡片的点击跳转事件 /// diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardEmphasisContent.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardEmphasisContent.cs index 2377ce537..d93d74973 100644 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardEmphasisContent.cs +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardEmphasisContent.cs @@ -8,28 +8,26 @@ namespace LINGYUN.Abp.WeChat.Work.Messages.Models; /// public class TemplateCardEmphasisContent { + public TemplateCardEmphasisContent( + string title = "", + string description = "") + { + Title = title; + Description = description; + } + /// - /// 关键数据样式的数据内容,建议不超过10个字 + /// 关键数据样式的数据内容,建议不超过14个字 /// [CanBeNull] [JsonProperty("title")] [JsonPropertyName("title")] public string Title { get; set; } /// - /// 关键数据样式的数据描述内容,建议不超过15个字 + /// 关键数据样式的数据描述内容,建议不超过22个字 /// [CanBeNull] [JsonProperty("desc")] [JsonPropertyName("desc")] public string Description { get; set; } - /// - /// 创建一个关键数据样式 - /// - /// 关键数据样式的数据内容 - /// 关键数据样式的数据描述内容 - public TemplateCardEmphasisContent(string title, string description = null) - { - Title = title; - Description = description; - } } diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardHorizontalContent.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardHorizontalContent.cs index 4018a040e..55dc5fc6e 100644 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardHorizontalContent.cs +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardHorizontalContent.cs @@ -1,7 +1,6 @@ using JetBrains.Annotations; using Newtonsoft.Json; using System.Text.Json.Serialization; -using Volo.Abp; namespace LINGYUN.Abp.WeChat.Work.Messages.Models; /// @@ -9,13 +8,53 @@ namespace LINGYUN.Abp.WeChat.Work.Messages.Models; /// public class TemplateCardHorizontalContent { + public static TemplateCardHorizontalContent None(string keyName, string value = "") + { + return new TemplateCardHorizontalContent( + keyName, 0, value); + } + + public static TemplateCardHorizontalContent FromUrl(string keyName, string url, string value = "") + { + return new TemplateCardHorizontalContent( + keyName, 1, value, url); + } + + public static TemplateCardHorizontalContent FromMedia(string keyName, string mediaId, string value = "") + { + return new TemplateCardHorizontalContent( + keyName, 2, value, mediaId: mediaId); + } + + public static TemplateCardHorizontalContent FromUser(string keyName, string userId, string value = "") + { + return new TemplateCardHorizontalContent( + keyName, 3, value, userId: userId); + } + + public TemplateCardHorizontalContent( + string keyName, + byte type = 0, + string value = "", + string url = "", + string mediaId = "", + string userId = "") + { + Type = type; + KeyName = keyName; + Value = value; + Url = url; + MediaId = mediaId; + UserId = userId; + } + /// - /// 模版卡片的二级标题信息内容支持的类型,1是url,2是文件附件,3 代表点击跳转成员详情 + /// 链接类型,0或不填代表不是链接,1 代表跳转url,2 代表下载附件,3 代表点击跳转成员详情 /// [CanBeNull] [JsonProperty("type")] [JsonPropertyName("type")] - public int? Type { get; set; } + public byte Type { get; } /// /// 二级标题,建议不超过5个字 /// @@ -24,100 +63,31 @@ public class TemplateCardHorizontalContent [JsonPropertyName("keyname")] public string KeyName { get; set; } /// - /// 二级文本,如果type是2,该字段代表文件名称(要包含文件类型),建议不超过26个字 + /// 二级文本,如果horizontal_content_list.type是2,该字段代表文件名称(要包含文件类型),建议不超过30个字,(支持id转译) /// [CanBeNull] [JsonProperty("value")] [JsonPropertyName("value")] public string Value { get; set; } /// - /// 链接跳转的url,type是1时必填 + /// 链接跳转的url,horizontal_content_list.type是1时必填 /// [CanBeNull] [JsonProperty("url")] [JsonPropertyName("url")] public string Url { get; set; } /// - /// 附件的media_id,type是2时必填 + /// 附件的media_id,horizontal_content_list.type是2时必填 /// [CanBeNull] [JsonProperty("media_id")] [JsonPropertyName("media_id")] public string MediaId { get; set; } /// - /// 成员详情的userid,type是3时必填 + /// 成员详情的userid,horizontal_content_list.type是3时必填 /// [CanBeNull] [JsonProperty("userid")] [JsonPropertyName("userid")] public string UserId { get; set; } - private TemplateCardHorizontalContent( - string keyName, - int? type = null, - string value = null, - string url = null, - string mediaId = null, - string userId = null) - { - Type = type; - KeyName = keyName; - Value = value; - Url = url; - MediaId = mediaId; - UserId = userId; - } - /// - /// 创建一个默认二级标题+文本 - /// - /// 二级标题 - /// 二级文本 - /// - public static TemplateCardHorizontalContent Default(string keyName, string value = null) - { - Check.NotNullOrWhiteSpace(keyName, nameof(keyName)); - - return new TemplateCardHorizontalContent(keyName, value: value); - } - /// - /// 创建一个跳转链接的二级标题+文本 - /// - /// 二级标题 - /// 链接跳转的url - /// 二级文本 - /// - public static TemplateCardHorizontalContent Link(string keyName, string url, string value = null) - { - Check.NotNullOrWhiteSpace(keyName, nameof(keyName)); - Check.NotNullOrWhiteSpace(url, nameof(url)); - - return new TemplateCardHorizontalContent(keyName, 1, value: value, url: url); - } - /// - /// 创建一个引用文件的二级标题+文本 - /// - /// 二级标题 - /// 文件名称 - /// 附件的mediaId - /// - public static TemplateCardHorizontalContent File(string keyName, string fileName, string mediaId) - { - Check.NotNullOrWhiteSpace(keyName, nameof(keyName)); - Check.NotNullOrWhiteSpace(fileName, nameof(fileName)); - Check.NotNullOrWhiteSpace(mediaId, nameof(mediaId)); - - return new TemplateCardHorizontalContent(keyName, 2, value: fileName, mediaId: mediaId); - } - /// - /// 创建一个成员详情的二级标题+文本 - /// - /// 二级标题 - /// 成员的userid - /// - public static TemplateCardHorizontalContent UserInfo(string keyName, string userId) - { - Check.NotNullOrWhiteSpace(keyName, nameof(keyName)); - Check.NotNullOrWhiteSpace(userId, nameof(userId)); - - return new TemplateCardHorizontalContent(keyName, 3, userId: userId); - } } diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardJump.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardJump.cs index 7418dae52..f996ec1a7 100644 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardJump.cs +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardJump.cs @@ -1,7 +1,9 @@ using JetBrains.Annotations; using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; using System.Text.Json.Serialization; -using Volo.Abp; namespace LINGYUN.Abp.WeChat.Work.Messages.Models; /// @@ -9,91 +11,52 @@ namespace LINGYUN.Abp.WeChat.Work.Messages.Models; /// public class TemplateCardJump { + public TemplateCardJump(string title, string url) + { + Type = 1; + Url = url; + Title = title; + } + public TemplateCardJump(string title, string appid, string pagePath) + { + Type = 2; + AppId = appid; + PagePath = pagePath; + Title = title; + } /// /// 跳转链接类型,0或不填代表不是链接,1 代表跳转url,2 代表跳转小程序 /// [CanBeNull] [JsonProperty("type")] [JsonPropertyName("type")] - public int? Type { get; set; } + public byte Type { get; } /// - /// 跳转链接样式的文案内容,建议不超过13个字 + /// 跳转链接样式的文案内容,建议不超过18个字 /// [NotNull] [JsonProperty("title")] [JsonPropertyName("title")] public string Title { get; set; } /// - /// 跳转链接的url,type是1时必填 + /// 跳转链接的url,jump_list.type是1时必填 /// [CanBeNull] [JsonProperty("url")] [JsonPropertyName("url")] public string Url { get; set; } /// - /// 点击跳转的小程序的appid,type是2时必填 + /// 跳转链接的小程序的appid,必须是与当前应用关联的小程序,jump_list.type是2时必填 /// [CanBeNull] [JsonProperty("appid")] [JsonPropertyName("appid")] public string AppId { get; set; } /// - /// 点击跳转的小程序的pagepath,type是2时选填 + /// 跳转链接的小程序的pagepath,jump_list.type是2时选填 /// [CanBeNull] [JsonProperty("pagepath")] [JsonPropertyName("pagepath")] public string PagePath { get; set; } - private TemplateCardJump( - string title, - int? type = null, - string url = null, - string appId = null, - string pagePath = null) - { - Type = type; - Title = title; - Url = url; - AppId = appId; - PagePath = pagePath; - } - /// - /// 创建一个默认指引样式 - /// - /// 跳转链接样式的文案内容 - /// - public static TemplateCardJump Default(string title) - { - Check.NotNullOrWhiteSpace(title, nameof(title)); - - return new TemplateCardJump(title); - } - /// - /// 创建一个跳转链接的指引样式 - /// - /// 跳转链接样式的文案内容 - /// 跳转链接的url - /// - public static TemplateCardJump Link(string title, string url) - { - Check.NotNullOrWhiteSpace(title, nameof(title)); - Check.NotNullOrWhiteSpace(url, nameof(url)); - - return new TemplateCardJump(title, 1, url); - } - /// - /// 创建一个跳转小程序的指引样式 - /// - /// 跳转链接样式的文案内容 - /// 跳转链接的小程序的appid - /// 跳转链接的小程序的pagepath - /// - public static TemplateCardJump MiniProgram(string title, string appId, string pagePath) - { - Check.NotNullOrWhiteSpace(title, nameof(title)); - Check.NotNullOrWhiteSpace(appId, nameof(appId)); - Check.NotNullOrWhiteSpace(pagePath, nameof(pagePath)); - - return new TemplateCardJump(title, 2, appId: appId, pagePath: pagePath); - } } diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardMainTitle.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardMainTitle.cs index b02075126..b8a0f78cc 100644 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardMainTitle.cs +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardMainTitle.cs @@ -4,32 +4,30 @@ using System.Text.Json.Serialization; namespace LINGYUN.Abp.WeChat.Work.Messages.Models; /// -/// 模版卡片的主要内容 +/// 卡票标题 /// public class TemplateCardMainTitle { + public TemplateCardMainTitle( + string title = "", + string description = "") + { + Title = title; + Description = description; + } + /// - /// 一级标题,建议不超过26个字。模版卡片主要内容的一级标题main_title.title和二级普通文本sub_title_text必须有一项填写 + /// 一级标题,建议不超过36个字,文本通知型卡片本字段非必填,但不可本字段和sub_title_text都不填,(支持id转译) /// [CanBeNull] [JsonProperty("title")] [JsonPropertyName("title")] public string Title { get; set; } /// - /// 标题辅助信息,建议不超过30个字 + /// 标题辅助信息,建议不超过44个字,(支持id转译) /// [CanBeNull] [JsonProperty("desc")] [JsonPropertyName("desc")] public string Description { get; set; } - /// - /// 创建一个模版卡片的主要内容 - /// - /// 一级标题 - /// 标题辅助信息 - public TemplateCardMainTitle(string title, string description = null) - { - Title = title; - Description = description; - } } diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardQuoteArea.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardQuoteArea.cs index cb773e501..0626cc7a9 100644 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardQuoteArea.cs +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardQuoteArea.cs @@ -1,37 +1,51 @@ using JetBrains.Annotations; using Newtonsoft.Json; using System.Text.Json.Serialization; -using Volo.Abp; namespace LINGYUN.Abp.WeChat.Work.Messages.Models; /// -/// 引用文献 +/// 引用文献样式 /// public class TemplateCardQuoteArea { + public TemplateCardQuoteArea(string url, string title = "", string text = "") + { + Type = 1; + Url = url; + Title = title; + Text = text; + } + public TemplateCardQuoteArea(string appid, string pagePath, string title = "", string text = "") + { + Type = 2; + AppId = appid; + PagePath = pagePath; + Title = title; + Text = text; + } /// /// 引用文献样式区域点击事件,0或不填代表没有点击事件,1 代表跳转url,2 代表跳转小程序 /// [CanBeNull] [JsonProperty("type")] [JsonPropertyName("type")] - public int? Type { get; set; } + public byte Type { get; } /// - /// 点击跳转的url,type是1时必填 + /// 点击跳转的url,quote_area.type是1时必填 /// [CanBeNull] [JsonProperty("url")] [JsonPropertyName("url")] public string Url { get; set; } /// - /// 点击跳转的小程序的appid,type是2时必填 + /// 点击跳转的小程序的appid,必须是与当前应用关联的小程序,quote_area.type是2时必填 /// [CanBeNull] [JsonProperty("appid")] [JsonPropertyName("appid")] public string AppId { get; set; } /// - /// 点击跳转的小程序的pagepath,type是2时选填 + /// 点击跳转的小程序的pagepath,quote_area.type是2时选填 /// [CanBeNull] [JsonProperty("pagepath")] @@ -50,62 +64,5 @@ public class TemplateCardQuoteArea [CanBeNull] [JsonProperty("quote_text")] [JsonPropertyName("quote_text")] - public string QuoteText { get; set; } - private TemplateCardQuoteArea( - string title, - int? type = null, - string url = null, - string appId = null, - string pagePath = null, - string quoteText = null) - { - Title = title; - QuoteText = quoteText; - Type = type; - Url = url; - AppId = appId; - PagePath = pagePath; - } - /// - /// 创建一个默认引用文献 - /// - /// 引用文献样式的标题 - /// 引用文献样式的引用文案 - /// - public static TemplateCardQuoteArea Default(string title, string quoteText = null) - { - Check.NotNullOrWhiteSpace(title, nameof(title)); - - return new TemplateCardQuoteArea(title, quoteText: quoteText); - } - /// - /// 创建一个跳转链接的引用文献 - /// - /// 引用文献样式的标题 - /// 点击跳转的url - /// 引用文献样式的引用文案 - /// - public static TemplateCardQuoteArea Link(string title, string url, string quoteText = null) - { - Check.NotNullOrWhiteSpace(title, nameof(title)); - Check.NotNullOrWhiteSpace(url, nameof(url)); - - return new TemplateCardQuoteArea(title, 1, url, quoteText: quoteText); - } - /// - /// 创建一个跳转小程序的引用文献 - /// - /// 引用文献样式的标题 - /// 跳转链接的小程序的appid - /// 跳转链接的小程序的pagepath - /// 引用文献样式的引用文案 - /// - public static TemplateCardQuoteArea MiniProgram(string title, string appId, string pagePath, string quoteText = null) - { - Check.NotNullOrWhiteSpace(title, nameof(title)); - Check.NotNullOrWhiteSpace(appId, nameof(appId)); - Check.NotNullOrWhiteSpace(pagePath, nameof(pagePath)); - - return new TemplateCardQuoteArea(title, 2, appId: appId, pagePath: pagePath, quoteText: quoteText); - } + public string Text { get; set; } } diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardSource.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardSource.cs index d0f5cf0fc..7000f010e 100644 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardSource.cs +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardSource.cs @@ -4,19 +4,39 @@ using System.Text.Json.Serialization; namespace LINGYUN.Abp.WeChat.Work.Messages.Models; /// +/// 来源文字颜色 +/// +public enum DescriptionColor +{ + Gray = 0, + Black = 1, + Red = 2, + Green = 3, +} +/// /// 卡片来源样式信息 /// public class TemplateCardSource { + public TemplateCardSource( + string iconUrl = "", + string description = "", + DescriptionColor descriptionColor = DescriptionColor.Gray) + { + IconUrl = iconUrl; + Description = description; + DescriptionColor = descriptionColor; + } + /// - /// 来源图片的url + /// 来源图片的url,来源图片的尺寸建议为72*72 /// [CanBeNull] [JsonProperty("icon_url")] [JsonPropertyName("icon_url")] public string IconUrl { get; set; } /// - /// 来源图片的描述,建议不超过13个字 + /// 来源图片的描述,建议不超过20个字,(支持id转译) /// [CanBeNull] [JsonProperty("desc")] @@ -28,54 +48,5 @@ public class TemplateCardSource [CanBeNull] [JsonProperty("desc_color")] [JsonPropertyName("desc_color")] - public int? DescriptionColor { get; set; } - private TemplateCardSource( - string iconUrl = null, - string description = null, - int? descriptionColor = 0) - { - IconUrl = iconUrl; - Description = description; - DescriptionColor = descriptionColor; - } - /// - /// 创建一个灰色卡片来源样式 - /// - /// 来源图片的url - /// 来源图片的描述 - /// - public static TemplateCardSource Grey(string iconUrl, string description = null) - { - return new TemplateCardSource(iconUrl, description, 0); - } - /// - /// 创建一个黑色卡片来源样式 - /// - /// 来源图片的url - /// 来源图片的描述 - /// - public static TemplateCardSource Black(string iconUrl, string description = null) - { - return new TemplateCardSource(iconUrl, description, 1); - } - /// - /// 创建一个红色卡片来源样式 - /// - /// 来源图片的url - /// 来源图片的描述 - /// - public static TemplateCardSource Red(string iconUrl, string description = null) - { - return new TemplateCardSource(iconUrl, description, 2); - } - /// - /// 创建一个绿色卡片来源样式 - /// - /// 来源图片的url - /// 来源图片的描述 - /// - public static TemplateCardSource Green(string iconUrl, string description = null) - { - return new TemplateCardSource(iconUrl, description, 3); - } + public DescriptionColor DescriptionColor { get; set; } } diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TextTemplateCard.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TextTemplateCard.cs similarity index 98% rename from aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TextTemplateCard.cs rename to aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TextTemplateCard.cs index 7f4ea3f64..7e9955712 100644 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TextTemplateCard.cs +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TextTemplateCard.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json; using System.Collections.Generic; using System.Text.Json.Serialization; -namespace LINGYUN.Abp.WeChat.Work.Messages.Templates; +namespace LINGYUN.Abp.WeChat.Work.Messages.Models; /// /// 文本模板卡片消息 /// diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/WeChatWorkTemplateCardMessage.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WeChatWorkTemplateCardMessage.cs similarity index 96% rename from aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/WeChatWorkTemplateCardMessage.cs rename to aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WeChatWorkTemplateCardMessage.cs index 5eca3e4fd..8c4f08c23 100644 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/WeChatWorkTemplateCardMessage.cs +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WeChatWorkTemplateCardMessage.cs @@ -2,7 +2,7 @@ using Newtonsoft.Json; using System.Text.Json.Serialization; -namespace LINGYUN.Abp.WeChat.Work.Messages.Templates; +namespace LINGYUN.Abp.WeChat.Work.Messages.Models; /// /// 企业微信模板卡片消息 /// diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookNewsNoticeCardMessage.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookNewsNoticeCardMessage.cs index 73b0e367a..f45675cac 100644 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookNewsNoticeCardMessage.cs +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookNewsNoticeCardMessage.cs @@ -11,6 +11,27 @@ namespace LINGYUN.Abp.WeChat.Work.Messages.Models; /// public class WebhookNewsNoticeCardMessage : WebhookTemplateCardMessage { + /// + /// 图片样式 + /// + [NotNull] + [JsonProperty("aspect_ratio")] + [JsonPropertyName("aspect_ratio")] + public WebhookTemplateCardImage CardImage { get; set; } + /// + /// 左图右文样式 + /// + [CanBeNull] + [JsonProperty("image_text_area")] + [JsonPropertyName("image_text_area")] + public WebhookTemplateCardImageTextArea ImageTextArea { get; set; } + /// + /// 卡片二级垂直内容,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过4 + /// + [CanBeNull] + [JsonProperty("vertical_content_list")] + [JsonPropertyName("vertical_content_list")] + public List VerticalContents { get; set; } /// /// 创建一个Webhook 图文展示模版卡片消息体 /// @@ -25,15 +46,15 @@ public class WebhookNewsNoticeCardMessage : WebhookTemplateCardMessage /// 跳转指引样式的列表,列表长度不超过3 /// public WebhookNewsNoticeCardMessage( - TemplateCardImage cardImage, - TemplateCardAction action, - TemplateCardMainTitle mainTitle, - TemplateCardImageTextArea imageTextArea = null, - TemplateCardSource source = null, - TemplateCardQuoteArea quoteArea = null, - List horizontalContents = null, - List verticalContents = null, - List jumps = null) + WebhookTemplateCardImage cardImage, + WebhookTemplateCardAction action, + WebhookTemplateCardMainTitle mainTitle, + WebhookTemplateCardImageTextArea imageTextArea = null, + WebhookTemplateCardSource source = null, + WebhookTemplateCardQuoteArea quoteArea = null, + List horizontalContents = null, + List verticalContents = null, + List jumps = null) : base("news_notice", action, mainTitle, source, quoteArea, horizontalContents, jumps) { Check.NotNull(mainTitle, nameof(mainTitle)); @@ -48,25 +69,4 @@ public class WebhookNewsNoticeCardMessage : WebhookTemplateCardMessage throw new ArgumentException("The length of the secondary vertical content list on the card cannot exceed 4!"); } } - /// - /// 图片样式 - /// - [NotNull] - [JsonProperty("aspect_ratio")] - [JsonPropertyName("aspect_ratio")] - public TemplateCardImage CardImage { get; set; } - /// - /// 左图右文样式 - /// - [CanBeNull] - [JsonProperty("image_text_area")] - [JsonPropertyName("image_text_area")] - public TemplateCardImageTextArea ImageTextArea { get; set; } - /// - /// 卡片二级垂直内容,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过4 - /// - [CanBeNull] - [JsonProperty("vertical_content_list")] - [JsonPropertyName("vertical_content_list")] - public List VerticalContents { get; set; } } diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardAction.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardAction.cs new file mode 100644 index 000000000..a02ada44c --- /dev/null +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardAction.cs @@ -0,0 +1,75 @@ +using JetBrains.Annotations; +using Newtonsoft.Json; +using System.Text.Json.Serialization; +using Volo.Abp; + +namespace LINGYUN.Abp.WeChat.Work.Messages.Models; +/// +/// 卡片的点击跳转事件 +/// +public class WebhookTemplateCardAction +{ + /// + /// 卡片跳转类型,1 代表跳转url,2 代表打开小程序。text_notice模版卡片中该字段取值范围为[1,2] + /// + [NotNull] + [JsonProperty("type")] + [JsonPropertyName("type")] + public int Type { get; set; } + /// + /// 跳转链接的url,type是1时必填 + /// + [CanBeNull] + [JsonProperty("url")] + [JsonPropertyName("url")] + public string Url { get; set; } + /// + /// 点击跳转的小程序的appid,type是2时必填 + /// + [CanBeNull] + [JsonProperty("appid")] + [JsonPropertyName("appid")] + public string AppId { get; set; } + /// + /// 点击跳转的小程序的pagepath,type是2时选填 + /// + [CanBeNull] + [JsonProperty("pagepath")] + [JsonPropertyName("pagepath")] + public string PagePath { get; set; } + private WebhookTemplateCardAction( + int type, + string url = null, + string appId = null, + string pagePath = null) + { + Type = type; + Url = url; + AppId = appId; + PagePath = pagePath; + } + /// + /// 创建一个跳转链接卡片事件 + /// + /// 跳转链接的url + /// + public static WebhookTemplateCardAction Link(string url) + { + Check.NotNullOrWhiteSpace(url, nameof(url)); + + return new WebhookTemplateCardAction(1, url); + } + /// + /// 创建一个跳转小程序卡片事件 + /// + /// 小程序的appid + /// 小程序的pagePath + /// + public static WebhookTemplateCardAction MiniProgram(string appId, string pagePath) + { + Check.NotNullOrWhiteSpace(appId, nameof(appId)); + Check.NotNullOrWhiteSpace(pagePath, nameof(pagePath)); + + return new WebhookTemplateCardAction(2, appId: appId, pagePath: pagePath); + } +} diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardEmphasisContent.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardEmphasisContent.cs similarity index 54% rename from aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardEmphasisContent.cs rename to aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardEmphasisContent.cs index d0b5dea7d..91394867a 100644 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardEmphasisContent.cs +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardEmphasisContent.cs @@ -2,32 +2,34 @@ using Newtonsoft.Json; using System.Text.Json.Serialization; -namespace LINGYUN.Abp.WeChat.Work.Messages.Templates; +namespace LINGYUN.Abp.WeChat.Work.Messages.Models; /// /// 关键数据样式 /// -public class TemplateCardEmphasisContent +public class WebhookTemplateCardEmphasisContent { - public TemplateCardEmphasisContent( - string title = "", - string description = "") - { - Title = title; - Description = description; - } - /// - /// 关键数据样式的数据内容,建议不超过14个字 + /// 关键数据样式的数据内容,建议不超过10个字 /// [CanBeNull] [JsonProperty("title")] [JsonPropertyName("title")] public string Title { get; set; } /// - /// 关键数据样式的数据描述内容,建议不超过22个字 + /// 关键数据样式的数据描述内容,建议不超过15个字 /// [CanBeNull] [JsonProperty("desc")] [JsonPropertyName("desc")] public string Description { get; set; } + /// + /// 创建一个关键数据样式 + /// + /// 关键数据样式的数据内容 + /// 关键数据样式的数据描述内容 + public WebhookTemplateCardEmphasisContent(string title, string description = null) + { + Title = title; + Description = description; + } } diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardHorizontalContent.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardHorizontalContent.cs new file mode 100644 index 000000000..96e2c3341 --- /dev/null +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardHorizontalContent.cs @@ -0,0 +1,123 @@ +using JetBrains.Annotations; +using Newtonsoft.Json; +using System.Text.Json.Serialization; +using Volo.Abp; + +namespace LINGYUN.Abp.WeChat.Work.Messages.Models; +/// +/// 二级标题+文本 +/// +public class WebhookTemplateCardHorizontalContent +{ + /// + /// 模版卡片的二级标题信息内容支持的类型,1是url,2是文件附件,3 代表点击跳转成员详情 + /// + [CanBeNull] + [JsonProperty("type")] + [JsonPropertyName("type")] + public int? Type { get; set; } + /// + /// 二级标题,建议不超过5个字 + /// + [NotNull] + [JsonProperty("keyname")] + [JsonPropertyName("keyname")] + public string KeyName { get; set; } + /// + /// 二级文本,如果type是2,该字段代表文件名称(要包含文件类型),建议不超过26个字 + /// + [CanBeNull] + [JsonProperty("value")] + [JsonPropertyName("value")] + public string Value { get; set; } + /// + /// 链接跳转的url,type是1时必填 + /// + [CanBeNull] + [JsonProperty("url")] + [JsonPropertyName("url")] + public string Url { get; set; } + /// + /// 附件的media_id,type是2时必填 + /// + [CanBeNull] + [JsonProperty("media_id")] + [JsonPropertyName("media_id")] + public string MediaId { get; set; } + /// + /// 成员详情的userid,type是3时必填 + /// + [CanBeNull] + [JsonProperty("userid")] + [JsonPropertyName("userid")] + public string UserId { get; set; } + private WebhookTemplateCardHorizontalContent( + string keyName, + int? type = null, + string value = null, + string url = null, + string mediaId = null, + string userId = null) + { + Type = type; + KeyName = keyName; + Value = value; + Url = url; + MediaId = mediaId; + UserId = userId; + } + /// + /// 创建一个默认二级标题+文本 + /// + /// 二级标题 + /// 二级文本 + /// + public static WebhookTemplateCardHorizontalContent Default(string keyName, string value = null) + { + Check.NotNullOrWhiteSpace(keyName, nameof(keyName)); + + return new WebhookTemplateCardHorizontalContent(keyName, value: value); + } + /// + /// 创建一个跳转链接的二级标题+文本 + /// + /// 二级标题 + /// 链接跳转的url + /// 二级文本 + /// + public static WebhookTemplateCardHorizontalContent Link(string keyName, string url, string value = null) + { + Check.NotNullOrWhiteSpace(keyName, nameof(keyName)); + Check.NotNullOrWhiteSpace(url, nameof(url)); + + return new WebhookTemplateCardHorizontalContent(keyName, 1, value: value, url: url); + } + /// + /// 创建一个引用文件的二级标题+文本 + /// + /// 二级标题 + /// 文件名称 + /// 附件的mediaId + /// + public static WebhookTemplateCardHorizontalContent File(string keyName, string fileName, string mediaId) + { + Check.NotNullOrWhiteSpace(keyName, nameof(keyName)); + Check.NotNullOrWhiteSpace(fileName, nameof(fileName)); + Check.NotNullOrWhiteSpace(mediaId, nameof(mediaId)); + + return new WebhookTemplateCardHorizontalContent(keyName, 2, value: fileName, mediaId: mediaId); + } + /// + /// 创建一个成员详情的二级标题+文本 + /// + /// 二级标题 + /// 成员的userid + /// + public static WebhookTemplateCardHorizontalContent UserInfo(string keyName, string userId) + { + Check.NotNullOrWhiteSpace(keyName, nameof(keyName)); + Check.NotNullOrWhiteSpace(userId, nameof(userId)); + + return new WebhookTemplateCardHorizontalContent(keyName, 3, userId: userId); + } +} diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardImage.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardImage.cs similarity index 88% rename from aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardImage.cs rename to aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardImage.cs index 2a12d353a..ce6f91021 100644 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardImage.cs +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardImage.cs @@ -6,7 +6,7 @@ namespace LINGYUN.Abp.WeChat.Work.Messages.Models; /// /// 图片样式 /// -public class TemplateCardImage +public class WebhookTemplateCardImage { /// /// 图片的url @@ -27,7 +27,7 @@ public class TemplateCardImage /// /// 图片的url /// 图片的宽高比,不填该参数默认1.3 - public TemplateCardImage(string url, float? aspectRatio = 1.3f) + public WebhookTemplateCardImage(string url, float? aspectRatio = 1.3f) { Url = url; AspectRatio = aspectRatio; diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardImageTextArea.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardImageTextArea.cs similarity index 88% rename from aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardImageTextArea.cs rename to aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardImageTextArea.cs index bcb0d5892..ef5ff32fb 100644 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardImageTextArea.cs +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardImageTextArea.cs @@ -7,7 +7,7 @@ namespace LINGYUN.Abp.WeChat.Work.Messages.Models; /// /// 左图右文样式 /// -public class TemplateCardImageTextArea +public class WebhookTemplateCardImageTextArea { /// /// 左图右文样式区域点击事件,0或不填代表没有点击事件,1 代表跳转url,2 代表跳转小程序 @@ -58,7 +58,7 @@ public class TemplateCardImageTextArea [JsonProperty("desc")] [JsonPropertyName("desc")] public string Description { get; set; } - private TemplateCardImageTextArea( + private WebhookTemplateCardImageTextArea( string imageUrl, int? type = null, string url = null, @@ -83,7 +83,7 @@ public class TemplateCardImageTextArea /// 左图右文样式的标题 /// 左图右文样式的描述 /// - public static TemplateCardImageTextArea Link( + public static WebhookTemplateCardImageTextArea Link( string imageUrl, string url, string title = null, @@ -92,7 +92,7 @@ public class TemplateCardImageTextArea Check.NotNullOrWhiteSpace(imageUrl, nameof(imageUrl)); Check.NotNullOrWhiteSpace(url, nameof(url)); - return new TemplateCardImageTextArea(imageUrl, 1, url: url, title: title, description: description); + return new WebhookTemplateCardImageTextArea(imageUrl, 1, url: url, title: title, description: description); } /// /// 创建一个跳转小程序左图右文样式 @@ -103,7 +103,7 @@ public class TemplateCardImageTextArea /// 左图右文样式的标题 /// 左图右文样式的描述 /// - public static TemplateCardImageTextArea MiniProgram( + public static WebhookTemplateCardImageTextArea MiniProgram( string imageUrl, string appId, string pagePath, @@ -114,6 +114,6 @@ public class TemplateCardImageTextArea Check.NotNullOrWhiteSpace(appId, nameof(appId)); Check.NotNullOrWhiteSpace(pagePath, nameof(pagePath)); - return new TemplateCardImageTextArea(imageUrl, 2, appId: appId, pagePath: pagePath, title: title, description: description); + return new WebhookTemplateCardImageTextArea(imageUrl, 2, appId: appId, pagePath: pagePath, title: title, description: description); } } diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardJump.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardJump.cs new file mode 100644 index 000000000..45a33fbc6 --- /dev/null +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardJump.cs @@ -0,0 +1,99 @@ +using JetBrains.Annotations; +using Newtonsoft.Json; +using System.Text.Json.Serialization; +using Volo.Abp; + +namespace LINGYUN.Abp.WeChat.Work.Messages.Models; +/// +/// 跳转指引样式 +/// +public class WebhookTemplateCardJump +{ + /// + /// 跳转链接类型,0或不填代表不是链接,1 代表跳转url,2 代表跳转小程序 + /// + [CanBeNull] + [JsonProperty("type")] + [JsonPropertyName("type")] + public int? Type { get; set; } + /// + /// 跳转链接样式的文案内容,建议不超过13个字 + /// + [NotNull] + [JsonProperty("title")] + [JsonPropertyName("title")] + public string Title { get; set; } + /// + /// 跳转链接的url,type是1时必填 + /// + [CanBeNull] + [JsonProperty("url")] + [JsonPropertyName("url")] + public string Url { get; set; } + /// + /// 点击跳转的小程序的appid,type是2时必填 + /// + [CanBeNull] + [JsonProperty("appid")] + [JsonPropertyName("appid")] + public string AppId { get; set; } + /// + /// 点击跳转的小程序的pagepath,type是2时选填 + /// + [CanBeNull] + [JsonProperty("pagepath")] + [JsonPropertyName("pagepath")] + public string PagePath { get; set; } + private WebhookTemplateCardJump( + string title, + int? type = null, + string url = null, + string appId = null, + string pagePath = null) + { + Type = type; + Title = title; + Url = url; + AppId = appId; + PagePath = pagePath; + } + /// + /// 创建一个默认指引样式 + /// + /// 跳转链接样式的文案内容 + /// + public static WebhookTemplateCardJump Default(string title) + { + Check.NotNullOrWhiteSpace(title, nameof(title)); + + return new WebhookTemplateCardJump(title); + } + /// + /// 创建一个跳转链接的指引样式 + /// + /// 跳转链接样式的文案内容 + /// 跳转链接的url + /// + public static WebhookTemplateCardJump Link(string title, string url) + { + Check.NotNullOrWhiteSpace(title, nameof(title)); + Check.NotNullOrWhiteSpace(url, nameof(url)); + + return new WebhookTemplateCardJump(title, 1, url); + } + /// + /// 创建一个跳转小程序的指引样式 + /// + /// 跳转链接样式的文案内容 + /// 跳转链接的小程序的appid + /// 跳转链接的小程序的pagepath + /// + public static WebhookTemplateCardJump MiniProgram(string title, string appId, string pagePath) + { + Check.NotNullOrWhiteSpace(title, nameof(title)); + Check.NotNullOrWhiteSpace(appId, nameof(appId)); + Check.NotNullOrWhiteSpace(pagePath, nameof(pagePath)); + + return new WebhookTemplateCardJump(title, 2, appId: appId, pagePath: pagePath); + } +} diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardMainTitle.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardMainTitle.cs new file mode 100644 index 000000000..9a4db37b1 --- /dev/null +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardMainTitle.cs @@ -0,0 +1,35 @@ +using JetBrains.Annotations; +using Newtonsoft.Json; +using System.Text.Json.Serialization; + +namespace LINGYUN.Abp.WeChat.Work.Messages.Models; +/// +/// 模版卡片的主要内容 +/// +public class WebhookTemplateCardMainTitle +{ + /// + /// 一级标题,建议不超过26个字。模版卡片主要内容的一级标题main_title.title和二级普通文本sub_title_text必须有一项填写 + /// + [CanBeNull] + [JsonProperty("title")] + [JsonPropertyName("title")] + public string Title { get; set; } + /// + /// 标题辅助信息,建议不超过30个字 + /// + [CanBeNull] + [JsonProperty("desc")] + [JsonPropertyName("desc")] + public string Description { get; set; } + /// + /// 创建一个模版卡片的主要内容 + /// + /// 一级标题 + /// 标题辅助信息 + public WebhookTemplateCardMainTitle(string title, string description = null) + { + Title = title; + Description = description; + } +} diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardMessage.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardMessage.cs index 2de22a67a..ef801dde8 100644 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardMessage.cs +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardMessage.cs @@ -24,42 +24,42 @@ public abstract class WebhookTemplateCardMessage [CanBeNull] [JsonProperty("source")] [JsonPropertyName("source")] - public TemplateCardSource Source { get; set; } + public WebhookTemplateCardSource Source { get; set; } /// /// 模版卡片的主要内容,包括一级标题和标题辅助信息 /// [CanBeNull] [JsonProperty("main_title")] [JsonPropertyName("main_title")] - public TemplateCardMainTitle MainTitle { get; set; } + public WebhookTemplateCardMainTitle MainTitle { get; set; } /// /// 引用文献样式,建议不与关键数据共用 /// [CanBeNull] [JsonProperty("quote_area")] [JsonPropertyName("quote_area")] - public TemplateCardQuoteArea QuoteArea { get; set; } + public WebhookTemplateCardQuoteArea QuoteArea { get; set; } /// /// 二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6 /// [CanBeNull] [JsonProperty("horizontal_content_list")] [JsonPropertyName("horizontal_content_list")] - public List HorizontalContents { get; set; } + public List HorizontalContents { get; set; } /// /// 跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过3 /// [CanBeNull] [JsonProperty("jump_list")] [JsonPropertyName("jump_list")] - public List Jumps { get; set; } + public List Jumps { get; set; } /// /// 整体卡片的点击跳转事件,text_notice模版卡片中该字段为必填项 /// [CanBeNull] [JsonProperty("card_action")] [JsonPropertyName("card_action")] - public TemplateCardAction Action { get; set; } + public WebhookTemplateCardAction Action { get; set; } /// /// 创建一个Webhook模板卡片消息体 /// @@ -72,12 +72,12 @@ public abstract class WebhookTemplateCardMessage /// protected WebhookTemplateCardMessage( string cardType, - TemplateCardAction action, - TemplateCardMainTitle mainTitle = null, - TemplateCardSource source = null, - TemplateCardQuoteArea quoteArea = null, - List horizontalContents = null, - List jumps = null) + WebhookTemplateCardAction action, + WebhookTemplateCardMainTitle mainTitle = null, + WebhookTemplateCardSource source = null, + WebhookTemplateCardQuoteArea quoteArea = null, + List horizontalContents = null, + List jumps = null) { CardType = Check.NotNullOrWhiteSpace(cardType, nameof(cardType)); Action = Check.NotNull(action, nameof(action)); diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardQuoteArea.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardQuoteArea.cs new file mode 100644 index 000000000..dd00cd366 --- /dev/null +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardQuoteArea.cs @@ -0,0 +1,111 @@ +using JetBrains.Annotations; +using Newtonsoft.Json; +using System.Text.Json.Serialization; +using Volo.Abp; + +namespace LINGYUN.Abp.WeChat.Work.Messages.Models; +/// +/// 引用文献 +/// +public class WebhookTemplateCardQuoteArea +{ + /// + /// 引用文献样式区域点击事件,0或不填代表没有点击事件,1 代表跳转url,2 代表跳转小程序 + /// + [CanBeNull] + [JsonProperty("type")] + [JsonPropertyName("type")] + public int? Type { get; set; } + /// + /// 点击跳转的url,type是1时必填 + /// + [CanBeNull] + [JsonProperty("url")] + [JsonPropertyName("url")] + public string Url { get; set; } + /// + /// 点击跳转的小程序的appid,type是2时必填 + /// + [CanBeNull] + [JsonProperty("appid")] + [JsonPropertyName("appid")] + public string AppId { get; set; } + /// + /// 点击跳转的小程序的pagepath,type是2时选填 + /// + [CanBeNull] + [JsonProperty("pagepath")] + [JsonPropertyName("pagepath")] + public string PagePath { get; set; } + /// + /// 引用文献样式的标题 + /// + [CanBeNull] + [JsonProperty("title")] + [JsonPropertyName("title")] + public string Title { get; set; } + /// + /// 引用文献样式的引用文案 + /// + [CanBeNull] + [JsonProperty("quote_text")] + [JsonPropertyName("quote_text")] + public string QuoteText { get; set; } + private WebhookTemplateCardQuoteArea( + string title, + int? type = null, + string url = null, + string appId = null, + string pagePath = null, + string quoteText = null) + { + Title = title; + QuoteText = quoteText; + Type = type; + Url = url; + AppId = appId; + PagePath = pagePath; + } + /// + /// 创建一个默认引用文献 + /// + /// 引用文献样式的标题 + /// 引用文献样式的引用文案 + /// + public static WebhookTemplateCardQuoteArea Default(string title, string quoteText = null) + { + Check.NotNullOrWhiteSpace(title, nameof(title)); + + return new WebhookTemplateCardQuoteArea(title, quoteText: quoteText); + } + /// + /// 创建一个跳转链接的引用文献 + /// + /// 引用文献样式的标题 + /// 点击跳转的url + /// 引用文献样式的引用文案 + /// + public static WebhookTemplateCardQuoteArea Link(string title, string url, string quoteText = null) + { + Check.NotNullOrWhiteSpace(title, nameof(title)); + Check.NotNullOrWhiteSpace(url, nameof(url)); + + return new WebhookTemplateCardQuoteArea(title, 1, url, quoteText: quoteText); + } + /// + /// 创建一个跳转小程序的引用文献 + /// + /// 引用文献样式的标题 + /// 跳转链接的小程序的appid + /// 跳转链接的小程序的pagepath + /// 引用文献样式的引用文案 + /// + public static WebhookTemplateCardQuoteArea MiniProgram(string title, string appId, string pagePath, string quoteText = null) + { + Check.NotNullOrWhiteSpace(title, nameof(title)); + Check.NotNullOrWhiteSpace(appId, nameof(appId)); + Check.NotNullOrWhiteSpace(pagePath, nameof(pagePath)); + + return new WebhookTemplateCardQuoteArea(title, 2, appId: appId, pagePath: pagePath, quoteText: quoteText); + } +} diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardSource.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardSource.cs new file mode 100644 index 000000000..322dec87b --- /dev/null +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardSource.cs @@ -0,0 +1,81 @@ +using JetBrains.Annotations; +using Newtonsoft.Json; +using System.Text.Json.Serialization; + +namespace LINGYUN.Abp.WeChat.Work.Messages.Models; +/// +/// 卡片来源样式信息 +/// +public class WebhookTemplateCardSource +{ + /// + /// 来源图片的url + /// + [CanBeNull] + [JsonProperty("icon_url")] + [JsonPropertyName("icon_url")] + public string IconUrl { get; set; } + /// + /// 来源图片的描述,建议不超过13个字 + /// + [CanBeNull] + [JsonProperty("desc")] + [JsonPropertyName("desc")] + public string Description { get; set; } + /// + /// 来源文字的颜色,目前支持:0(默认) 灰色,1 黑色,2 红色,3 绿色 + /// + [CanBeNull] + [JsonProperty("desc_color")] + [JsonPropertyName("desc_color")] + public int? DescriptionColor { get; set; } + private WebhookTemplateCardSource( + string iconUrl = null, + string description = null, + int? descriptionColor = 0) + { + IconUrl = iconUrl; + Description = description; + DescriptionColor = descriptionColor; + } + /// + /// 创建一个灰色卡片来源样式 + /// + /// 来源图片的url + /// 来源图片的描述 + /// + public static WebhookTemplateCardSource Grey(string iconUrl, string description = null) + { + return new WebhookTemplateCardSource(iconUrl, description, 0); + } + /// + /// 创建一个黑色卡片来源样式 + /// + /// 来源图片的url + /// 来源图片的描述 + /// + public static WebhookTemplateCardSource Black(string iconUrl, string description = null) + { + return new WebhookTemplateCardSource(iconUrl, description, 1); + } + /// + /// 创建一个红色卡片来源样式 + /// + /// 来源图片的url + /// 来源图片的描述 + /// + public static WebhookTemplateCardSource Red(string iconUrl, string description = null) + { + return new WebhookTemplateCardSource(iconUrl, description, 2); + } + /// + /// 创建一个绿色卡片来源样式 + /// + /// 来源图片的url + /// 来源图片的描述 + /// + public static WebhookTemplateCardSource Green(string iconUrl, string description = null) + { + return new WebhookTemplateCardSource(iconUrl, description, 3); + } +} diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardVerticalContent.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardVerticalContent.cs similarity index 86% rename from aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardVerticalContent.cs rename to aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardVerticalContent.cs index be8035b28..3301e0a33 100644 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardVerticalContent.cs +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardVerticalContent.cs @@ -6,7 +6,7 @@ namespace LINGYUN.Abp.WeChat.Work.Messages.Models; /// /// 卡片二级垂直内容 /// -public class TemplateCardVerticalContent +public class WebhookTemplateCardVerticalContent { /// /// 卡片二级标题,建议不超过26个字 @@ -27,7 +27,7 @@ public class TemplateCardVerticalContent /// /// 卡片二级标题 /// 二级普通文本 - public TemplateCardVerticalContent(string title, string description = null) + public WebhookTemplateCardVerticalContent(string title, string description = null) { Title = title; Description = description; diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTextNoticeCardMessage.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTextNoticeCardMessage.cs index 706b6536e..24e208f0b 100644 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTextNoticeCardMessage.cs +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTextNoticeCardMessage.cs @@ -23,7 +23,7 @@ public class WebhookTextNoticeCardMessage : WebhookTemplateCardMessage [CanBeNull] [JsonProperty("emphasis_content")] [JsonPropertyName("emphasis_content")] - public TemplateCardEmphasisContent EmphasisContent { get; set; } + public WebhookTemplateCardEmphasisContent EmphasisContent { get; set; } /// /// 创建一个Webhook 文本通知模版卡片消息体 /// @@ -37,14 +37,14 @@ public class WebhookTextNoticeCardMessage : WebhookTemplateCardMessage /// 跳转指引样式的列表,列表长度不超过3 /// public WebhookTextNoticeCardMessage( - TemplateCardAction action, - TemplateCardMainTitle mainTitle = null, + WebhookTemplateCardAction action, + WebhookTemplateCardMainTitle mainTitle = null, string subTitleText = null, - TemplateCardEmphasisContent emphasisContent = null, - TemplateCardSource source = null, - TemplateCardQuoteArea quoteArea = null, - List horizontalContents = null, - List jumps = null) + WebhookTemplateCardEmphasisContent emphasisContent = null, + WebhookTemplateCardSource source = null, + WebhookTemplateCardQuoteArea quoteArea = null, + List horizontalContents = null, + List jumps = null) : base("text_notice", action, mainTitle, source, quoteArea, horizontalContents, jumps) { MainTitle = mainTitle; diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/README.md b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/README.md index ccbd8eb6d..90f1bb428 100644 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/README.md +++ b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/README.md @@ -26,19 +26,19 @@ public class Demo "693a91f6-7xxx-4bc4-97a0-0ec2sifa5aaa", new WeChatWorkWebhookTemplateCardMessage( new WebhookTextNoticeCardMessage( - TemplateCardAction.Link("https://developer.work.weixin.qq.com/document/path/99110"), - new TemplateCardMainTitle("请假通过通知", "您的请假申请已通过,请前往查看!"), - source: TemplateCardSource.Black("https://wwcdn.weixin.qq.com/node/wework/images/wecom-logo.a61830413b.svg", "企业微信"), - horizontalContents: new List + WebhookTemplateCardAction.Link("https://developer.work.weixin.qq.com/document/path/99110"), + new WebhookTemplateCardMainTitle("请假通过通知", "您的请假申请已通过,请前往查看!"), + source: WebhookTemplateCardSource.Black("https://wwcdn.weixin.qq.com/node/wework/images/wecom-logo.a61830413b.svg", "企业微信"), + horizontalContents: new List { - TemplateCardHorizontalContent.Default("审批单号", "QJ20251000000136"), - TemplateCardHorizontalContent.Default("请假日期", "2025/10/01-2025/10/10"), - TemplateCardHorizontalContent.Default("通过时间", "2025-10-01 15:30:00"), - TemplateCardHorizontalContent.Default("审批备注", "做好考勤及交接事项"), + WebhookTemplateCardHorizontalContent.Default("审批单号", "QJ20251000000136"), + WebhookTemplateCardHorizontalContent.Default("请假日期", "2025/10/01-2025/10/10"), + WebhookTemplateCardHorizontalContent.Default("通过时间", "2025-10-01 15:30:00"), + WebhookTemplateCardHorizontalContent.Default("审批备注", "做好考勤及交接事项"), }, - jumps: new List + jumps: new List { - TemplateCardJump.Link("去OA查看", "https://developer.work.weixin.qq.com/document/path/99110") + WebhookTemplateCardJump.Link("去OA查看", "https://developer.work.weixin.qq.com/document/path/99110") }))); } } diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardAction.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardAction.cs deleted file mode 100644 index fd40a9fd4..000000000 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardAction.cs +++ /dev/null @@ -1,31 +0,0 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; -using System.Text.Json.Serialization; - -namespace LINGYUN.Abp.WeChat.Work.Messages.Templates; -/// -/// 卡片操作按钮 -/// -public class TemplateCardAction -{ - public TemplateCardAction(string key, string text) - { - Key = key; - Text = text; - } - - /// - /// 操作key值,用户点击后,会产生回调事件将本参数作为EventKey返回,回调事件会带上该key值,最长支持1024字节,不可重复 - /// - [NotNull] - [JsonProperty("key")] - [JsonPropertyName("key")] - public string Key { get; set; } - /// - /// 操作的描述文案 - /// - [NotNull] - [JsonProperty("text")] - [JsonPropertyName("text")] - public string Text { get; set; } -} \ No newline at end of file diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardHorizontalContent.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardHorizontalContent.cs deleted file mode 100644 index 8b2e68687..000000000 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardHorizontalContent.cs +++ /dev/null @@ -1,93 +0,0 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; -using System.Text.Json.Serialization; - -namespace LINGYUN.Abp.WeChat.Work.Messages.Templates; -/// -/// 二级标题+文本 -/// -public class TemplateCardHorizontalContent -{ - public static TemplateCardHorizontalContent None(string keyName, string value = "") - { - return new TemplateCardHorizontalContent( - keyName, 0, value); - } - - public static TemplateCardHorizontalContent FromUrl(string keyName, string url, string value = "") - { - return new TemplateCardHorizontalContent( - keyName, 1, value, url); - } - - public static TemplateCardHorizontalContent FromMedia(string keyName, string mediaId, string value = "") - { - return new TemplateCardHorizontalContent( - keyName, 2, value, mediaId: mediaId); - } - - public static TemplateCardHorizontalContent FromUser(string keyName, string userId, string value = "") - { - return new TemplateCardHorizontalContent( - keyName, 3, value, userId: userId); - } - - public TemplateCardHorizontalContent( - string keyName, - byte type = 0, - string value = "", - string url = "", - string mediaId = "", - string userId = "") - { - Type = type; - KeyName = keyName; - Value = value; - Url = url; - MediaId = mediaId; - UserId = userId; - } - - /// - /// 链接类型,0或不填代表不是链接,1 代表跳转url,2 代表下载附件,3 代表点击跳转成员详情 - /// - [CanBeNull] - [JsonProperty("type")] - [JsonPropertyName("type")] - public byte Type { get; } - /// - /// 二级标题,建议不超过5个字 - /// - [NotNull] - [JsonProperty("keyname")] - [JsonPropertyName("keyname")] - public string KeyName { get; set; } - /// - /// 二级文本,如果horizontal_content_list.type是2,该字段代表文件名称(要包含文件类型),建议不超过30个字,(支持id转译) - /// - [CanBeNull] - [JsonProperty("value")] - [JsonPropertyName("value")] - public string Value { get; set; } - /// - /// 链接跳转的url,horizontal_content_list.type是1时必填 - /// - [CanBeNull] - [JsonProperty("url")] - [JsonPropertyName("url")] - public string Url { get; set; } - /// - /// 附件的media_id,horizontal_content_list.type是2时必填 - /// - [CanBeNull] - [JsonProperty("media_id")] - [JsonPropertyName("media_id")] - public string MediaId { get; set; } - /// - /// 成员详情的userid,horizontal_content_list.type是3时必填 - /// - [CanBeNull] - [JsonProperty("userid")] - [JsonPropertyName("userid")] - public string UserId { get; set; } -} diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardJump.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardJump.cs deleted file mode 100644 index 94b04d81c..000000000 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardJump.cs +++ /dev/null @@ -1,62 +0,0 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.Json.Serialization; - -namespace LINGYUN.Abp.WeChat.Work.Messages.Templates; -/// -/// 跳转指引样式 -/// -public class TemplateCardJump -{ - public TemplateCardJump(string title, string url) - { - Type = 1; - Url = url; - Title = title; - } - public TemplateCardJump(string title, string appid, string pagePath) - { - Type = 2; - AppId = appid; - PagePath = pagePath; - Title = title; - } - /// - /// 跳转链接类型,0或不填代表不是链接,1 代表跳转url,2 代表跳转小程序 - /// - [CanBeNull] - [JsonProperty("type")] - [JsonPropertyName("type")] - public byte Type { get; } - /// - /// 跳转链接样式的文案内容,建议不超过18个字 - /// - [NotNull] - [JsonProperty("title")] - [JsonPropertyName("title")] - public string Title { get; set; } - /// - /// 跳转链接的url,jump_list.type是1时必填 - /// - [CanBeNull] - [JsonProperty("url")] - [JsonPropertyName("url")] - public string Url { get; set; } - /// - /// 跳转链接的小程序的appid,必须是与当前应用关联的小程序,jump_list.type是2时必填 - /// - [CanBeNull] - [JsonProperty("appid")] - [JsonPropertyName("appid")] - public string AppId { get; set; } - /// - /// 跳转链接的小程序的pagepath,jump_list.type是2时选填 - /// - [CanBeNull] - [JsonProperty("pagepath")] - [JsonPropertyName("pagepath")] - public string PagePath { get; set; } -} diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardMainTitle.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardMainTitle.cs deleted file mode 100644 index 0bf2b873c..000000000 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardMainTitle.cs +++ /dev/null @@ -1,33 +0,0 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; -using System.Text.Json.Serialization; - -namespace LINGYUN.Abp.WeChat.Work.Messages.Templates; -/// -/// 卡票标题 -/// -public class TemplateCardMainTitle -{ - public TemplateCardMainTitle( - string title = "", - string description = "") - { - Title = title; - Description = description; - } - - /// - /// 一级标题,建议不超过36个字,文本通知型卡片本字段非必填,但不可本字段和sub_title_text都不填,(支持id转译) - /// - [CanBeNull] - [JsonProperty("title")] - [JsonPropertyName("title")] - public string Title { get; set; } - /// - /// 标题辅助信息,建议不超过44个字,(支持id转译) - /// - [CanBeNull] - [JsonProperty("desc")] - [JsonPropertyName("desc")] - public string Description { get; set; } -} diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardQuoteArea.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardQuoteArea.cs deleted file mode 100644 index 1549ceabb..000000000 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardQuoteArea.cs +++ /dev/null @@ -1,68 +0,0 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; -using System.Text.Json.Serialization; - -namespace LINGYUN.Abp.WeChat.Work.Messages.Templates; -/// -/// 引用文献样式 -/// -public class TemplateCardQuoteArea -{ - public TemplateCardQuoteArea(string url, string title = "", string text = "") - { - Type = 1; - Url = url; - Title = title; - Text = text; - } - public TemplateCardQuoteArea(string appid, string pagePath, string title = "", string text = "") - { - Type = 2; - AppId = appid; - PagePath = pagePath; - Title = title; - Text = text; - } - /// - /// 引用文献样式区域点击事件,0或不填代表没有点击事件,1 代表跳转url,2 代表跳转小程序 - /// - [CanBeNull] - [JsonProperty("type")] - [JsonPropertyName("type")] - public byte Type { get; } - /// - /// 点击跳转的url,quote_area.type是1时必填 - /// - [CanBeNull] - [JsonProperty("url")] - [JsonPropertyName("url")] - public string Url { get; set; } - /// - /// 点击跳转的小程序的appid,必须是与当前应用关联的小程序,quote_area.type是2时必填 - /// - [CanBeNull] - [JsonProperty("appid")] - [JsonPropertyName("appid")] - public string AppId { get; set; } - /// - /// 点击跳转的小程序的pagepath,quote_area.type是2时选填 - /// - [CanBeNull] - [JsonProperty("pagepath")] - [JsonPropertyName("pagepath")] - public string PagePath { get; set; } - /// - /// 引用文献样式的标题 - /// - [CanBeNull] - [JsonProperty("title")] - [JsonPropertyName("title")] - public string Title { get; set; } - /// - /// 引用文献样式的引用文案 - /// - [CanBeNull] - [JsonProperty("quote_text")] - [JsonPropertyName("quote_text")] - public string Text { get; set; } -} diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardSource.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardSource.cs deleted file mode 100644 index 0eee1cb87..000000000 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardSource.cs +++ /dev/null @@ -1,52 +0,0 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; -using System.Text.Json.Serialization; - -namespace LINGYUN.Abp.WeChat.Work.Messages.Templates; -/// -/// 来源文字颜色 -/// -public enum DescriptionColor -{ - Gray = 0, - Black = 1, - Red = 2, - Green = 3, -} -/// -/// 卡片来源样式信息 -/// -public class TemplateCardSource -{ - public TemplateCardSource( - string iconUrl = "", - string description = "", - DescriptionColor descriptionColor = DescriptionColor.Gray) - { - IconUrl = iconUrl; - Description = description; - DescriptionColor = descriptionColor; - } - - /// - /// 来源图片的url,来源图片的尺寸建议为72*72 - /// - [CanBeNull] - [JsonProperty("icon_url")] - [JsonPropertyName("icon_url")] - public string IconUrl { get; set; } - /// - /// 来源图片的描述,建议不超过20个字,(支持id转译) - /// - [CanBeNull] - [JsonProperty("desc")] - [JsonPropertyName("desc")] - public string Description { get; set; } - /// - /// 来源文字的颜色,目前支持:0(默认) 灰色,1 黑色,2 红色,3 绿色 - /// - [CanBeNull] - [JsonProperty("desc_color")] - [JsonPropertyName("desc_color")] - public DescriptionColor DescriptionColor { get; set; } -} diff --git a/aspnet-core/tests/LINGYUN.Abp.WeChat.Work.Tests/LINGYUN/Abp/WeChat/Work/AbpWeChatWorkTestModule.cs b/aspnet-core/tests/LINGYUN.Abp.WeChat.Work.Tests/LINGYUN/Abp/WeChat/Work/AbpWeChatWorkTestModule.cs index 430f0b033..bb888cb1f 100644 --- a/aspnet-core/tests/LINGYUN.Abp.WeChat.Work.Tests/LINGYUN/Abp/WeChat/Work/AbpWeChatWorkTestModule.cs +++ b/aspnet-core/tests/LINGYUN.Abp.WeChat.Work.Tests/LINGYUN/Abp/WeChat/Work/AbpWeChatWorkTestModule.cs @@ -56,6 +56,10 @@ public class AbpWeChatWorkTestModule : AbpModule { return true.ToString(); }); + options.Map(WeChatWorkFeatureNames.Webhook.Enable, (feature) => + { + return true.ToString(); + }); }); } } diff --git a/aspnet-core/tests/LINGYUN.Abp.WeChat.Work.Tests/LINGYUN/Abp/WeChat/Work/Message/WeChatWorkMessageSender_Tests.cs b/aspnet-core/tests/LINGYUN.Abp.WeChat.Work.Tests/LINGYUN/Abp/WeChat/Work/Message/WeChatWorkMessageSender_Tests.cs index 39570eb6a..c1049b8b7 100644 --- a/aspnet-core/tests/LINGYUN.Abp.WeChat.Work.Tests/LINGYUN/Abp/WeChat/Work/Message/WeChatWorkMessageSender_Tests.cs +++ b/aspnet-core/tests/LINGYUN.Abp.WeChat.Work.Tests/LINGYUN/Abp/WeChat/Work/Message/WeChatWorkMessageSender_Tests.cs @@ -1,6 +1,5 @@ using LINGYUN.Abp.WeChat.Work.Messages; using LINGYUN.Abp.WeChat.Work.Messages.Models; -using LINGYUN.Abp.WeChat.Work.Messages.Templates; using System; using System.Collections.Generic; using System.Threading.Tasks; @@ -104,4 +103,29 @@ public class WeChatWorkMessageSender_Tests : AbpWeChatWorkTestBase var response = await Sender.SendAsync(message); response.IsSuccessed.ShouldBeTrue(); } + + [Theory] + [InlineData("cee71c5b-6e6a-478a-aafe-fe612198ffbd")] + public async Task Send_Webhook_Text_Template_Card_Message_Test(string webhookKey) + { + var message = new WeChatWorkWebhookTemplateCardMessage( + new WebhookTextNoticeCardMessage( + WebhookTemplateCardAction.Link("https://developer.work.weixin.qq.com/document/path/99110"), + new WebhookTemplateCardMainTitle("请假通过通知", "您的请假申请已通过,请前往查看!"), + source: WebhookTemplateCardSource.Black("https://wwcdn.weixin.qq.com/node/wework/images/wecom-logo.a61830413b.svg", "企业微信"), + horizontalContents: new List + { + WebhookTemplateCardHorizontalContent.Default("审批单号", "QJ20251000000136"), + WebhookTemplateCardHorizontalContent.Default("请假日期", "2025/10/01-2025/10/10"), + WebhookTemplateCardHorizontalContent.Default("通过时间", "2025-10-01 15:30:00"), + WebhookTemplateCardHorizontalContent.Default("审批备注", "做好考勤及交接事项"), + }, + jumps: new List + { + WebhookTemplateCardJump.Link("去OA查看", "https://developer.work.weixin.qq.com/document/path/99110") + })); + + var response = await Sender.SendAsync(webhookKey, message); + response.IsSuccessed.ShouldBeTrue(); + } }