Browse Source

fix(webchat): fix wecom unit test

pull/1348/head
colin 4 months ago
parent
commit
0726ef98e0
  1. 2
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCard.cs
  2. 76
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardAction.cs
  3. 2
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardActionMenu.cs
  4. 2
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardCardAction.cs
  5. 22
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardEmphasisContent.cs
  6. 122
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardHorizontalContent.cs
  7. 79
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardJump.cs
  8. 24
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardMainTitle.cs
  9. 85
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardQuoteArea.cs
  10. 75
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardSource.cs
  11. 2
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TextTemplateCard.cs
  12. 2
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WeChatWorkTemplateCardMessage.cs
  13. 60
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookNewsNoticeCardMessage.cs
  14. 75
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardAction.cs
  15. 26
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardEmphasisContent.cs
  16. 123
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardHorizontalContent.cs
  17. 4
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardImage.cs
  18. 12
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardImageTextArea.cs
  19. 99
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardJump.cs
  20. 35
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardMainTitle.cs
  21. 24
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardMessage.cs
  22. 111
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardQuoteArea.cs
  23. 81
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardSource.cs
  24. 4
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTemplateCardVerticalContent.cs
  25. 16
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/WebhookTextNoticeCardMessage.cs
  26. 20
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/README.md
  27. 31
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardAction.cs
  28. 93
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardHorizontalContent.cs
  29. 62
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardJump.cs
  30. 33
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardMainTitle.cs
  31. 68
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardQuoteArea.cs
  32. 52
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardSource.cs
  33. 4
      aspnet-core/tests/LINGYUN.Abp.WeChat.Work.Tests/LINGYUN/Abp/WeChat/Work/AbpWeChatWorkTestModule.cs
  34. 26
      aspnet-core/tests/LINGYUN.Abp.WeChat.Work.Tests/LINGYUN/Abp/WeChat/Work/Message/WeChatWorkMessageSender_Tests.cs

2
aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCard.cs → 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
{

76
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;
/// <summary>
/// 卡片的点击跳转事件
/// 卡片操作按钮
/// </summary>
public class TemplateCardAction
{
/// <summary>
/// 卡片跳转类型,1 代表跳转url,2 代表打开小程序。text_notice模版卡片中该字段取值范围为[1,2]
/// </summary>
[NotNull]
[JsonProperty("type")]
[JsonPropertyName("type")]
public int Type { get; set; }
/// <summary>
/// 跳转链接的url,type是1时必填
/// </summary>
[CanBeNull]
[JsonProperty("url")]
[JsonPropertyName("url")]
public string Url { get; set; }
/// <summary>
/// 点击跳转的小程序的appid,type是2时必填
/// </summary>
[CanBeNull]
[JsonProperty("appid")]
[JsonPropertyName("appid")]
public string AppId { get; set; }
/// <summary>
/// 点击跳转的小程序的pagepath,type是2时选填
/// </summary>
[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;
}
/// <summary>
/// 创建一个跳转链接卡片事件
/// 操作key值,用户点击后,会产生回调事件将本参数作为EventKey返回,回调事件会带上该key值,最长支持1024字节,不可重复
/// </summary>
/// <param name="url">跳转链接的url</param>
/// <returns></returns>
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; }
/// <summary>
/// 创建一个跳转小程序卡片事件
/// 操作的描述文案
/// </summary>
/// <param name="appId">小程序的appid</param>
/// <param name="pagePath">小程序的pagePath</param>
/// <returns></returns>
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; }
}

2
aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardActionMenu.cs → 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;
/// <summary>
/// 卡片右上角更多操作按钮
/// </summary>

2
aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardCardAction.cs → 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;
/// <summary>
/// 整体卡片的点击跳转事件
/// </summary>

22
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;
/// </summary>
public class TemplateCardEmphasisContent
{
public TemplateCardEmphasisContent(
string title = "",
string description = "")
{
Title = title;
Description = description;
}
/// <summary>
/// 关键数据样式的数据内容,建议不超过10个字
/// 关键数据样式的数据内容,建议不超过14个字
/// </summary>
[CanBeNull]
[JsonProperty("title")]
[JsonPropertyName("title")]
public string Title { get; set; }
/// <summary>
/// 关键数据样式的数据描述内容,建议不超过15个字
/// 关键数据样式的数据描述内容,建议不超过22个字
/// </summary>
[CanBeNull]
[JsonProperty("desc")]
[JsonPropertyName("desc")]
public string Description { get; set; }
/// <summary>
/// 创建一个关键数据样式
/// </summary>
/// <param name="title">关键数据样式的数据内容</param>
/// <param name="description">关键数据样式的数据描述内容</param>
public TemplateCardEmphasisContent(string title, string description = null)
{
Title = title;
Description = description;
}
}

