Class WeChatWorkTemplateCardBuilder

java.lang.Object
com.bytedesk.core.webhook.channel.WeChatWorkTemplateCardBuilder

public class WeChatWorkTemplateCardBuilder extends Object
企业微信模板卡片构建器 用于构建文本通知和图文展示模板卡片
  • Field Details

  • Constructor Details

    • WeChatWorkTemplateCardBuilder

      public WeChatWorkTemplateCardBuilder()
  • Method Details

    • cardType

      public WeChatWorkTemplateCardBuilder cardType(String cardType)
      设置卡片类型
      Parameters:
      cardType - 卡片类型:text_notice(文本通知) 或 news_notice(图文展示)
      Returns:
      构建器实例
    • source

      public WeChatWorkTemplateCardBuilder source(String iconUrl, String desc, Integer descColor)
      设置来源信息
      Parameters:
      iconUrl - 来源图片URL
      desc - 来源描述
      descColor - 来源文字颜色:0(默认灰色),1(黑色),2(红色),3(绿色)
      Returns:
      构建器实例
    • mainTitle

      public WeChatWorkTemplateCardBuilder mainTitle(String title, String desc)
      设置主标题
      Parameters:
      title - 一级标题
      desc - 标题辅助信息
      Returns:
      构建器实例
    • emphasisContent

      public WeChatWorkTemplateCardBuilder emphasisContent(String title, String desc)
      设置关键数据样式
      Parameters:
      title - 关键数据内容
      desc - 关键数据描述
      Returns:
      构建器实例
    • quoteArea

      public WeChatWorkTemplateCardBuilder quoteArea(Integer type, String url, String appid, String pagepath, String title, String quoteText)
      设置引用文献样式
      Parameters:
      type - 点击事件类型:0(无点击事件),1(跳转URL),2(跳转小程序)
      url - 跳转URL(type=1时必填)
      appid - 小程序appid(type=2时必填)
      pagepath - 小程序pagepath(type=2时选填)
      title - 引用文献标题
      quoteText - 引用文献内容
      Returns:
      构建器实例
    • subTitleText

      public WeChatWorkTemplateCardBuilder subTitleText(String subTitleText)
      设置二级普通文本
      Parameters:
      subTitleText - 二级普通文本
      Returns:
      构建器实例
    • cardImage

      public WeChatWorkTemplateCardBuilder cardImage(String url, Float aspectRatio)
      设置图片样式(仅图文展示卡片支持)
      Parameters:
      url - 图片URL
      aspectRatio - 图片宽高比
      Returns:
      构建器实例
    • imageTextArea

      public WeChatWorkTemplateCardBuilder imageTextArea(Integer type, String url, String appid, String pagepath, String title, String desc, String imageUrl)
      设置左图右文样式(仅图文展示卡片支持)
      Parameters:
      type - 点击事件类型:0(无点击事件),1(跳转URL),2(跳转小程序)
      url - 跳转URL(type=1时必填)
      appid - 小程序appid(type=2时必填)
      pagepath - 小程序pagepath(type=2时选填)
      title - 标题
      desc - 描述
      imageUrl - 图片URL
      Returns:
      构建器实例
    • verticalContentList

      public WeChatWorkTemplateCardBuilder verticalContentList(List<Map<String,String>> verticalContents)
      设置卡片二级垂直内容(仅图文展示卡片支持)
      Parameters:
      verticalContents - 垂直内容列表
      Returns:
      构建器实例
    • addVerticalContent

      public WeChatWorkTemplateCardBuilder addVerticalContent(String title, String desc)
      添加一个垂直内容项
      Parameters:
      title - 标题
      desc - 描述
      Returns:
      构建器实例
    • horizontalContentList

      public WeChatWorkTemplateCardBuilder horizontalContentList(List<Map<String,Object>> horizontalContents)
      设置二级标题+文本列表
      Parameters:
      horizontalContents - 水平内容列表
      Returns:
      构建器实例
    • addHorizontalContent

      public WeChatWorkTemplateCardBuilder addHorizontalContent(String keyname, String value, Integer type, String url, String mediaId, String userid)
      添加一个水平内容项
      Parameters:
      keyname - 二级标题
      value - 二级文本
      type - 内容类型:1(URL),2(文件附件),3(成员详情)
      url - 链接URL(type=1时必填)
      mediaId - 附件mediaId(type=2时必填)
      userid - 成员userid(type=3时必填)
      Returns:
      构建器实例
    • jumpList

      public WeChatWorkTemplateCardBuilder jumpList(List<Map<String,Object>> jumpList)
      设置跳转指引样式列表
      Parameters:
      jumpList - 跳转列表
      Returns:
      构建器实例
    • addJumpItem

      public WeChatWorkTemplateCardBuilder addJumpItem(String title, Integer type, String url, String appid, String pagepath)
      添加一个跳转项
      Parameters:
      title - 跳转链接文案
      type - 跳转链接类型:0(不是链接),1(跳转URL),2(跳转小程序)
      url - 跳转URL(type=1时必填)
      appid - 小程序appid(type=2时必填)
      pagepath - 小程序pagepath(type=2时选填)
      Returns:
      构建器实例
    • cardAction

      public WeChatWorkTemplateCardBuilder cardAction(Integer type, String url, String appid, String pagepath)
      设置整体卡片点击跳转事件
      Parameters:
      type - 卡片跳转类型:1(跳转URL),2(打开小程序)
      url - 跳转URL(type=1时必填)
      appid - 小程序appid(type=2时必填)
      pagepath - 小程序pagepath(type=2时选填)
      Returns:
      构建器实例
    • build

      public Map<String,Object> build()
      构建模板卡片
      Returns:
      模板卡片Map
    • textNotice

      public static WeChatWorkTemplateCardBuilder textNotice()
      创建文本通知模板卡片构建器
      Returns:
      构建器实例
    • newsNotice

      public static WeChatWorkTemplateCardBuilder newsNotice()
      创建图文展示模板卡片构建器
      Returns:
      构建器实例