🎨 【企业微信】重构规范化模板卡片消息部分字段命名,并补充card_image的支持

This commit is contained in:
Binary Wang 2022-04-02 17:32:53 +08:00
parent 1df2dda136
commit 2cb8331030
3 changed files with 226 additions and 205 deletions

View File

@ -71,9 +71,7 @@ public class WxCpMessage implements Serializable {
private String taskId; private String taskId;
private List<TaskCardButton> taskButtons = new ArrayList<>(); private List<TaskCardButton> taskButtons = new ArrayList<>();
/** // 模板型卡片特有属性
* 模板型卡片特有属性
*/
/** /**
* 模板卡片类型文本通知型卡片填写 text_notice, * 模板卡片类型文本通知型卡片填写 text_notice,
* 图文展示型卡片此处填写 news_notice, * 图文展示型卡片此处填写 news_notice,
@ -81,62 +79,62 @@ public class WxCpMessage implements Serializable {
* 投票选择型卡片填写vote_interaction, * 投票选择型卡片填写vote_interaction,
* 多项选择型卡片填写 multiple_interaction * 多项选择型卡片填写 multiple_interaction
*/ */
private String card_type; private String cardType;
/** /**
* 卡片来源样式信息不需要来源样式可不填写 * 卡片来源样式信息不需要来源样式可不填写
* 来源图片的url * 来源图片的url
*/ */
private String source_icon_url; private String sourceIconUrl;
/** /**
* 卡片来源样式信息不需要来源样式可不填写 * 卡片来源样式信息不需要来源样式可不填写
* 来源图片的描述建议不超过20个字 * 来源图片的描述建议不超过20个字
*/ */
private String source_desc; private String sourceDesc;
/** /**
* 一级标题建议不超过36个字 * 一级标题建议不超过36个字
*/ */
private String main_title_title; private String mainTitleTitle;
/** /**
* 标题辅助信息建议不超过44个字 * 标题辅助信息建议不超过44个字
*/ */
private String main_title_desc; private String mainTitleDesc;
/** /**
* 图文展示型的卡片必须有图片字段 * 图文展示型的卡片必须有图片字段
* 图片的url. * 图片的url.
*/ */
private String card_image_url; private String cardImageUrl;
/** /**
* 图片的宽高比宽高比要小于2.25大于1.3不填该参数默认1.3 * 图片的宽高比宽高比要小于2.25大于1.3不填该参数默认1.3
*/ */
private Float card_image_aspect_ratio; private Float cardImageAspectRatio;
/** /**
* 关键数据样式 * 关键数据样式
* 关键数据样式的数据内容建议不超过14个字 * 关键数据样式的数据内容建议不超过14个字
*/ */
private String emphasis_content_title; private String emphasisContentTitle;
/** /**
* 关键数据样式的数据描述内容建议不超过22个字 * 关键数据样式的数据描述内容建议不超过22个字
*/ */
private String emphasis_content_desc; private String emphasisContentDesc;
/** /**
* 二级普通文本建议不超过160个字 * 二级普通文本建议不超过160个字
*/ */
private String sub_title_text; private String subTitleText;
/** /**
* 卡片二级垂直内容该字段可为空数组但有数据的话需确认对应字段是否必填列表长度不超过4 * 卡片二级垂直内容该字段可为空数组但有数据的话需确认对应字段是否必填列表长度不超过4
*/ */
private List<VerticalContent> vertical_contents; private List<VerticalContent> verticalContents;
/** /**
* 二级标题+文本列表该字段可为空数组但有数据的话需确认对应字段是否必填列表长度不超过6 * 二级标题+文本列表该字段可为空数组但有数据的话需确认对应字段是否必填列表长度不超过6
*/ */
private List<HorizontalContent> horizontal_contents; private List<HorizontalContent> horizontalContents;
/** /**
* 跳转指引样式的列表该字段可为空数组但有数据的话需确认对应字段是否必填列表长度不超过3 * 跳转指引样式的列表该字段可为空数组但有数据的话需确认对应字段是否必填列表长度不超过3
@ -147,21 +145,21 @@ public class WxCpMessage implements Serializable {
* 整体卡片的点击跳转事件text_notice必填本字段 * 整体卡片的点击跳转事件text_notice必填本字段
* 跳转事件类型1 代表跳转url2 代表打开小程序text_notice卡片模版中该字段取值范围为[1,2] * 跳转事件类型1 代表跳转url2 代表打开小程序text_notice卡片模版中该字段取值范围为[1,2]
*/ */
private Integer card_action_type; private Integer cardActionType;
/** /**
* 跳转事件的urlcard_action.type是1时必填 * 跳转事件的urlcard_action.type是1时必填
*/ */
private String card_action_url; private String cardActionUrl;
/** /**
* 跳转事件的小程序的appid必须是与当前应用关联的小程序card_action.type是2时必填 * 跳转事件的小程序的appid必须是与当前应用关联的小程序card_action.type是2时必填
*/ */
private String card_action_appid; private String cardActionAppid;
/** /**
* 跳转事件的小程序的pagepathcard_action.type是2时选填 * 跳转事件的小程序的pagepathcard_action.type是2时选填
*/ */
private String card_action_pagepath; private String cardActionPagepath;
/** /**
* 按钮交互型卡片需指定 * 按钮交互型卡片需指定
@ -173,12 +171,12 @@ public class WxCpMessage implements Serializable {
* 投票选择型卡片需要指定 * 投票选择型卡片需要指定
* 选择题key值用户提交选项后会产生回调事件回调事件会带上该key值表示该题最长支持1024字节 * 选择题key值用户提交选项后会产生回调事件回调事件会带上该key值表示该题最长支持1024字节
*/ */
private String checkbox_question_key; private String checkboxQuestionKey;
/** /**
* 选择题模式单选0多选1不填默认0 * 选择题模式单选0多选1不填默认0
*/ */
private Integer checkbox_mode; private Integer checkboxMode;
/** /**
* 选项list选项个数不超过 20 最少1个 * 选项list选项个数不超过 20 最少1个
@ -189,11 +187,11 @@ public class WxCpMessage implements Serializable {
* 提交按钮样式 * 提交按钮样式
* 按钮文案建议不超过10个字不填默认为提交 * 按钮文案建议不超过10个字不填默认为提交
*/ */
private String submit_button_text; private String submitButtonText;
/** /**
* 提交按钮的key会产生回调事件将本参数作为EventKey返回最长支持1024字节 * 提交按钮的key会产生回调事件将本参数作为EventKey返回最长支持1024字节
*/ */
private String submit_button_key; private String submitButtonKey;
/** /**
* 下拉式的选择器列表multiple_interaction类型的卡片该字段不可为空一个消息最多支持 3 个选择器 * 下拉式的选择器列表multiple_interaction类型的卡片该字段不可为空一个消息最多支持 3 个选择器
*/ */
@ -472,64 +470,75 @@ public class WxCpMessage implements Serializable {
} }
case TEMPLATE_CARD: { case TEMPLATE_CARD: {
JsonObject template = new JsonObject(); JsonObject template = new JsonObject();
template.addProperty("card_type", this.getCard_type()); template.addProperty("card_type", this.getCardType());
if (StringUtils.isNotBlank(this.getSource_icon_url()) || StringUtils.isNotBlank(this.getSource_desc())) { if (StringUtils.isNotBlank(this.getSourceIconUrl()) || StringUtils.isNotBlank(this.getSourceDesc())) {
JsonObject source = new JsonObject(); JsonObject source = new JsonObject();
if (StringUtils.isNotBlank(this.getSource_icon_url())) { if (StringUtils.isNotBlank(this.getSourceIconUrl())) {
source.addProperty("icon_url", this.getSource_icon_url()); source.addProperty("icon_url", this.getSourceIconUrl());
} }
if (StringUtils.isNotBlank(this.getSource_desc())) { if (StringUtils.isNotBlank(this.getSourceDesc())) {
source.addProperty("desc", this.getSource_desc()); source.addProperty("desc", this.getSourceDesc());
} }
template.add("source", source); template.add("source", source);
} }
if (StringUtils.isNotBlank(this.getMain_title_title()) || StringUtils.isNotBlank(this.getMain_title_desc())) { if (StringUtils.isNotBlank(this.getMainTitleTitle()) || StringUtils.isNotBlank(this.getMainTitleDesc())) {
JsonObject main_title = new JsonObject(); JsonObject mainTitle = new JsonObject();
if (StringUtils.isNotBlank(this.getMain_title_title())) { if (StringUtils.isNotBlank(this.getMainTitleTitle())) {
main_title.addProperty("title", this.getMain_title_title()); mainTitle.addProperty("title", this.getMainTitleTitle());
} }
if (StringUtils.isNotBlank(this.getMain_title_desc())) { if (StringUtils.isNotBlank(this.getMainTitleDesc())) {
main_title.addProperty("desc", this.getMain_title_desc()); mainTitle.addProperty("desc", this.getMainTitleDesc());
} }
template.add("main_title", main_title); template.add("main_title", mainTitle);
} }
if (StringUtils.isNotBlank(this.getEmphasis_content_title()) || StringUtils.isNotBlank(this.getEmphasis_content_desc())) { if (StringUtils.isNotBlank(this.getCardImageUrl()) || this.getCardImageAspectRatio() != null) {
JsonObject emphasis_content = new JsonObject(); JsonObject cardImage = new JsonObject();
if (StringUtils.isNotBlank(this.getEmphasis_content_title())) { if (StringUtils.isNotBlank(this.getCardImageUrl())) {
emphasis_content.addProperty("title", this.getEmphasis_content_title()); cardImage.addProperty("url", this.getCardImageUrl());
} }
if (StringUtils.isNotBlank(this.getEmphasis_content_desc())) { if (null != this.getCardImageAspectRatio()) {
emphasis_content.addProperty("desc", this.getEmphasis_content_desc()); cardImage.addProperty("aspect_ratio", this.getCardImageAspectRatio());
} }
template.add("emphasis_content", emphasis_content); template.add("card_image", cardImage);
}
if (StringUtils.isNotBlank(this.getEmphasisContentTitle()) || StringUtils.isNotBlank(this.getEmphasisContentDesc())) {
JsonObject emphasisContent = new JsonObject();
if (StringUtils.isNotBlank(this.getEmphasisContentTitle())) {
emphasisContent.addProperty("title", this.getEmphasisContentTitle());
}
if (StringUtils.isNotBlank(this.getEmphasisContentDesc())) {
emphasisContent.addProperty("desc", this.getEmphasisContentDesc());
}
template.add("emphasis_content", emphasisContent);
} }
if (StringUtils.isNotBlank(this.getSub_title_text())) { if (StringUtils.isNotBlank(this.getSubTitleText())) {
template.addProperty("sub_title_text", this.getSub_title_text()); template.addProperty("sub_title_text", this.getSubTitleText());
} }
if (StringUtils.isNotBlank(this.getTaskId())) { if (StringUtils.isNotBlank(this.getTaskId())) {
template.addProperty("task_id", this.getTaskId()); template.addProperty("task_id", this.getTaskId());
} }
List<VerticalContent> verticalContents = this.getVertical_contents(); List<VerticalContent> verticalContents = this.getVerticalContents();
if (null != verticalContents && verticalContents.size() > 0) { if (null != verticalContents && !verticalContents.isEmpty()) {
JsonArray vContentJsonArray = new JsonArray(); JsonArray vContentJsonArray = new JsonArray();
for (VerticalContent vContent : this.getVertical_contents()) { for (VerticalContent vContent : this.getVerticalContents()) {
JsonObject tempObject = vContent.toJson(); JsonObject tempObject = vContent.toJson();
vContentJsonArray.add(tempObject); vContentJsonArray.add(tempObject);
} }
template.add("vertical_content_list", vContentJsonArray); template.add("vertical_content_list", vContentJsonArray);
} }
List<HorizontalContent> horizontalContents = this.getHorizontal_contents(); List<HorizontalContent> horizontalContents = this.getHorizontalContents();
if (null != horizontalContents && horizontalContents.size() > 0) { if (null != horizontalContents && !horizontalContents.isEmpty()) {
JsonArray hContentJsonArray = new JsonArray(); JsonArray hContentJsonArray = new JsonArray();
for (HorizontalContent hContent : this.getHorizontal_contents()) { for (HorizontalContent hContent : this.getHorizontalContents()) {
JsonObject tempObject = hContent.toJson(); JsonObject tempObject = hContent.toJson();
hContentJsonArray.add(tempObject); hContentJsonArray.add(tempObject);
} }
@ -537,7 +546,7 @@ public class WxCpMessage implements Serializable {
} }
List<TemplateCardJump> jumps = this.getJumps(); List<TemplateCardJump> jumps = this.getJumps();
if (null != jumps && jumps.size() > 0) { if (null != jumps && !jumps.isEmpty()) {
JsonArray jumpJsonArray = new JsonArray(); JsonArray jumpJsonArray = new JsonArray();
for (TemplateCardJump jump : this.getJumps()) { for (TemplateCardJump jump : this.getJumps()) {
JsonObject tempObject = jump.toJson(); JsonObject tempObject = jump.toJson();
@ -546,23 +555,23 @@ public class WxCpMessage implements Serializable {
template.add("jump_list", jumpJsonArray); template.add("jump_list", jumpJsonArray);
} }
if (null != this.getCard_action_type()) { if (null != this.getCardActionType()) {
JsonObject cardAction = new JsonObject(); JsonObject cardAction = new JsonObject();
cardAction.addProperty("type", this.getCard_action_type()); cardAction.addProperty("type", this.getCardActionType());
if (StringUtils.isNotBlank(this.getCard_action_url())) { if (StringUtils.isNotBlank(this.getCardActionUrl())) {
cardAction.addProperty("url", this.getCard_action_url()); cardAction.addProperty("url", this.getCardActionUrl());
} }
if (StringUtils.isNotBlank(this.getCard_action_appid())) { if (StringUtils.isNotBlank(this.getCardActionAppid())) {
cardAction.addProperty("appid", this.getCard_action_appid()); cardAction.addProperty("appid", this.getCardActionAppid());
} }
if (StringUtils.isNotBlank(this.getCard_action_pagepath())) { if (StringUtils.isNotBlank(this.getCardActionPagepath())) {
cardAction.addProperty("pagepath", this.getCard_action_pagepath()); cardAction.addProperty("pagepath", this.getCardActionPagepath());
} }
template.add("card_action", cardAction); template.add("card_action", cardAction);
} }
List<TemplateCardButton> buttons = this.getButtons(); List<TemplateCardButton> buttons = this.getButtons();
if (null != buttons && buttons.size() > 0) { if (null != buttons && !buttons.isEmpty()) {
JsonArray btnJsonArray = new JsonArray(); JsonArray btnJsonArray = new JsonArray();
for (TemplateCardButton btn : this.getButtons()) { for (TemplateCardButton btn : this.getButtons()) {
JsonObject tempObject = btn.toJson(); JsonObject tempObject = btn.toJson();
@ -572,11 +581,11 @@ public class WxCpMessage implements Serializable {
} }
// checkbox // checkbox
if (StringUtils.isNotBlank(this.getCheckbox_question_key())) { if (StringUtils.isNotBlank(this.getCheckboxQuestionKey())) {
JsonObject checkBox = new JsonObject(); JsonObject checkBox = new JsonObject();
checkBox.addProperty("question_key", this.getCheckbox_question_key()); checkBox.addProperty("question_key", this.getCheckboxQuestionKey());
if (null != this.getCheckbox_mode()) { if (null != this.getCheckboxMode()) {
checkBox.addProperty("mode", this.getCheckbox_mode()); checkBox.addProperty("mode", this.getCheckboxMode());
} }
JsonArray optionArray = new JsonArray(); JsonArray optionArray = new JsonArray();
for (CheckboxOption option : this.getOptions()) { for (CheckboxOption option : this.getOptions()) {
@ -589,20 +598,20 @@ public class WxCpMessage implements Serializable {
} }
// submit_button // submit_button
if (StringUtils.isNotBlank(this.getSubmit_button_text()) || StringUtils.isNotBlank(this.getSubmit_button_key())) { if (StringUtils.isNotBlank(this.getSubmitButtonText()) || StringUtils.isNotBlank(this.getSubmitButtonKey())) {
JsonObject submit_button = new JsonObject(); JsonObject submit_button = new JsonObject();
if (StringUtils.isNotBlank(this.getSubmit_button_text())) { if (StringUtils.isNotBlank(this.getSubmitButtonText())) {
submit_button.addProperty("text", this.getSubmit_button_text()); submit_button.addProperty("text", this.getSubmitButtonText());
} }
if (StringUtils.isNotBlank(this.getSubmit_button_key())) { if (StringUtils.isNotBlank(this.getSubmitButtonKey())) {
submit_button.addProperty("key", this.getSubmit_button_key()); submit_button.addProperty("key", this.getSubmitButtonKey());
} }
template.add("submit_button", submit_button); template.add("submit_button", submit_button);
} }
// select_list // select_list
List<MultipleSelect> selects = this.getSelects(); List<MultipleSelect> selects = this.getSelects();
if (null != selects && selects.size() > 0) { if (null != selects && !selects.isEmpty()) {
JsonArray selectJsonArray = new JsonArray(); JsonArray selectJsonArray = new JsonArray();
for (MultipleSelect select : this.getSelects()) { for (MultipleSelect select : this.getSelects()) {
JsonObject tempObject = select.toJson(); JsonObject tempObject = select.toJson();

View File

@ -23,62 +23,62 @@ public class TemplateCardBuilder extends BaseBuilder<TemplateCardBuilder> {
* 投票选择型卡片填写vote_interaction, * 投票选择型卡片填写vote_interaction,
* 多项选择型卡片填写 multiple_interaction * 多项选择型卡片填写 multiple_interaction
*/ */
private String card_type; private String cardType;
/** /**
* 卡片来源样式信息不需要来源样式可不填写 * 卡片来源样式信息不需要来源样式可不填写
* 来源图片的url * 来源图片的url
*/ */
private String source_icon_url; private String sourceIconUrl;
/** /**
* 卡片来源样式信息不需要来源样式可不填写 * 卡片来源样式信息不需要来源样式可不填写
* 来源图片的描述建议不超过20个字 * 来源图片的描述建议不超过20个字
*/ */
private String source_desc; private String sourceDesc;
/** /**
* 一级标题建议不超过36个字 * 一级标题建议不超过36个字
*/ */
private String main_title_title; private String mainTitleTitle;
/** /**
* 标题辅助信息建议不超过44个字 * 标题辅助信息建议不超过44个字
*/ */
private String main_title_desc; private String mainTitleDesc;
/** /**
* 图文展示型的卡片必须有图片字段 * 图文展示型的卡片必须有图片字段
* 图片的url. * 图片的url.
*/ */
private String card_image_url; private String cardImageUrl;
/** /**
* 图片的宽高比宽高比要小于2.25大于1.3不填该参数默认1.3 * 图片的宽高比宽高比要小于2.25大于1.3不填该参数默认1.3
*/ */
private Float card_image_aspect_ratio; private Float cardImageAspectRatio;
/** /**
* 关键数据样式 * 关键数据样式
* 关键数据样式的数据内容建议不超过14个字 * 关键数据样式的数据内容建议不超过14个字
*/ */
private String emphasis_content_title; private String emphasisContentTitle;
/** /**
* 关键数据样式的数据描述内容建议不超过22个字 * 关键数据样式的数据描述内容建议不超过22个字
*/ */
private String emphasis_content_desc; private String emphasisContentDesc;
/** /**
* 二级普通文本建议不超过160个字 * 二级普通文本建议不超过160个字
*/ */
private String sub_title_text; private String subTitleText;
/** /**
* 卡片二级垂直内容该字段可为空数组但有数据的话需确认对应字段是否必填列表长度不超过4 * 卡片二级垂直内容该字段可为空数组但有数据的话需确认对应字段是否必填列表长度不超过4
*/ */
private List<VerticalContent> vertical_contents; private List<VerticalContent> verticalContents;
/** /**
* 二级标题+文本列表该字段可为空数组但有数据的话需确认对应字段是否必填列表长度不超过6 * 二级标题+文本列表该字段可为空数组但有数据的话需确认对应字段是否必填列表长度不超过6
*/ */
private List<HorizontalContent> horizontal_contents; private List<HorizontalContent> horizontalContents;
/** /**
* 跳转指引样式的列表该字段可为空数组但有数据的话需确认对应字段是否必填列表长度不超过3 * 跳转指引样式的列表该字段可为空数组但有数据的话需确认对应字段是否必填列表长度不超过3
@ -89,26 +89,26 @@ public class TemplateCardBuilder extends BaseBuilder<TemplateCardBuilder> {
* 整体卡片的点击跳转事件text_notice必填本字段 * 整体卡片的点击跳转事件text_notice必填本字段
* 跳转事件类型1 代表跳转url2 代表打开小程序text_notice卡片模版中该字段取值范围为[1,2] * 跳转事件类型1 代表跳转url2 代表打开小程序text_notice卡片模版中该字段取值范围为[1,2]
*/ */
private Integer card_action_type; private Integer cardActionType;
/** /**
* 跳转事件的urlcard_action.type是1时必填 * 跳转事件的urlcard_action.type是1时必填
*/ */
private String card_action_url; private String cardActionUrl;
/** /**
* 跳转事件的小程序的appid必须是与当前应用关联的小程序card_action.type是2时必填 * 跳转事件的小程序的appid必须是与当前应用关联的小程序card_action.type是2时必填
*/ */
private String card_action_appid; private String cardActionAppid;
/** /**
* 跳转事件的小程序的pagepathcard_action.type是2时选填 * 跳转事件的小程序的pagepathcard_action.type是2时选填
*/ */
private String card_action_pagepath; private String cardActionPagepath;
/** /**
* 任务id同一个应用任务id不能重复只能由数字字母和_-@组成最长128字节 * 任务id同一个应用任务id不能重复只能由数字字母和_-@组成最长128字节
*/ */
private String task_id; private String taskId;
/** /**
* 按钮交互型卡片需指定 * 按钮交互型卡片需指定
@ -120,12 +120,12 @@ public class TemplateCardBuilder extends BaseBuilder<TemplateCardBuilder> {
* 投票选择型卡片需要指定 * 投票选择型卡片需要指定
* 选择题key值用户提交选项后会产生回调事件回调事件会带上该key值表示该题最长支持1024字节 * 选择题key值用户提交选项后会产生回调事件回调事件会带上该key值表示该题最长支持1024字节
*/ */
private String checkbox_question_key; private String checkboxQuestionKey;
/** /**
* 选择题模式单选0多选1不填默认0 * 选择题模式单选0多选1不填默认0
*/ */
private Integer checkbox_mode; private Integer checkboxMode;
/** /**
* 选项list选项个数不超过 20 最少1个 * 选项list选项个数不超过 20 最少1个
@ -136,11 +136,11 @@ public class TemplateCardBuilder extends BaseBuilder<TemplateCardBuilder> {
* 提交按钮样式 * 提交按钮样式
* 按钮文案建议不超过10个字不填默认为提交 * 按钮文案建议不超过10个字不填默认为提交
*/ */
private String submit_button_text; private String submitButtonText;
/** /**
* 提交按钮的key会产生回调事件将本参数作为EventKey返回最长支持1024字节 * 提交按钮的key会产生回调事件将本参数作为EventKey返回最长支持1024字节
*/ */
private String submit_button_key; private String submitButtonKey;
/** /**
* 下拉式的选择器列表multiple_interaction类型的卡片该字段不可为空一个消息最多支持 3 个选择器 * 下拉式的选择器列表multiple_interaction类型的卡片该字段不可为空一个消息最多支持 3 个选择器
@ -157,53 +157,63 @@ public class TemplateCardBuilder extends BaseBuilder<TemplateCardBuilder> {
this.msgType = WxConsts.KefuMsgType.TEMPLATE_CARD; this.msgType = WxConsts.KefuMsgType.TEMPLATE_CARD;
} }
public TemplateCardBuilder card_type(String card_type) { public TemplateCardBuilder cardType(String cardType) {
this.card_type = card_type; this.cardType = cardType;
return this; return this;
} }
public TemplateCardBuilder source_icon_url(String source_icon_url) { public TemplateCardBuilder cardImageUrl(String cardImageUrl) {
this.source_icon_url = source_icon_url; this.cardImageUrl = cardImageUrl;
return this; return this;
} }
public TemplateCardBuilder source_desc(String source_desc) { public TemplateCardBuilder cardImageAspectRatio(Float cardImageAspectRatio) {
this.source_desc = source_desc; this.cardImageAspectRatio = cardImageAspectRatio;
return this; return this;
} }
public TemplateCardBuilder main_title_title(String main_title_title) { public TemplateCardBuilder sourceIconUrl(String sourceIconUrl) {
this.main_title_title = main_title_title; this.sourceIconUrl = sourceIconUrl;
return this; return this;
} }
public TemplateCardBuilder main_title_desc(String mainTitleDesc) { public TemplateCardBuilder sourceDesc(String sourceDesc) {
this.main_title_desc = mainTitleDesc; this.sourceDesc = sourceDesc;
return this; return this;
} }
public TemplateCardBuilder emphasis_content_title(String emphasis_content_title) { public TemplateCardBuilder mainTitleTitle(String mainTitleTitle) {
this.emphasis_content_title = emphasis_content_title; this.mainTitleTitle = mainTitleTitle;
return this; return this;
} }
public TemplateCardBuilder emphasis_content_desc(String emphasis_content_desc) { public TemplateCardBuilder mainTitleDesc(String mainTitleDesc) {
this.emphasis_content_desc = emphasis_content_desc; this.mainTitleDesc = mainTitleDesc;
return this; return this;
} }
public TemplateCardBuilder sub_title_text(String sub_title_text) { public TemplateCardBuilder emphasisContentTitle(String emphasisContentTitle) {
this.sub_title_text = sub_title_text; this.emphasisContentTitle = emphasisContentTitle;
return this; return this;
} }
public TemplateCardBuilder vertical_contents(List<VerticalContent> vertical_contents) { public TemplateCardBuilder emphasisContentDesc(String emphasisContentDesc) {
this.vertical_contents = vertical_contents; this.emphasisContentDesc = emphasisContentDesc;
return this; return this;
} }
public TemplateCardBuilder horizontal_contents(List<HorizontalContent> horizontal_contents) { public TemplateCardBuilder subTitleText(String subTitleText) {
this.horizontal_contents = horizontal_contents; this.subTitleText = subTitleText;
return this;
}
public TemplateCardBuilder verticalContents(List<VerticalContent> verticalContents) {
this.verticalContents = verticalContents;
return this;
}
public TemplateCardBuilder horizontalContents(List<HorizontalContent> horizontalContents) {
this.horizontalContents = horizontalContents;
return this; return this;
} }
@ -212,28 +222,28 @@ public class TemplateCardBuilder extends BaseBuilder<TemplateCardBuilder> {
return this; return this;
} }
public TemplateCardBuilder card_action_type(Integer card_action_type) { public TemplateCardBuilder cardActionType(Integer cardActionType) {
this.card_action_type = card_action_type; this.cardActionType = cardActionType;
return this; return this;
} }
public TemplateCardBuilder card_action_url(String card_action_url) { public TemplateCardBuilder cardActionUrl(String cardActionUrl) {
this.card_action_url = card_action_url; this.cardActionUrl = cardActionUrl;
return this; return this;
} }
public TemplateCardBuilder card_action_appid(String card_action_appid) { public TemplateCardBuilder cardActionAppid(String cardActionAppid) {
this.card_action_appid = card_action_appid; this.cardActionAppid = cardActionAppid;
return this; return this;
} }
public TemplateCardBuilder card_action_pagepath(String card_action_pagepath) { public TemplateCardBuilder cardActionPagepath(String cardActionPagepath) {
this.card_action_pagepath = card_action_pagepath; this.cardActionPagepath = cardActionPagepath;
return this; return this;
} }
public TemplateCardBuilder task_id(String taskId) { public TemplateCardBuilder taskId(String taskId) {
this.task_id = taskId; this.taskId = taskId;
return this; return this;
} }
@ -242,13 +252,13 @@ public class TemplateCardBuilder extends BaseBuilder<TemplateCardBuilder> {
return this; return this;
} }
public TemplateCardBuilder checkbox_question_key(String checkbox_question_key) { public TemplateCardBuilder checkboxQuestionKey(String checkboxQuestionKey) {
this.checkbox_question_key = checkbox_question_key; this.checkboxQuestionKey = checkboxQuestionKey;
return this; return this;
} }
public TemplateCardBuilder checkbox_mode(Integer checkbox_mode) { public TemplateCardBuilder checkboxMode(Integer checkboxMode) {
this.checkbox_mode = checkbox_mode; this.checkboxMode = checkboxMode;
return this; return this;
} }
@ -257,13 +267,13 @@ public class TemplateCardBuilder extends BaseBuilder<TemplateCardBuilder> {
return this; return this;
} }
public TemplateCardBuilder submit_button_text(String submit_button_text) { public TemplateCardBuilder submitButtonText(String submitButtonText) {
this.submit_button_text = submit_button_text; this.submitButtonText = submitButtonText;
return this; return this;
} }
public TemplateCardBuilder submit_button_key(String submit_button_key) { public TemplateCardBuilder submitButtonKey(String submitButtonKey) {
this.submit_button_key = submit_button_key; this.submitButtonKey = submitButtonKey;
return this; return this;
} }
@ -281,30 +291,30 @@ public class TemplateCardBuilder extends BaseBuilder<TemplateCardBuilder> {
public WxCpMessage build() { public WxCpMessage build() {
WxCpMessage m = super.build(); WxCpMessage m = super.build();
m.setSafe(null); m.setSafe(null);
m.setCard_type(this.card_type); m.setCardType(this.cardType);
m.setSource_icon_url(this.source_icon_url); m.setSourceIconUrl(this.sourceIconUrl);
m.setSource_desc(this.source_desc); m.setSourceDesc(this.sourceDesc);
m.setMain_title_title(this.main_title_title); m.setMainTitleTitle(this.mainTitleTitle);
m.setMain_title_desc(this.main_title_desc); m.setMainTitleDesc(this.mainTitleDesc);
m.setCard_image_url(this.card_image_url); m.setCardImageUrl(this.cardImageUrl);
m.setCard_image_aspect_ratio(this.card_image_aspect_ratio); m.setCardImageAspectRatio(this.cardImageAspectRatio);
m.setEmphasis_content_title(this.emphasis_content_title); m.setEmphasisContentTitle(this.emphasisContentTitle);
m.setEmphasis_content_desc(this.emphasis_content_desc); m.setEmphasisContentDesc(this.emphasisContentDesc);
m.setSub_title_text(this.sub_title_text); m.setSubTitleText(this.subTitleText);
m.setVertical_contents(this.vertical_contents); m.setVerticalContents(this.verticalContents);
m.setHorizontal_contents(this.horizontal_contents); m.setHorizontalContents(this.horizontalContents);
m.setJumps(this.jumps); m.setJumps(this.jumps);
m.setCard_action_type(this.card_action_type); m.setCardActionType(this.cardActionType);
m.setCard_action_appid(this.card_action_appid); m.setCardActionAppid(this.cardActionAppid);
m.setCard_action_pagepath(this.card_action_pagepath); m.setCardActionPagepath(this.cardActionPagepath);
m.setCard_action_url(this.card_action_url); m.setCardActionUrl(this.cardActionUrl);
m.setTaskId(this.task_id); m.setTaskId(this.taskId);
m.setButtons(this.buttons); m.setButtons(this.buttons);
m.setCheckbox_mode(this.checkbox_mode); m.setCheckboxMode(this.checkboxMode);
m.setCheckbox_question_key(this.checkbox_question_key); m.setCheckboxQuestionKey(this.checkboxQuestionKey);
m.setOptions(this.options); m.setOptions(this.options);
m.setSubmit_button_text(this.submit_button_text); m.setSubmitButtonText(this.submitButtonText);
m.setSubmit_button_key(this.submit_button_key); m.setSubmitButtonKey(this.submitButtonKey);
m.setSelects(this.selects); m.setSelects(this.selects);
m.setQuoteArea(this.quoteArea); m.setQuoteArea(this.quoteArea);
return m; return m;

View File

@ -188,20 +188,20 @@ public class WxCpMessageTest {
.build(); .build();
WxCpMessage reply = WxCpMessage.TEMPLATECARD().toUser("OPENID") WxCpMessage reply = WxCpMessage.TEMPLATECARD().toUser("OPENID")
.agentId(1000002) .agentId(1000002)
.card_type(WxConsts.TemplateCardType.TEXT_NOTICE) .cardType(WxConsts.TemplateCardType.TEXT_NOTICE)
.source_icon_url("图片的url") .sourceIconUrl("图片的url")
.source_desc("企业微信") .sourceDesc("企业微信")
.main_title_title("欢迎使用企业微信") .mainTitleTitle("欢迎使用企业微信")
.main_title_desc("您的好友正在邀请您加入企业微信") .mainTitleDesc("您的好友正在邀请您加入企业微信")
.emphasis_content_title("100") .emphasisContentTitle("100")
.emphasis_content_desc("核心数据") .emphasisContentDesc("核心数据")
.sub_title_text("下载企业微信还能抢红包!") .subTitleText("下载企业微信还能抢红包!")
.horizontal_contents(Arrays.asList(hContent1,hContent2,hContent3)) .horizontalContents(Arrays.asList(hContent1,hContent2,hContent3))
.jumps(Arrays.asList(jump1,jump2)) .jumps(Arrays.asList(jump1,jump2))
.card_action_type(2) .cardActionType(2)
.card_action_appid("小程序的appid") .cardActionAppid("小程序的appid")
.card_action_url("https://work.weixin.qq.com") .cardActionUrl("https://work.weixin.qq.com")
.card_action_pagepath("/index.html") .cardActionPagepath("/index.html")
.quoteArea(quoteArea) .quoteArea(quoteArea)
.build(); .build();
reply.setEnableIdTrans(false); reply.setEnableIdTrans(false);
@ -259,18 +259,18 @@ public class WxCpMessageTest {
WxCpMessage reply = WxCpMessage.TEMPLATECARD().toUser("OPENID") WxCpMessage reply = WxCpMessage.TEMPLATECARD().toUser("OPENID")
.agentId(1000002) .agentId(1000002)
.card_type(WxConsts.TemplateCardType.NEWS_NOTICE) .cardType(WxConsts.TemplateCardType.NEWS_NOTICE)
.source_icon_url("图片的url") .sourceIconUrl("图片的url")
.source_desc("企业微信") .sourceDesc("企业微信")
.main_title_title("欢迎使用企业微信") .mainTitleTitle("欢迎使用企业微信")
.main_title_desc("您的好友正在邀请您加入企业微信") .mainTitleDesc("您的好友正在邀请您加入企业微信")
.vertical_contents(Arrays.asList(vContent1,vContent2)) .verticalContents(Arrays.asList(vContent1,vContent2))
.horizontal_contents(Arrays.asList(hContent1,hContent2,hContent3)) .horizontalContents(Arrays.asList(hContent1,hContent2,hContent3))
.jumps(Arrays.asList(jump1,jump2)) .jumps(Arrays.asList(jump1,jump2))
.card_action_type(2) .cardActionType(2)
.card_action_appid("小程序的appid") .cardActionAppid("小程序的appid")
.card_action_url("https://work.weixin.qq.com") .cardActionUrl("https://work.weixin.qq.com")
.card_action_pagepath("/index.html") .cardActionPagepath("/index.html")
.build(); .build();
reply.setEnableIdTrans(false); reply.setEnableIdTrans(false);
reply.setEnableDuplicateCheck(false); reply.setEnableDuplicateCheck(false);
@ -316,18 +316,18 @@ public class WxCpMessageTest {
WxCpMessage reply = WxCpMessage.TEMPLATECARD().toUser("OPENID") WxCpMessage reply = WxCpMessage.TEMPLATECARD().toUser("OPENID")
.agentId(1000002) .agentId(1000002)
.card_type(WxConsts.TemplateCardType.BUTTON_INTERACTION) .cardType(WxConsts.TemplateCardType.BUTTON_INTERACTION)
.source_icon_url("图片的url") .sourceIconUrl("图片的url")
.source_desc("企业微信") .sourceDesc("企业微信")
.main_title_title("欢迎使用企业微信") .mainTitleTitle("欢迎使用企业微信")
.main_title_desc("您的好友正在邀请您加入企业微信") .mainTitleDesc("您的好友正在邀请您加入企业微信")
.sub_title_text("下载企业微信还能抢红包!") .subTitleText("下载企业微信还能抢红包!")
.horizontal_contents(Arrays.asList(hContent1,hContent2,hContent3)) .horizontalContents(Arrays.asList(hContent1,hContent2,hContent3))
.card_action_type(2) .cardActionType(2)
.card_action_appid("小程序的appid") .cardActionAppid("小程序的appid")
.card_action_url("https://work.weixin.qq.com") .cardActionUrl("https://work.weixin.qq.com")
.card_action_pagepath("/index.html") .cardActionPagepath("/index.html")
.task_id("task_id") .taskId("task_id")
.buttons(Arrays.asList(tButton1,tButton2)) .buttons(Arrays.asList(tButton1,tButton2))
.build(); .build();
reply.setEnableIdTrans(false); reply.setEnableIdTrans(false);
@ -356,22 +356,24 @@ public class WxCpMessageTest {
WxCpMessage reply = WxCpMessage.TEMPLATECARD().toUser("OPENID") WxCpMessage reply = WxCpMessage.TEMPLATECARD().toUser("OPENID")
.agentId(1000002) .agentId(1000002)
.card_type(WxConsts.TemplateCardType.VOTE_INTERACTION) .cardType(WxConsts.TemplateCardType.VOTE_INTERACTION)
.source_icon_url("图片的url") .sourceIconUrl("图片的url")
.source_desc("企业微信") .sourceDesc("企业微信")
.main_title_title("欢迎使用企业微信") .mainTitleTitle("欢迎使用企业微信")
.main_title_desc("您的好友正在邀请您加入企业微信") .mainTitleDesc("您的好友正在邀请您加入企业微信")
.task_id("task_id") .taskId("task_id")
.checkbox_question_key("question_key1") .checkboxQuestionKey("question_key1")
.checkbox_mode(1) .checkboxMode(1)
.options(Arrays.asList(option1,option2)) .options(Arrays.asList(option1,option2))
.submit_button_key("key") .submitButtonKey("key")
.submit_button_text("提交") .submitButtonText("提交")
.build(); .build();
reply.setEnableIdTrans(false); reply.setEnableIdTrans(false);
reply.setEnableDuplicateCheck(false); reply.setEnableDuplicateCheck(false);
reply.setDuplicateCheckInterval(1800); reply.setDuplicateCheckInterval(1800);
System.out.println(reply.toJson()); System.out.println(reply.toJson());
assertThat(reply.toJson()) assertThat(reply.toJson())
.isEqualTo("{\"agentid\":1000002,\"touser\":\"OPENID\",\"msgtype\":\"template_card\",\"duplicate_check_interval\":1800,\"template_card\":{\"card_type\":\"vote_interaction\",\"source\":{\"icon_url\":\"图片的url\",\"desc\":\"企业微信\"},\"main_title\":{\"title\":\"欢迎使用企业微信\",\"desc\":\"您的好友正在邀请您加入企业微信\"},\"task_id\":\"task_id\",\"checkbox\":{\"question_key\":\"question_key1\",\"mode\":1,\"option_list\":[{\"id\":\"option_id1\",\"text\":\"选择题选项1\",\"is_checked\":true},{\"id\":\"option_id2\",\"text\":\"选择题选项2\",\"is_checked\":false}]},\"submit_button\":{\"text\":\"提交\",\"key\":\"key\"}}}"); .isEqualTo("{\"agentid\":1000002,\"touser\":\"OPENID\",\"msgtype\":\"template_card\",\"duplicate_check_interval\":1800,\"template_card\":{\"card_type\":\"vote_interaction\",\"source\":{\"icon_url\":\"图片的url\",\"desc\":\"企业微信\"},\"main_title\":{\"title\":\"欢迎使用企业微信\",\"desc\":\"您的好友正在邀请您加入企业微信\"},\"task_id\":\"task_id\",\"checkbox\":{\"question_key\":\"question_key1\",\"mode\":1,\"option_list\":[{\"id\":\"option_id1\",\"text\":\"选择题选项1\",\"is_checked\":true},{\"id\":\"option_id2\",\"text\":\"选择题选项2\",\"is_checked\":false}]},\"submit_button\":{\"text\":\"提交\",\"key\":\"key\"}}}");
} }
@ -414,15 +416,15 @@ public class WxCpMessageTest {
WxCpMessage reply = WxCpMessage.TEMPLATECARD().toUser("OPENID") WxCpMessage reply = WxCpMessage.TEMPLATECARD().toUser("OPENID")
.agentId(1000002) .agentId(1000002)
.card_type(WxConsts.TemplateCardType.MULTIPLE_INTERACTION) .cardType(WxConsts.TemplateCardType.MULTIPLE_INTERACTION)
.source_icon_url("图片的url") .sourceIconUrl("图片的url")
.source_desc("企业微信") .sourceDesc("企业微信")
.main_title_title("欢迎使用企业微信") .mainTitleTitle("欢迎使用企业微信")
.main_title_desc("您的好友正在邀请您加入企业微信") .mainTitleDesc("您的好友正在邀请您加入企业微信")
.task_id("task_id") .taskId("task_id")
.selects(Arrays.asList(mSelect1,mSelect2)) .selects(Arrays.asList(mSelect1,mSelect2))
.submit_button_key("key") .submitButtonKey("key")
.submit_button_text("提交") .submitButtonText("提交")
.build(); .build();
reply.setEnableIdTrans(false); reply.setEnableIdTrans(false);
reply.setEnableDuplicateCheck(false); reply.setEnableDuplicateCheck(false);