122
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;
/// <summary>
@ -9,13 +8,53 @@ namespace LINGYUN.Abp.WeChat.Work.Messages.Models;
/// </summary>
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;
}
/// <summary>
/// 模版卡片的二级标题信息内容支持的类型,1是url,2是文件附件,3 代表点击跳转成员详情
/// 链接类型,0或不填代表不是链接,1 代表跳转url,2 代表下载附件,3 代表点击跳转成员详情
/// </summary>
[CanBeNull]
[JsonProperty("type")]
[JsonPropertyName("type")]
public int? Type { get; set; }
public byte Type { get; }
/// <summary>
/// 二级标题,建议不超过5个字
/// </summary>
@ -24,100 +63,31 @@ public class TemplateCardHorizontalContent
[JsonPropertyName("keyname")]
public string KeyName { get; set; }
/// <summary>
/// 二级文本,如果type是2,该字段代表文件名称(要包含文件类型),建议不超过26个字
/// 二级文本,如果horizontal_content_list.type是2,该字段代表文件名称(要包含文件类型),建议不超过30个字,(支持id转译)
/// </summary>
[CanBeNull]
[JsonProperty("value")]
[JsonPropertyName("value")]
public string Value { get; set; }
/// <summary>
/// 链接跳转的url,type是1时必填
/// 链接跳转的url,horizontal_content_list.type是1时必填
/// </summary>
[CanBeNull]
[JsonProperty("url")]
[JsonPropertyName("url")]
public string Url { get; set; }
/// <summary>
/// 附件的media_id,type是2时必填
/// 附件的media_id,horizontal_content_list.type是2时必填
/// </summary>
[CanBeNull]
[JsonProperty("media_id")]
[JsonPropertyName("media_id")]
public string MediaId { get; set; }
/// <summary>
/// 成员详情的userid,type是3时必填
/// 成员详情的userid,horizontal_content_list.type是3时必填
/// </summary>
[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;
}
/// <summary>
/// 创建一个默认二级标题+文本
/// </summary>
/// <param name="keyName">二级标题</param>
/// <param name="value">二级文本</param>
/// <returns></returns>
public static TemplateCardHorizontalContent Default(string keyName, string value = null)
{
Check.NotNullOrWhiteSpace(keyName, nameof(keyName));
return new TemplateCardHorizontalContent(keyName, value: value);
}
/// <summary>
/// 创建一个跳转链接的二级标题+文本
/// </summary>
/// <param name="keyName">二级标题</param>
/// <param name="url">链接跳转的url</param>
/// <param name="value">二级文本</param>
/// <returns></returns>
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);
}
/// <summary>
/// 创建一个引用文件的二级标题+文本
/// </summary>
/// <param name="keyName">二级标题</param>
/// <param name="fileName">文件名称</param>
/// <param name="mediaId">附件的mediaId</param>
/// <returns></returns>
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);
}
/// <summary>
/// 创建一个成员详情的二级标题+文本
/// </summary>
/// <param name="keyName">二级标题</param>
/// <param name="userId">成员的userid</param>
/// <returns></returns>
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);
}
}

79
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;
/// <summary>
@ -9,91 +11,52 @@ namespace LINGYUN.Abp.WeChat.Work.Messages.Models;
/// </summary>
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;
}
/// <summary>
/// 跳转链接类型,0或不填代表不是链接,1 代表跳转url,2 代表跳转小程序
/// </summary>
[CanBeNull]
[JsonProperty("type")]
[JsonPropertyName("type")]
public int? Type { get; set; }
public byte Type { get; }
/// <summary>
/// 跳转链接样式的文案内容,建议不超过13个字
/// 跳转链接样式的文案内容,建议不超过18个字
/// </summary>
[NotNull]
[JsonProperty("title")]
[JsonPropertyName("title")]
public string Title { get; set; }
/// <summary>
/// 跳转链接的url,type是1时必填
/// 跳转链接的url,jump_list.type是1时必填
/// </summary>
[CanBeNull]
[JsonProperty("url")]
[JsonPropertyName("url")]
public string Url { get; set; }
/// <summary>
/// 点击跳转的小程序的appid,type是2时必填
/// 跳转链接的小程序的appid,必须是与当前应用关联的小程序,jump_list.type是2时必填
/// </summary>
[CanBeNull]
[JsonProperty("appid")]
[JsonPropertyName("appid")]
public string AppId { get; set; }
/// <summary>
/// 点击跳转的小程序的pagepath,type是2时选填
/// 跳转链接的小程序的pagepath,jump_list.type是2时选填
/// </summary>
[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;
}
/// <summary>
/// 创建一个默认指引样式
/// </summary>
/// <param name="title">跳转链接样式的文案内容</param>
/// <returns></returns>
public static TemplateCardJump Default(string title)
{
Check.NotNullOrWhiteSpace(title, nameof(title));
return new TemplateCardJump(title);
}
/// <summary>
/// 创建一个跳转链接的指引样式
/// </summary>
/// <param name="title">跳转链接样式的文案内容</param>
/// <param name="url">跳转链接的url</param>
/// <returns></returns>
public static TemplateCardJump Link(string title, string url)
{
Check.NotNullOrWhiteSpace(title, nameof(title));
Check.NotNullOrWhiteSpace(url, nameof(url));
return new TemplateCardJump(title, 1, url);
}
/// <summary>
/// 创建一个跳转小程序的指引样式
/// </summary>
/// <param name="title">跳转链接样式的文案内容</param>
/// <param name="appId">跳转链接的小程序的appid</param>
/// <param name="pagePath">跳转链接的小程序的pagepath</param>
/// <returns></returns>
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);
}
}

24
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;
/// <summary>
/// 模版卡片的主要内容
/// 卡票标题
/// </summary>
public class TemplateCardMainTitle
{
public TemplateCardMainTitle(
string title = "",
string description = "")
{
Title = title;
Description = description;
}
/// <summary>
/// 一级标题,建议不超过26个字。模版卡片主要内容的一级标题main_title.title和二级普通文本sub_title_text必须有一项填写
/// 一级标题,建议不超过36个字,文本通知型卡片本字段非必填,但不可本字段和sub_title_text都不填,(支持id转译)
/// </summary>
[CanBeNull]
[JsonProperty("title")]
[JsonPropertyName("title")]
public string Title { get; set; }
/// <summary>
/// 标题辅助信息,建议不超过30个字
/// 标题辅助信息,建议不超过44个字,(支持id转译)
/// </summary>
[CanBeNull]
[JsonProperty("desc")]
[JsonPropertyName("desc")]
public string Description { get; set; }
/// <summary>
/// 创建一个模版卡片的主要内容
/// </summary>
/// <param name="title">一级标题</param>
/// <param name="description">标题辅助信息</param>
public TemplateCardMainTitle(string title, string description = null)
{
Title = title;
Description = description;
}
}

