@@ -71,72 +71,70 @@ public class WxCpMessage implements Serializable {
71
71
private String taskId ;
72
72
private List <TaskCardButton > taskButtons = new ArrayList <>();
73
73
74
- /**
75
- * 模板型卡片特有属性
76
- */
74
+ // 模板型卡片特有属性
77
75
/**
78
76
* 模板卡片类型,文本通知型卡片填写 “text_notice”,
79
77
* 图文展示型卡片此处填写 “news_notice”,
80
78
* 按钮交互型卡片填写”button_interaction”,
81
79
* 投票选择型卡片填写”vote_interaction”,
82
80
* 多项选择型卡片填写 “multiple_interaction”
83
81
*/
84
- private String card_type ;
82
+ private String cardType ;
85
83
86
84
/**
87
85
* 卡片来源样式信息,不需要来源样式可不填写
88
86
* 来源图片的url
89
87
*/
90
- private String source_icon_url ;
88
+ private String sourceIconUrl ;
91
89
/**
92
90
* 卡片来源样式信息,不需要来源样式可不填写
93
91
* 来源图片的描述,建议不超过20个字
94
92
*/
95
- private String source_desc ;
93
+ private String sourceDesc ;
96
94
97
95
/**
98
96
* 一级标题,建议不超过36个字
99
97
*/
100
- private String main_title_title ;
98
+ private String mainTitleTitle ;
101
99
/**
102
100
* 标题辅助信息,建议不超过44个字
103
101
*/
104
- private String main_title_desc ;
102
+ private String mainTitleDesc ;
105
103
106
104
/**
107
105
* 图文展示型的卡片必须有图片字段。
108
106
* 图片的url.
109
107
*/
110
- private String card_image_url ;
108
+ private String cardImageUrl ;
111
109
112
110
/**
113
111
* 图片的宽高比,宽高比要小于2.25,大于1.3,不填该参数默认1.3
114
112
*/
115
- private Float card_image_aspect_ratio ;
113
+ private Float cardImageAspectRatio ;
116
114
/**
117
115
* 关键数据样式
118
116
* 关键数据样式的数据内容,建议不超过14个字
119
117
*/
120
- private String emphasis_content_title ;
118
+ private String emphasisContentTitle ;
121
119
/**
122
120
* 关键数据样式的数据描述内容,建议不超过22个字
123
121
*/
124
- private String emphasis_content_desc ;
122
+ private String emphasisContentDesc ;
125
123
126
124
/**
127
125
* 二级普通文本,建议不超过160个字
128
126
*/
129
- private String sub_title_text ;
127
+ private String subTitleText ;
130
128
131
129
/**
132
130
* 卡片二级垂直内容,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过4
133
131
*/
134
- private List <VerticalContent > vertical_contents ;
132
+ private List <VerticalContent > verticalContents ;
135
133
136
134
/**
137
135
* 二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6
138
136
*/
139
- private List <HorizontalContent > horizontal_contents ;
137
+ private List <HorizontalContent > horizontalContents ;
140
138
141
139
/**
142
140
* 跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过3
@@ -147,21 +145,21 @@ public class WxCpMessage implements Serializable {
147
145
* 整体卡片的点击跳转事件,text_notice必填本字段
148
146
* 跳转事件类型,1 代表跳转url,2 代表打开小程序。text_notice卡片模版中该字段取值范围为[1,2]
149
147
*/
150
- private Integer card_action_type ;
148
+ private Integer cardActionType ;
151
149
/**
152
150
* 跳转事件的url,card_action.type是1时必填
153
151
*/
154
- private String card_action_url ;
152
+ private String cardActionUrl ;
155
153
156
154
/**
157
155
* 跳转事件的小程序的appid,必须是与当前应用关联的小程序,card_action.type是2时必填
158
156
*/
159
- private String card_action_appid ;
157
+ private String cardActionAppid ;
160
158
161
159
/**
162
160
* 跳转事件的小程序的pagepath,card_action.type是2时选填
163
161
*/
164
- private String card_action_pagepath ;
162
+ private String cardActionPagepath ;
165
163
166
164
/**
167
165
* 按钮交互型卡片需指定。
@@ -173,12 +171,12 @@ public class WxCpMessage implements Serializable {
173
171
* 投票选择型卡片需要指定
174
172
* 选择题key值,用户提交选项后,会产生回调事件,回调事件会带上该key值表示该题,最长支持1024字节
175
173
*/
176
- private String checkbox_question_key ;
174
+ private String checkboxQuestionKey ;
177
175
178
176
/**
179
177
* 选择题模式,单选:0,多选:1,不填默认0
180
178
*/
181
- private Integer checkbox_mode ;
179
+ private Integer checkboxMode ;
182
180
183
181
/**
184
182
* 选项list,选项个数不超过 20 个,最少1个
@@ -189,11 +187,11 @@ public class WxCpMessage implements Serializable {
189
187
* 提交按钮样式
190
188
* 按钮文案,建议不超过10个字,不填默认为提交
191
189
*/
192
- private String submit_button_text ;
190
+ private String submitButtonText ;
193
191
/**
194
192
* 提交按钮的key,会产生回调事件将本参数作为EventKey返回,最长支持1024字节
195
193
*/
196
- private String submit_button_key ;
194
+ private String submitButtonKey ;
197
195
/**
198
196
* 下拉式的选择器列表,multiple_interaction类型的卡片该字段不可为空,一个消息最多支持 3 个选择器
199
197
*/
@@ -472,72 +470,83 @@ private void handleMsgType(JsonObject messageJson) {
472
470
}
473
471
case TEMPLATE_CARD : {
474
472
JsonObject template = new JsonObject ();
475
- template .addProperty ("card_type" , this .getCard_type ());
473
+ template .addProperty ("card_type" , this .getCardType ());
476
474
477
- if (StringUtils .isNotBlank (this .getSource_icon_url ()) || StringUtils .isNotBlank (this .getSource_desc ())) {
475
+ if (StringUtils .isNotBlank (this .getSourceIconUrl ()) || StringUtils .isNotBlank (this .getSourceDesc ())) {
478
476
JsonObject source = new JsonObject ();
479
- if (StringUtils .isNotBlank (this .getSource_icon_url ())) {
480
- source .addProperty ("icon_url" , this .getSource_icon_url ());
477
+ if (StringUtils .isNotBlank (this .getSourceIconUrl ())) {
478
+ source .addProperty ("icon_url" , this .getSourceIconUrl ());
481
479
}
482
- if (StringUtils .isNotBlank (this .getSource_desc ())) {
483
- source .addProperty ("desc" , this .getSource_desc ());
480
+ if (StringUtils .isNotBlank (this .getSourceDesc ())) {
481
+ source .addProperty ("desc" , this .getSourceDesc ());
484
482
}
485
483
template .add ("source" , source );
486
484
}
487
485
488
- if (StringUtils .isNotBlank (this .getMain_title_title ()) || StringUtils .isNotBlank (this .getMain_title_desc ())) {
489
- JsonObject main_title = new JsonObject ();
490
- if (StringUtils .isNotBlank (this .getMain_title_title ())) {
491
- main_title .addProperty ("title" , this .getMain_title_title ());
486
+ if (StringUtils .isNotBlank (this .getMainTitleTitle ()) || StringUtils .isNotBlank (this .getMainTitleDesc ())) {
487
+ JsonObject mainTitle = new JsonObject ();
488
+ if (StringUtils .isNotBlank (this .getMainTitleTitle ())) {
489
+ mainTitle .addProperty ("title" , this .getMainTitleTitle ());
490
+ }
491
+ if (StringUtils .isNotBlank (this .getMainTitleDesc ())) {
492
+ mainTitle .addProperty ("desc" , this .getMainTitleDesc ());
493
+ }
494
+ template .add ("main_title" , mainTitle );
495
+ }
496
+
497
+ if (StringUtils .isNotBlank (this .getCardImageUrl ()) || this .getCardImageAspectRatio () != null ) {
498
+ JsonObject cardImage = new JsonObject ();
499
+ if (StringUtils .isNotBlank (this .getCardImageUrl ())) {
500
+ cardImage .addProperty ("url" , this .getCardImageUrl ());
492
501
}
493
- if (StringUtils . isNotBlank ( this .getMain_title_desc () )) {
494
- main_title .addProperty ("desc " , this .getMain_title_desc ());
502
+ if (null != this .getCardImageAspectRatio ( )) {
503
+ cardImage .addProperty ("aspect_ratio " , this .getCardImageAspectRatio ());
495
504
}
496
- template .add ("main_title " , main_title );
505
+ template .add ("card_image " , cardImage );
497
506
}
498
507
499
- if (StringUtils .isNotBlank (this .getEmphasis_content_title ()) || StringUtils .isNotBlank (this .getEmphasis_content_desc ())) {
500
- JsonObject emphasis_content = new JsonObject ();
501
- if (StringUtils .isNotBlank (this .getEmphasis_content_title ())) {
502
- emphasis_content .addProperty ("title" , this .getEmphasis_content_title ());
508
+ if (StringUtils .isNotBlank (this .getEmphasisContentTitle ()) || StringUtils .isNotBlank (this .getEmphasisContentDesc ())) {
509
+ JsonObject emphasisContent = new JsonObject ();
510
+ if (StringUtils .isNotBlank (this .getEmphasisContentTitle ())) {
511
+ emphasisContent .addProperty ("title" , this .getEmphasisContentTitle ());
503
512
}
504
- if (StringUtils .isNotBlank (this .getEmphasis_content_desc ())) {
505
- emphasis_content .addProperty ("desc" , this .getEmphasis_content_desc ());
513
+ if (StringUtils .isNotBlank (this .getEmphasisContentDesc ())) {
514
+ emphasisContent .addProperty ("desc" , this .getEmphasisContentDesc ());
506
515
}
507
- template .add ("emphasis_content" , emphasis_content );
516
+ template .add ("emphasis_content" , emphasisContent );
508
517
}
509
518
510
519
511
- if (StringUtils .isNotBlank (this .getSub_title_text ())) {
512
- template .addProperty ("sub_title_text" , this .getSub_title_text ());
520
+ if (StringUtils .isNotBlank (this .getSubTitleText ())) {
521
+ template .addProperty ("sub_title_text" , this .getSubTitleText ());
513
522
}
514
523
515
524
if (StringUtils .isNotBlank (this .getTaskId ())) {
516
525
template .addProperty ("task_id" , this .getTaskId ());
517
526
}
518
527
519
- List <VerticalContent > verticalContents = this .getVertical_contents ();
520
- if (null != verticalContents && verticalContents .size () > 0 ) {
528
+ List <VerticalContent > verticalContents = this .getVerticalContents ();
529
+ if (null != verticalContents && ! verticalContents .isEmpty () ) {
521
530
JsonArray vContentJsonArray = new JsonArray ();
522
- for (VerticalContent vContent : this .getVertical_contents ()) {
531
+ for (VerticalContent vContent : this .getVerticalContents ()) {
523
532
JsonObject tempObject = vContent .toJson ();
524
533
vContentJsonArray .add (tempObject );
525
534
}
526
535
template .add ("vertical_content_list" , vContentJsonArray );
527
536
}
528
537
529
- List <HorizontalContent > horizontalContents = this .getHorizontal_contents ();
530
- if (null != horizontalContents && horizontalContents .size () > 0 ) {
538
+ List <HorizontalContent > horizontalContents = this .getHorizontalContents ();
539
+ if (null != horizontalContents && ! horizontalContents .isEmpty () ) {
531
540
JsonArray hContentJsonArray = new JsonArray ();
532
- for (HorizontalContent hContent : this .getHorizontal_contents ()) {
541
+ for (HorizontalContent hContent : this .getHorizontalContents ()) {
533
542
JsonObject tempObject = hContent .toJson ();
534
543
hContentJsonArray .add (tempObject );
535
544
}
536
545
template .add ("horizontal_content_list" , hContentJsonArray );
537
546
}
538
547
539
548
List <TemplateCardJump > jumps = this .getJumps ();
540
- if (null != jumps && jumps .size () > 0 ) {
549
+ if (null != jumps && ! jumps .isEmpty () ) {
541
550
JsonArray jumpJsonArray = new JsonArray ();
542
551
for (TemplateCardJump jump : this .getJumps ()) {
543
552
JsonObject tempObject = jump .toJson ();
@@ -546,23 +555,23 @@ private void handleMsgType(JsonObject messageJson) {
546
555
template .add ("jump_list" , jumpJsonArray );
547
556
}
548
557
549
- if (null != this .getCard_action_type ()) {
558
+ if (null != this .getCardActionType ()) {
550
559
JsonObject cardAction = new JsonObject ();
551
- cardAction .addProperty ("type" , this .getCard_action_type ());
552
- if (StringUtils .isNotBlank (this .getCard_action_url ())) {
553
- cardAction .addProperty ("url" , this .getCard_action_url ());
560
+ cardAction .addProperty ("type" , this .getCardActionType ());
561
+ if (StringUtils .isNotBlank (this .getCardActionUrl ())) {
562
+ cardAction .addProperty ("url" , this .getCardActionUrl ());
554
563
}
555
- if (StringUtils .isNotBlank (this .getCard_action_appid ())) {
556
- cardAction .addProperty ("appid" , this .getCard_action_appid ());
564
+ if (StringUtils .isNotBlank (this .getCardActionAppid ())) {
565
+ cardAction .addProperty ("appid" , this .getCardActionAppid ());
557
566
}
558
- if (StringUtils .isNotBlank (this .getCard_action_pagepath ())) {
559
- cardAction .addProperty ("pagepath" , this .getCard_action_pagepath ());
567
+ if (StringUtils .isNotBlank (this .getCardActionPagepath ())) {
568
+ cardAction .addProperty ("pagepath" , this .getCardActionPagepath ());
560
569
}
561
570
template .add ("card_action" , cardAction );
562
571
}
563
572
564
573
List <TemplateCardButton > buttons = this .getButtons ();
565
- if (null != buttons && buttons .size () > 0 ) {
574
+ if (null != buttons && ! buttons .isEmpty () ) {
566
575
JsonArray btnJsonArray = new JsonArray ();
567
576
for (TemplateCardButton btn : this .getButtons ()) {
568
577
JsonObject tempObject = btn .toJson ();
@@ -572,11 +581,11 @@ private void handleMsgType(JsonObject messageJson) {
572
581
}
573
582
574
583
// checkbox
575
- if (StringUtils .isNotBlank (this .getCheckbox_question_key ())) {
584
+ if (StringUtils .isNotBlank (this .getCheckboxQuestionKey ())) {
576
585
JsonObject checkBox = new JsonObject ();
577
- checkBox .addProperty ("question_key" , this .getCheckbox_question_key ());
578
- if (null != this .getCheckbox_mode ()) {
579
- checkBox .addProperty ("mode" , this .getCheckbox_mode ());
586
+ checkBox .addProperty ("question_key" , this .getCheckboxQuestionKey ());
587
+ if (null != this .getCheckboxMode ()) {
588
+ checkBox .addProperty ("mode" , this .getCheckboxMode ());
580
589
}
581
590
JsonArray optionArray = new JsonArray ();
582
591
for (CheckboxOption option : this .getOptions ()) {
@@ -589,20 +598,20 @@ private void handleMsgType(JsonObject messageJson) {
589
598
}
590
599
591
600
// submit_button
592
- if (StringUtils .isNotBlank (this .getSubmit_button_text ()) || StringUtils .isNotBlank (this .getSubmit_button_key ())) {
601
+ if (StringUtils .isNotBlank (this .getSubmitButtonText ()) || StringUtils .isNotBlank (this .getSubmitButtonKey ())) {
593
602
JsonObject submit_button = new JsonObject ();
594
- if (StringUtils .isNotBlank (this .getSubmit_button_text ())) {
595
- submit_button .addProperty ("text" , this .getSubmit_button_text ());
603
+ if (StringUtils .isNotBlank (this .getSubmitButtonText ())) {
604
+ submit_button .addProperty ("text" , this .getSubmitButtonText ());
596
605
}
597
- if (StringUtils .isNotBlank (this .getSubmit_button_key ())) {
598
- submit_button .addProperty ("key" , this .getSubmit_button_key ());
606
+ if (StringUtils .isNotBlank (this .getSubmitButtonKey ())) {
607
+ submit_button .addProperty ("key" , this .getSubmitButtonKey ());
599
608
}
600
609
template .add ("submit_button" , submit_button );
601
610
}
602
611
603
612
// select_list
604
613
List <MultipleSelect > selects = this .getSelects ();
605
- if (null != selects && selects .size () > 0 ) {
614
+ if (null != selects && ! selects .isEmpty () ) {
606
615
JsonArray selectJsonArray = new JsonArray ();
607
616
for (MultipleSelect select : this .getSelects ()) {
608
617
JsonObject tempObject = select .toJson ();
0 commit comments