@@ -48,6 +48,22 @@ public class WxCpMessage implements Serializable {
4848 private Boolean emphasisFirstItem ;
4949 private Map <String , String > contentItems ;
5050
51+ /**
52+ * enable_id_trans
53+ * 表示是否开启id转译,0表示否,1表示是,默认0
54+ */
55+ private Boolean enableIdTrans ;
56+ /**
57+ * enable_duplicate_check
58+ * 表示是否开启重复消息检查,0表示否,1表示是,默认0
59+ */
60+ private Boolean enableDuplicateCheck ;
61+ /**
62+ * duplicate_check_interval
63+ * 表示是否重复消息检查的时间间隔,默认1800s,最大不超过4小时
64+ */
65+ private Integer duplicateCheckInterval ;
66+
5167 /**
5268 * 任务卡片特有的属性.
5369 */
@@ -172,6 +188,18 @@ public String toJson() {
172188 messageJson .addProperty ("totag" , this .getToTag ());
173189 }
174190
191+ if (this .getEnableIdTrans ()) {
192+ messageJson .addProperty ("enable_id_trans" , 1 );
193+ }
194+
195+ if (this .getEnableDuplicateCheck ()) {
196+ messageJson .addProperty ("enable_duplicate_check" , 1 );
197+ }
198+
199+ if (this .getDuplicateCheckInterval () != null ) {
200+ messageJson .addProperty ("duplicate_check_interval" , this .getDuplicateCheckInterval ());
201+ }
202+
175203 this .handleMsgType (messageJson );
176204
177205 if (StringUtils .isNotBlank (this .getSafe ())) {
@@ -253,15 +281,7 @@ private void handleMsgType(JsonObject messageJson) {
253281 } else {
254282 JsonArray articleJsonArray = new JsonArray ();
255283 for (MpnewsArticle article : this .getMpnewsArticles ()) {
256- JsonObject articleJson = new JsonObject ();
257- articleJson .addProperty ("title" , article .getTitle ());
258- articleJson .addProperty ("thumb_media_id" , article .getThumbMediaId ());
259- articleJson .addProperty ("author" , article .getAuthor ());
260- articleJson .addProperty ("content_source_url" , article .getContentSourceUrl ());
261- articleJson .addProperty ("content" , article .getContent ());
262- articleJson .addProperty ("digest" , article .getDigest ());
263- articleJson .addProperty ("show_cover_pic" , article .getShowCoverPic ());
264- articleJsonArray .add (articleJson );
284+ article2Json (articleJsonArray , article );
265285 }
266286
267287 newsJsonObject .add ("articles" , articleJsonArray );
@@ -282,23 +302,7 @@ private void handleMsgType(JsonObject messageJson) {
282302
283303 JsonArray buttonJsonArray = new JsonArray ();
284304 for (TaskCardButton button : this .getTaskButtons ()) {
285- JsonObject buttonJson = new JsonObject ();
286- buttonJson .addProperty ("key" , button .getKey ());
287- buttonJson .addProperty ("name" , button .getName ());
288-
289- if (StringUtils .isNotBlank (button .getReplaceName ())) {
290- buttonJson .addProperty ("replace_name" , button .getReplaceName ());
291- }
292-
293- if (StringUtils .isNotBlank (button .getColor ())) {
294- buttonJson .addProperty ("color" , button .getColor ());
295- }
296-
297- if (button .getBold () != null ) {
298- buttonJson .addProperty ("is_bold" , button .getBold ());
299- }
300-
301- buttonJsonArray .add (buttonJson );
305+ btn2Json (buttonJsonArray , button );
302306 }
303307 text .add ("btn" , buttonJsonArray );
304308
@@ -330,4 +334,36 @@ private void handleMsgType(JsonObject messageJson) {
330334 }
331335 }
332336
337+ private void btn2Json (JsonArray buttonJsonArray , TaskCardButton button ) {
338+ JsonObject buttonJson = new JsonObject ();
339+ buttonJson .addProperty ("key" , button .getKey ());
340+ buttonJson .addProperty ("name" , button .getName ());
341+
342+ if (StringUtils .isNotBlank (button .getReplaceName ())) {
343+ buttonJson .addProperty ("replace_name" , button .getReplaceName ());
344+ }
345+
346+ if (StringUtils .isNotBlank (button .getColor ())) {
347+ buttonJson .addProperty ("color" , button .getColor ());
348+ }
349+
350+ if (button .getBold () != null ) {
351+ buttonJson .addProperty ("is_bold" , button .getBold ());
352+ }
353+
354+ buttonJsonArray .add (buttonJson );
355+ }
356+
357+ private void article2Json (JsonArray articleJsonArray , MpnewsArticle article ) {
358+ JsonObject articleJson = new JsonObject ();
359+ articleJson .addProperty ("title" , article .getTitle ());
360+ articleJson .addProperty ("thumb_media_id" , article .getThumbMediaId ());
361+ articleJson .addProperty ("author" , article .getAuthor ());
362+ articleJson .addProperty ("content_source_url" , article .getContentSourceUrl ());
363+ articleJson .addProperty ("content" , article .getContent ());
364+ articleJson .addProperty ("digest" , article .getDigest ());
365+ articleJson .addProperty ("show_cover_pic" , article .getShowCoverPic ());
366+ articleJsonArray .add (articleJson );
367+ }
368+
333369}
0 commit comments