85
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;
/// <summary>
/// 引用文献
/// 引用文献样式
/// </summary>
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;
}
/// <summary>
/// 引用文献样式区域点击事件,0或不填代表没有点击事件,1 代表跳转url,2 代表跳转小程序
/// </summary>
[CanBeNull]
[JsonProperty("type")]
[JsonPropertyName("type")]
public int? Type { get; set; }
public byte Type { get; }
/// <summary>
/// 点击跳转的url,type是1时必填
/// 点击跳转的url,quote_area.type是1时必填
/// </summary>
[CanBeNull]
[JsonProperty("url")]
[JsonPropertyName("url")]
public string Url { get; set; }
/// <summary>
/// 点击跳转的小程序的appid,type是2时必填
/// 点击跳转的小程序的appid,必须是与当前应用关联的小程序,quote_area.type是2时必填
/// </summary>
[CanBeNull]
[JsonProperty("appid")]
[JsonPropertyName("appid")]
public string AppId { get; set; }
/// <summary>
/// 点击跳转的小程序的pagepath,type是2时选填
/// 点击跳转的小程序的pagepath,quote_area.type是2时选填
/// </summary>
[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;
}
/// <summary>
/// 创建一个默认引用文献
/// </summary>
/// <param name="title">引用文献样式的标题</param>
/// <param name="quoteText">引用文献样式的引用文案</param>
/// <returns></returns>
public static TemplateCardQuoteArea Default(string title, string quoteText = null)
{
Check.NotNullOrWhiteSpace(title, nameof(title));
return new TemplateCardQuoteArea(title, quoteText: quoteText);
}
/// <summary>
/// 创建一个跳转链接的引用文献
/// </summary>
/// <param name="title">引用文献样式的标题</param>
/// <param name="url">点击跳转的url</param>
/// <param name="quoteText">引用文献样式的引用文案</param>
/// <returns></returns>
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);
}
/// <summary>
/// 创建一个跳转小程序的引用文献
/// </summary>
/// <param name="title">引用文献样式的标题</param>
/// <param name="appId">跳转链接的小程序的appid</param>
/// <param name="pagePath">跳转链接的小程序的pagepath</param>
/// <param name="quoteText">引用文献样式的引用文案</param>
/// <returns></returns>
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; }
}

75
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;
/// <summary>
/// 来源文字颜色
/// </summary>
public enum DescriptionColor
{
Gray = 0,
Black = 1,
Red = 2,
Green = 3,
}
/// <summary>
/// 卡片来源样式信息
/// </summary>
public class TemplateCardSource
{
public TemplateCardSource(
string iconUrl = "",
string description = "",
DescriptionColor descriptionColor = DescriptionColor.Gray)
{
IconUrl = iconUrl;
Description = description;
DescriptionColor = descriptionColor;
}
/// <summary>
/// 来源图片的url
/// 来源图片的url,来源图片的尺寸建议为72*72
/// </summary>
[CanBeNull]
[JsonProperty("icon_url")]
[JsonPropertyName("icon_url")]
public string IconUrl { get; set; }
/// <summary>
/// 来源图片的描述,建议不超过13个字
/// 来源图片的描述,建议不超过20个字,(支持id转译)
/// </summary>
[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;
}
/// <summary>
/// 创建一个灰色卡片来源样式
/// </summary>
/// <param name="iconUrl">来源图片的url</param>
/// <param name="description">来源图片的描述</param>
/// <returns></returns>
public static TemplateCardSource Grey(string iconUrl, string description = null)
{
return new TemplateCardSource(iconUrl, description, 0);
}
/// <summary>
/// 创建一个黑色卡片来源样式
/// </summary>
/// <param name="iconUrl">来源图片的url</param>
/// <param name="description">来源图片的描述</param>
/// <returns></returns>
public static TemplateCardSource Black(string iconUrl, string description = null)
{
return new TemplateCardSource(iconUrl, description, 1);
}
/// <summary>
/// 创建一个红色卡片来源样式
/// </summary>
/// <param name="iconUrl">来源图片的url</param>
/// <param name="description">来源图片的描述</param>
/// <returns></returns>
public static TemplateCardSource Red(string iconUrl, string description = null)
{
return new TemplateCardSource(iconUrl, description, 2);
}
/// <summary>
/// 创建一个绿色卡片来源样式
/// </summary>
/// <param name="iconUrl">来源图片的url</param>
/// <param name="description">来源图片的描述</param>
/// <returns></returns>
public static TemplateCardSource Green(string iconUrl, string description = null)
{
return new TemplateCardSource(iconUrl, description, 3);
}
public DescriptionColor DescriptionColor { get; set; }
}

2
aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TextTemplateCard.cs → 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;
/// <summary>
/// 文本模板卡片消息
/// </summary>

2
aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/WeChatWorkTemplateCardMessage.cs → 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;
/// <summary>
/// 企业微信模板卡片消息
/// </summary>

60
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;
/// </summary>
public class WebhookNewsNoticeCardMessage : WebhookTemplateCardMessage
{
/// <summary>
/// 图片样式
/// </summary>
[NotNull]
[JsonProperty("aspect_ratio")]
[JsonPropertyName("aspect_ratio")]
public WebhookTemplateCardImage CardImage { get; set; }
/// <summary>
/// 左图右文样式
/// </summary>
[CanBeNull]
[JsonProperty("image_text_area")]
[JsonPropertyName("image_text_area")]
public WebhookTemplateCardImageTextArea ImageTextArea { get; set; }
/// <summary>
/// 卡片二级垂直内容,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过4
/// </summary>
[CanBeNull]
[JsonProperty("vertical_content_list")]
[JsonPropertyName("vertical_content_list")]
public List<WebhookTemplateCardVerticalContent> VerticalContents { get; set; }
/// <summary>
/// 创建一个Webhook 图文展示模版卡片消息体
/// </summary>
@ -25,15 +46,15 @@ public class WebhookNewsNoticeCardMessage : WebhookTemplateCardMessage
/// <param name="jumps">跳转指引样式的列表,列表长度不超过3</param>
/// <exception cref="ArgumentException"></exception>
public WebhookNewsNoticeCardMessage(
TemplateCardImage cardImage,
TemplateCardAction action,
TemplateCardMainTitle mainTitle,
TemplateCardImageTextArea imageTextArea = null,
TemplateCardSource source = null,
TemplateCardQuoteArea quoteArea = null,
List<TemplateCardHorizontalContent> horizontalContents = null,
List<TemplateCardVerticalContent> verticalContents = null,
List<TemplateCardJump> jumps = null)
WebhookTemplateCardImage cardImage,
WebhookTemplateCardAction action,
WebhookTemplateCardMainTitle mainTitle,
WebhookTemplateCardImageTextArea imageTextArea = null,
WebhookTemplateCardSource source = null,
WebhookTemplateCardQuoteArea quoteArea = null,
List<WebhookTemplateCardHorizontalContent> horizontalContents = null,
List<WebhookTemplateCardVerticalContent> verticalContents = null,
List<WebhookTemplateCardJump> 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!");
}
}
/// <summary>
/// 图片样式
/// </summary>
[NotNull]
[JsonProperty("aspect_ratio")]
[JsonPropertyName("aspect_ratio")]
public TemplateCardImage CardImage { get; set; }
/// <summary>
/// 左图右文样式
/// </summary>
[CanBeNull]
[JsonProperty("image_text_area")]
[JsonPropertyName("image_text_area")]
public TemplateCardImageTextArea ImageTextArea { get; set; }
/// <summary>
/// 卡片二级垂直内容,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过4
/// </summary>
[CanBeNull]
[JsonProperty("vertical_content_list")]
[JsonPropertyName("vertical_content_list")]
public List<TemplateCardVerticalContent> VerticalContents { get; set; }
}

75
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;
/// <summary>
/// 卡片的点击跳转事件
/// </summary>
public class WebhookTemplateCardAction
{
/// <summary>
/// 卡片跳转类型,1 代表跳转url,2 代表打开小程序。text_notice模版卡片中该字段取值范围为[1,2]
/// </summary>
[NotNull]
[JsonProperty("type")]
[JsonPropertyName("type")]
public int Type { get; set; }
/// <summary>
/// 跳转链接的url,type是1时必填
/// </summary>
[CanBeNull]
[JsonProperty("url")]
[JsonPropertyName("url")]
public string Url { get; set; }
/// <summary>
/// 点击跳转的小程序的appid,type是2时必填
/// </summary>
[CanBeNull]
[JsonProperty("appid")]
[JsonPropertyName("appid")]
public string AppId { get; set; }
/// <summary>
/// 点击跳转的小程序的pagepath,type是2时选填
/// </summary>
[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;
}
/// <summary>
/// 创建一个跳转链接卡片事件
/// </summary>
/// <param name="url">跳转链接的url</param>
/// <returns></returns>
public static WebhookTemplateCardAction Link(string url)
{
Check.NotNullOrWhiteSpace(url, nameof(url));
return new WebhookTemplateCardAction(1, url);
}
/// <summary>
/// 创建一个跳转小程序卡片事件
/// </summary>
/// <param name="appId">小程序的appid</param>
/// <param name="pagePath">小程序的pagePath</param>
/// <returns></returns>
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);
}
}

26
aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardEmphasisContent.cs → 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;
/// <summary>
/// 关键数据样式
/// </summary>
public class TemplateCardEmphasisContent
public class WebhookTemplateCardEmphasisContent
{
public TemplateCardEmphasisContent(
string title = "",
string description = "")
{
Title = title;
Description = description;
}
/// <summary>
/// 关键数据样式的数据内容,建议不超过14个字
/// 关键数据样式的数据内容,建议不超过10个字
/// </summary>
[CanBeNull]
[JsonProperty("title")]
[JsonPropertyName("title")]
public string Title { get; set; }
/// <summary>
/// 关键数据样式的数据描述内容,建议不超过22个字
/// 关键数据样式的数据描述内容,建议不超过15个字
/// </summary>
[CanBeNull]
[JsonProperty("desc")]
[JsonPropertyName("desc")]
public string Description { get; set; }
/// <summary>
/// 创建一个关键数据样式
/// </summary>
/// <param name="title">关键数据样式的数据内容</param>
/// <param name="description">关键数据样式的数据描述内容</param>
public WebhookTemplateCardEmphasisContent(string title, string description = null)
{
Title = title;
Description = description;
}
}

123
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;
/// <summary>
/// 二级标题+文本
/// </summary>
public class WebhookTemplateCardHorizontalContent
{
/// <summary>
/// 模版卡片的二级标题信息内容支持的类型,1是url,2是文件附件,3 代表点击跳转成员详情
/// </summary>
[CanBeNull]
[JsonProperty("type")]
[JsonPropertyName("type")]
public int? Type { get; set; }
/// <summary>
/// 二级标题,建议不超过5个字
/// </summary>
[NotNull]
[JsonProperty("keyname")]
[JsonPropertyName("keyname")]
public string KeyName { get; set; }
/// <summary>
/// 二级文本,如果type是2,该字段代表文件名称(要包含文件类型),建议不超过26个字
/// </summary>
[CanBeNull]
[JsonProperty("value")]
[JsonPropertyName("value")]
public string Value { get; set; }
/// <summary>
/// 链接跳转的url,type是1时必填
/// </summary>
[CanBeNull]
[JsonProperty("url")]
[JsonPropertyName("url")]
public string Url { get; set; }
/// <summary>
/// 附件的media_id,type是2时必填
/// </summary>
[CanBeNull]
[JsonProperty("media_id")]
[JsonPropertyName("media_id")]
public string MediaId { get; set; }
/// <summary>
/// 成员详情的userid,type是3时必填
/// </summary>
[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;
}
/// <summary>
/// 创建一个默认二级标题+文本
/// </summary>
/// <param name="keyName">二级标题</param>
/// <param name="value">二级文本</param>
/// <returns></returns>
public static WebhookTemplateCardHorizontalContent Default(string keyName, string value = null)
{
Check.NotNullOrWhiteSpace(keyName, nameof(keyName));
return new WebhookTemplateCardHorizontalContent(keyName, value: value);
}
/// <summary>
/// 创建一个跳转链接的二级标题+文本
/// </summary>
/// <param name="keyName">二级标题</param>
/// <param name="url">链接跳转的url</param>
/// <param name="value">二级文本</param>
/// <returns></returns>
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);
}
/// <summary>
/// 创建一个引用文件的二级标题+文本
/// </summary>
/// <param name="keyName">二级标题</param>
/// <param name="fileName">文件名称</param>
/// <param name="mediaId">附件的mediaId</param>
/// <returns></returns>
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);
}
/// <summary>
/// 创建一个成员详情的二级标题+文本
/// </summary>
/// <param name="keyName">二级标题</param>
/// <param name="userId">成员的userid</param>
/// <returns></returns>
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);
}
}

4
aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardImage.cs → 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;
/// <summary>
/// 图片样式
/// </summary>
public class TemplateCardImage
public class WebhookTemplateCardImage
{
/// <summary>
/// 图片的url
@ -27,7 +27,7 @@ public class TemplateCardImage
/// </summary>
/// <param name="url">图片的url</param>
/// <param name="aspectRatio">图片的宽高比,不填该参数默认1.3</param>
public TemplateCardImage(string url, float? aspectRatio = 1.3f)
public WebhookTemplateCardImage(string url, float? aspectRatio = 1.3f)
{
Url = url;
AspectRatio = aspectRatio;

12
aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardImageTextArea.cs → 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;
/// <summary>
/// 左图右文样式
/// </summary>
public class TemplateCardImageTextArea
public class WebhookTemplateCardImageTextArea
{
/// <summary>
/// 左图右文样式区域点击事件,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
/// <param name="title">左图右文样式的标题</param>
/// <param name="description">左图右文样式的描述</param>
/// <returns></returns>
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);
}
/// <summary>
/// 创建一个跳转小程序左图右文样式
@ -103,7 +103,7 @@ public class TemplateCardImageTextArea
/// <param name="title">左图右文样式的标题</param>
/// <param name="description">左图右文样式的描述</param>
/// <returns></returns>
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);
}
}

99
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;
/// <summary>
/// 跳转指引样式
/// </summary>
public class WebhookTemplateCardJump
{
/// <summary>
/// 跳转链接类型,0或不填代表不是链接,1 代表跳转url,2 代表跳转小程序
/// </summary>
[CanBeNull]
[JsonProperty("type")]
[JsonPropertyName("type")]
public int? Type { get; set; }
/// <summary>
/// 跳转链接样式的文案内容,建议不超过13个字
/// </summary>
[NotNull]
[JsonProperty("title")]
[JsonPropertyName("title")]
public string Title { get; set; }
/// <summary>
/// 跳转链接的url,type是1时必填
/// </summary>
[CanBeNull]
[JsonProperty("url")]
[JsonPropertyName("url")]
public string Url { get; set; }
/// <summary>
/// 点击跳转的小程序的appid,type是2时必填
/// </summary>
[CanBeNull]
[JsonProperty("appid")]
[JsonPropertyName("appid")]
public string AppId { get; set; }
/// <summary>
/// 点击跳转的小程序的pagepath,type是2时选填
/// </summary>
[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;
}
/// <summary>
/// 创建一个默认指引样式
/// </summary>
/// <param name="title">跳转链接样式的文案内容</param>
/// <returns></returns>
public static WebhookTemplateCardJump Default(string title)
{
Check.NotNullOrWhiteSpace(title, nameof(title));
return new WebhookTemplateCardJump(title);
}
/// <summary>
/// 创建一个跳转链接的指引样式
/// </summary>
/// <param name="title">跳转链接样式的文案内容</param>
/// <param name="url">跳转链接的url</param>
/// <returns></returns>
public static WebhookTemplateCardJump Link(string title, string url)
{
Check.NotNullOrWhiteSpace(title, nameof(title));
Check.NotNullOrWhiteSpace(url, nameof(url));
return new WebhookTemplateCardJump(title, 1, url);
}
/// <summary>
/// 创建一个跳转小程序的指引样式
/// </summary>
/// <param name="title">跳转链接样式的文案内容</param>
/// <param name="appId">跳转链接的小程序的appid</param>
/// <param name="pagePath">跳转链接的小程序的pagepath</param>
/// <returns></returns>
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);
}
}

35
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;
/// <summary>
/// 模版卡片的主要内容
/// </summary>
public class WebhookTemplateCardMainTitle
{
/// <summary>
/// 一级标题,建议不超过26个字。模版卡片主要内容的一级标题main_title.title和二级普通文本sub_title_text必须有一项填写
/// </summary>
[CanBeNull]
[JsonProperty("title")]
[JsonPropertyName("title")]
public string Title { get; set; }
/// <summary>
/// 标题辅助信息,建议不超过30个字
/// </summary>
[CanBeNull]
[JsonProperty("desc")]
[JsonPropertyName("desc")]
public string Description { get; set; }
/// <summary>
/// 创建一个模版卡片的主要内容
/// </summary>
/// <param name="title">一级标题</param>
/// <param name="description">标题辅助信息</param>
public WebhookTemplateCardMainTitle(string title, string description = null)
{
Title = title;
Description = description;
}
}

24
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; }
/// <summary>
/// 模版卡片的主要内容,包括一级标题和标题辅助信息
/// </summary>
[CanBeNull]
[JsonProperty("main_title")]
[JsonPropertyName("main_title")]
public TemplateCardMainTitle MainTitle { get; set; }
public WebhookTemplateCardMainTitle MainTitle { get; set; }
/// <summary>
/// 引用文献样式,建议不与关键数据共用
/// </summary>
[CanBeNull]
[JsonProperty("quote_area")]
[JsonPropertyName("quote_area")]
public TemplateCardQuoteArea QuoteArea { get; set; }
public WebhookTemplateCardQuoteArea QuoteArea { get; set; }
/// <summary>
/// 二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6
/// </summary>
[CanBeNull]
[JsonProperty("horizontal_content_list")]
[JsonPropertyName("horizontal_content_list")]
public List<TemplateCardHorizontalContent> HorizontalContents { get; set; }
public List<WebhookTemplateCardHorizontalContent> HorizontalContents { get; set; }
/// <summary>
/// 跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过3
/// </summary>
[CanBeNull]
[JsonProperty("jump_list")]
[JsonPropertyName("jump_list")]
public List<TemplateCardJump> Jumps { get; set; }
public List<WebhookTemplateCardJump> Jumps { get; set; }
/// <summary>
/// 整体卡片的点击跳转事件,text_notice模版卡片中该字段为必填项
/// </summary>
[CanBeNull]
[JsonProperty("card_action")]
[JsonPropertyName("card_action")]
public TemplateCardAction Action { get; set; }
public WebhookTemplateCardAction Action { get; set; }
/// <summary>
/// 创建一个Webhook模板卡片消息体
/// </summary>
@ -72,12 +72,12 @@ public abstract class WebhookTemplateCardMessage
/// <exception cref="ArgumentException"></exception>
protected WebhookTemplateCardMessage(
string cardType,
TemplateCardAction action,
TemplateCardMainTitle mainTitle = null,
TemplateCardSource source = null,
TemplateCardQuoteArea quoteArea = null,
List<TemplateCardHorizontalContent> horizontalContents = null,
List<TemplateCardJump> jumps = null)
WebhookTemplateCardAction action,
WebhookTemplateCardMainTitle mainTitle = null,
WebhookTemplateCardSource source = null,
WebhookTemplateCardQuoteArea quoteArea = null,
List<WebhookTemplateCardHorizontalContent> horizontalContents = null,
List<WebhookTemplateCardJump> jumps = null)
{
CardType = Check.NotNullOrWhiteSpace(cardType, nameof(cardType));
Action = Check.NotNull(action, nameof(action));

111
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;
/// <summary>
/// 引用文献
/// </summary>
public class WebhookTemplateCardQuoteArea
{
/// <summary>
/// 引用文献样式区域点击事件,0或不填代表没有点击事件,1 代表跳转url,2 代表跳转小程序
/// </summary>
[CanBeNull]
[JsonProperty("type")]
[JsonPropertyName("type")]
public int? Type { get; set; }
/// <summary>
/// 点击跳转的url,type是1时必填
/// </summary>
[CanBeNull]
[JsonProperty("url")]
[JsonPropertyName("url")]
public string Url { get; set; }
/// <summary>
/// 点击跳转的小程序的appid,type是2时必填
/// </summary>
[CanBeNull]
[JsonProperty("appid")]
[JsonPropertyName("appid")]
public string AppId { get; set; }
/// <summary>
/// 点击跳转的小程序的pagepath,type是2时选填
/// </summary>
[CanBeNull]
[JsonProperty("pagepath")]
[JsonPropertyName("pagepath")]
public string PagePath { get; set; }
/// <summary>
/// 引用文献样式的标题
/// </summary>
[CanBeNull]
[JsonProperty("title")]
[JsonPropertyName("title")]
public string Title { get; set; }
/// <summary>
/// 引用文献样式的引用文案
/// </summary>
[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;
}
/// <summary>
/// 创建一个默认引用文献
/// </summary>
/// <param name="title">引用文献样式的标题</param>
/// <param name="quoteText">引用文献样式的引用文案</param>
/// <returns></returns>
public static WebhookTemplateCardQuoteArea Default(string title, string quoteText = null)
{
Check.NotNullOrWhiteSpace(title, nameof(title));
return new WebhookTemplateCardQuoteArea(title, quoteText: quoteText);
}
/// <summary>
/// 创建一个跳转链接的引用文献
/// </summary>
/// <param name="title">引用文献样式的标题</param>
/// <param name="url">点击跳转的url</param>
/// <param name="quoteText">引用文献样式的引用文案</param>
/// <returns></returns>
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);
}
/// <summary>
/// 创建一个跳转小程序的引用文献
/// </summary>
/// <param name="title">引用文献样式的标题</param>
/// <param name="appId">跳转链接的小程序的appid</param>
/// <param name="pagePath">跳转链接的小程序的pagepath</param>
/// <param name="quoteText">引用文献样式的引用文案</param>
/// <returns></returns>
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);
}
}

81
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;
/// <summary>
/// 卡片来源样式信息
/// </summary>
public class WebhookTemplateCardSource
{
/// <summary>
/// 来源图片的url
/// </summary>
[CanBeNull]
[JsonProperty("icon_url")]
[JsonPropertyName("icon_url")]
public string IconUrl { get; set; }
/// <summary>
/// 来源图片的描述,建议不超过13个字
/// </summary>
[CanBeNull]
[JsonProperty("desc")]
[JsonPropertyName("desc")]
public string Description { get; set; }
/// <summary>
/// 来源文字的颜色,目前支持:0(默认) 灰色,1 黑色,2 红色,3 绿色
/// </summary>
[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;
}
/// <summary>
/// 创建一个灰色卡片来源样式
/// </summary>
/// <param name="iconUrl">来源图片的url</param>
/// <param name="description">来源图片的描述</param>
/// <returns></returns>
public static WebhookTemplateCardSource Grey(string iconUrl, string description = null)
{
return new WebhookTemplateCardSource(iconUrl, description, 0);
}
/// <summary>
/// 创建一个黑色卡片来源样式
/// </summary>
/// <param name="iconUrl">来源图片的url</param>
/// <param name="description">来源图片的描述</param>
/// <returns></returns>
public static WebhookTemplateCardSource Black(string iconUrl, string description = null)
{
return new WebhookTemplateCardSource(iconUrl, description, 1);
}
/// <summary>
/// 创建一个红色卡片来源样式
/// </summary>
/// <param name="iconUrl">来源图片的url</param>
/// <param name="description">来源图片的描述</param>
/// <returns></returns>
public static WebhookTemplateCardSource Red(string iconUrl, string description = null)
{
return new WebhookTemplateCardSource(iconUrl, description, 2);
}
/// <summary>
/// 创建一个绿色卡片来源样式
/// </summary>
/// <param name="iconUrl">来源图片的url</param>
/// <param name="description">来源图片的描述</param>
/// <returns></returns>
public static WebhookTemplateCardSource Green(string iconUrl, string description = null)
{
return new WebhookTemplateCardSource(iconUrl, description, 3);
}
}

4
aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Models/TemplateCardVerticalContent.cs → 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;
/// <summary>
/// 卡片二级垂直内容
/// </summary>
public class TemplateCardVerticalContent
public class WebhookTemplateCardVerticalContent
{
/// <summary>
/// 卡片二级标题,建议不超过26个字
@ -27,7 +27,7 @@ public class TemplateCardVerticalContent
/// </summary>
/// <param name="title">卡片二级标题</param>
/// <param name="description">二级普通文本</param>
public TemplateCardVerticalContent(string title, string description = null)
public WebhookTemplateCardVerticalContent(string title, string description = null)
{
Title = title;
Description = description;

16
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; }
/// <summary>
/// 创建一个Webhook 文本通知模版卡片消息体
/// </summary>
@ -37,14 +37,14 @@ public class WebhookTextNoticeCardMessage : WebhookTemplateCardMessage
/// <param name="jumps">跳转指引样式的列表,列表长度不超过3</param>
/// <exception cref="ArgumentException"></exception>
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<TemplateCardHorizontalContent> horizontalContents = null,
List<TemplateCardJump> jumps = null)
WebhookTemplateCardEmphasisContent emphasisContent = null,
WebhookTemplateCardSource source = null,
WebhookTemplateCardQuoteArea quoteArea = null,
List<WebhookTemplateCardHorizontalContent> horizontalContents = null,
List<WebhookTemplateCardJump> jumps = null)
: base("text_notice", action, mainTitle, source, quoteArea, horizontalContents, jumps)
{
MainTitle = mainTitle;

20
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<TemplateCardHorizontalContent>
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>
{
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<TemplateCardJump>
jumps: new List<WebhookTemplateCardJump>
{
TemplateCardJump.Link("去OA查看", "https://developer.work.weixin.qq.com/document/path/99110")
WebhookTemplateCardJump.Link("去OA查看", "https://developer.work.weixin.qq.com/document/path/99110")
})));
}
}

31
aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardAction.cs

@ -1,31 +0,0 @@
using JetBrains.Annotations;
using Newtonsoft.Json;
using System.Text.Json.Serialization;
namespace LINGYUN.Abp.WeChat.Work.Messages.Templates;
/// <summary>
/// 卡片操作按钮
/// </summary>
public class TemplateCardAction
{
public TemplateCardAction(string key, string text)
{
Key = key;
Text = text;
}
/// <summary>
/// 操作key值,用户点击后,会产生回调事件将本参数作为EventKey返回,回调事件会带上该key值,最长支持1024字节,不可重复
/// </summary>
[NotNull]
[JsonProperty("key")]
[JsonPropertyName("key")]
public string Key { get; set; }
/// <summary>
/// 操作的描述文案
/// </summary>
[NotNull]
[JsonProperty("text")]
[JsonPropertyName("text")]
public string Text { get; set; }
}

93
aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardHorizontalContent.cs

@ -1,93 +0,0 @@
using JetBrains.Annotations;
using Newtonsoft.Json;
using System.Text.Json.Serialization;
namespace LINGYUN.Abp.WeChat.Work.Messages.Templates;
/// <summary>
/// 二级标题+文本
/// </summary>
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;
}
/// <summary>
/// 链接类型,0或不填代表不是链接,1 代表跳转url,2 代表下载附件,3 代表点击跳转成员详情
/// </summary>
[CanBeNull]
[JsonProperty("type")]
[JsonPropertyName("type")]
public byte Type { get; }
/// <summary>
/// 二级标题,建议不超过5个字
/// </summary>
[NotNull]
[JsonProperty("keyname")]
[JsonPropertyName("keyname")]
public string KeyName { get; set; }
/// <summary>
/// 二级文本,如果horizontal_content_list.type是2,该字段代表文件名称(要包含文件类型),建议不超过30个字,(支持id转译)
/// </summary>
[CanBeNull]
[JsonProperty("value")]
[JsonPropertyName("value")]
public string Value { get; set; }
/// <summary>
/// 链接跳转的url,horizontal_content_list.type是1时必填
/// </summary>
[CanBeNull]
[JsonProperty("url")]
[JsonPropertyName("url")]
public string Url { get; set; }
/// <summary>
/// 附件的media_id,horizontal_content_list.type是2时必填
/// </summary>
[CanBeNull]
[JsonProperty("media_id")]
[JsonPropertyName("media_id")]
public string MediaId { get; set; }
/// <summary>
/// 成员详情的userid,horizontal_content_list.type是3时必填
/// </summary>
[CanBeNull]
[JsonProperty("userid")]
[JsonPropertyName("userid")]
public string UserId { get; set; }
}

62
aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardJump.cs

@ -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;
/// <summary>
/// 跳转指引样式
/// </summary>
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;
}
/// <summary>
/// 跳转链接类型,0或不填代表不是链接,1 代表跳转url,2 代表跳转小程序
/// </summary>
[CanBeNull]
[JsonProperty("type")]
[JsonPropertyName("type")]
public byte Type { get; }
/// <summary>
/// 跳转链接样式的文案内容,建议不超过18个字
/// </summary>
[NotNull]
[JsonProperty("title")]
[JsonPropertyName("title")]
public string Title { get; set; }
/// <summary>
/// 跳转链接的url,jump_list.type是1时必填
/// </summary>
[CanBeNull]
[JsonProperty("url")]
[JsonPropertyName("url")]
public string Url { get; set; }
/// <summary>
/// 跳转链接的小程序的appid,必须是与当前应用关联的小程序,jump_list.type是2时必填
/// </summary>
[CanBeNull]
[JsonProperty("appid")]
[JsonPropertyName("appid")]
public string AppId { get; set; }
/// <summary>
/// 跳转链接的小程序的pagepath,jump_list.type是2时选填
/// </summary>
[CanBeNull]
[JsonProperty("pagepath")]
[JsonPropertyName("pagepath")]
public string PagePath { get; set; }
}

33
aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardMainTitle.cs

@ -1,33 +0,0 @@
using JetBrains.Annotations;
using Newtonsoft.Json;
using System.Text.Json.Serialization;
namespace LINGYUN.Abp.WeChat.Work.Messages.Templates;
/// <summary>
/// 卡票标题
/// </summary>
public class TemplateCardMainTitle
{
public TemplateCardMainTitle(
string title = "",
string description = "")
{
Title = title;
Description = description;
}
/// <summary>
/// 一级标题,建议不超过36个字,文本通知型卡片本字段非必填,但不可本字段和sub_title_text都不填,(支持id转译)
/// </summary>
[CanBeNull]
[JsonProperty("title")]
[JsonPropertyName("title")]
public string Title { get; set; }
/// <summary>
/// 标题辅助信息,建议不超过44个字,(支持id转译)
/// </summary>
[CanBeNull]
[JsonProperty("desc")]
[JsonPropertyName("desc")]
public string Description { get; set; }
}

68
aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardQuoteArea.cs

@ -1,68 +0,0 @@
using JetBrains.Annotations;
using Newtonsoft.Json;
using System.Text.Json.Serialization;
namespace LINGYUN.Abp.WeChat.Work.Messages.Templates;
/// <summary>
/// 引用文献样式
/// </summary>
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;
}
/// <summary>
/// 引用文献样式区域点击事件,0或不填代表没有点击事件,1 代表跳转url,2 代表跳转小程序
/// </summary>
[CanBeNull]
[JsonProperty("type")]
[JsonPropertyName("type")]
public byte Type { get; }
/// <summary>
/// 点击跳转的url,quote_area.type是1时必填
/// </summary>
[CanBeNull]
[JsonProperty("url")]
[JsonPropertyName("url")]
public string Url { get; set; }
/// <summary>
/// 点击跳转的小程序的appid,必须是与当前应用关联的小程序,quote_area.type是2时必填
/// </summary>
[CanBeNull]
[JsonProperty("appid")]
[JsonPropertyName("appid")]
public string AppId { get; set; }
/// <summary>
/// 点击跳转的小程序的pagepath,quote_area.type是2时选填
/// </summary>
[CanBeNull]
[JsonProperty("pagepath")]
[JsonPropertyName("pagepath")]
public string PagePath { get; set; }
/// <summary>
/// 引用文献样式的标题
/// </summary>
[CanBeNull]
[JsonProperty("title")]
[JsonPropertyName("title")]
public string Title { get; set; }
/// <summary>
/// 引用文献样式的引用文案
/// </summary>
[CanBeNull]
[JsonProperty("quote_text")]
[JsonPropertyName("quote_text")]
public string Text { get; set; }
}

52
aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Messages/Templates/TemplateCardSource.cs

@ -1,52 +0,0 @@
using JetBrains.Annotations;
using Newtonsoft.Json;
using System.Text.Json.Serialization;
namespace LINGYUN.Abp.WeChat.Work.Messages.Templates;
/// <summary>
/// 来源文字颜色
/// </summary>
public enum DescriptionColor
{
Gray = 0,
Black = 1,
Red = 2,
Green = 3,
}
/// <summary>
/// 卡片来源样式信息
/// </summary>
public class TemplateCardSource
{
public TemplateCardSource(
string iconUrl = "",
string description = "",
DescriptionColor descriptionColor = DescriptionColor.Gray)
{
IconUrl = iconUrl;
Description = description;
DescriptionColor = descriptionColor;
}
/// <summary>
/// 来源图片的url,来源图片的尺寸建议为72*72
/// </summary>
[CanBeNull]
[JsonProperty("icon_url")]
[JsonPropertyName("icon_url")]
public string IconUrl { get; set; }
/// <summary>
/// 来源图片的描述,建议不超过20个字,(支持id转译)
/// </summary>
[CanBeNull]
[JsonProperty("desc")]
[JsonPropertyName("desc")]
public string Description { get; set; }
/// <summary>
/// 来源文字的颜色,目前支持:0(默认) 灰色,1 黑色,2 红色,3 绿色
/// </summary>
[CanBeNull]
[JsonProperty("desc_color")]
[JsonPropertyName("desc_color")]
public DescriptionColor DescriptionColor { get; set; }
}

4
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();
});
});
}
}

26
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>
{
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>
{
WebhookTemplateCardJump.Link("去OA查看", "https://developer.work.weixin.qq.com/document/path/99110")
}));
var response = await Sender.SendAsync(webhookKey, message);
response.IsSuccessed.ShouldBeTrue();
}
}

Loading…
Cancel
Save