🆕 #1915 【企业微信】发送应用消息接口增加是否开启重复消息检查等字段

This commit is contained in:
Binary Wang 2020-12-21 01:02:32 +08:00
parent 155501152a
commit a2448d5179
2 changed files with 76 additions and 26 deletions

View File

@ -48,6 +48,22 @@ public class WxCpMessage implements Serializable {
private Boolean emphasisFirstItem;
private Map<String, String> contentItems;
/**
* enable_id_trans
* 表示是否开启id转译0表示否1表示是默认0
*/
private Boolean enableIdTrans;
/**
* enable_duplicate_check
* 表示是否开启重复消息检查0表示否1表示是默认0
*/
private Boolean enableDuplicateCheck;
/**
* duplicate_check_interval
* 表示是否重复消息检查的时间间隔默认1800s最大不超过4小时
*/
private Integer duplicateCheckInterval;
/**
* 任务卡片特有的属性.
*/
@ -172,6 +188,18 @@ public class WxCpMessage implements Serializable {
messageJson.addProperty("totag", this.getToTag());
}
if (this.getEnableIdTrans()) {
messageJson.addProperty("enable_id_trans", 1);
}
if (this.getEnableDuplicateCheck()) {
messageJson.addProperty("enable_duplicate_check", 1);
}
if (this.getDuplicateCheckInterval() != null) {
messageJson.addProperty("duplicate_check_interval", this.getDuplicateCheckInterval());
}
this.handleMsgType(messageJson);
if (StringUtils.isNotBlank(this.getSafe())) {
@ -253,15 +281,7 @@ public class WxCpMessage implements Serializable {
} else {
JsonArray articleJsonArray = new JsonArray();
for (MpnewsArticle article : this.getMpnewsArticles()) {
JsonObject articleJson = new JsonObject();
articleJson.addProperty("title", article.getTitle());
articleJson.addProperty("thumb_media_id", article.getThumbMediaId());
articleJson.addProperty("author", article.getAuthor());
articleJson.addProperty("content_source_url", article.getContentSourceUrl());
articleJson.addProperty("content", article.getContent());
articleJson.addProperty("digest", article.getDigest());
articleJson.addProperty("show_cover_pic", article.getShowCoverPic());
articleJsonArray.add(articleJson);
article2Json(articleJsonArray, article);
}
newsJsonObject.add("articles", articleJsonArray);
@ -282,23 +302,7 @@ public class WxCpMessage implements Serializable {
JsonArray buttonJsonArray = new JsonArray();
for (TaskCardButton button : this.getTaskButtons()) {
JsonObject buttonJson = new JsonObject();
buttonJson.addProperty("key", button.getKey());
buttonJson.addProperty("name", button.getName());
if (StringUtils.isNotBlank(button.getReplaceName())) {
buttonJson.addProperty("replace_name", button.getReplaceName());
}
if (StringUtils.isNotBlank(button.getColor())) {
buttonJson.addProperty("color", button.getColor());
}
if (button.getBold() != null) {
buttonJson.addProperty("is_bold", button.getBold());
}
buttonJsonArray.add(buttonJson);
btn2Json(buttonJsonArray, button);
}
text.add("btn", buttonJsonArray);
@ -330,4 +334,36 @@ public class WxCpMessage implements Serializable {
}
}
private void btn2Json(JsonArray buttonJsonArray, TaskCardButton button) {
JsonObject buttonJson = new JsonObject();
buttonJson.addProperty("key", button.getKey());
buttonJson.addProperty("name", button.getName());
if (StringUtils.isNotBlank(button.getReplaceName())) {
buttonJson.addProperty("replace_name", button.getReplaceName());
}
if (StringUtils.isNotBlank(button.getColor())) {
buttonJson.addProperty("color", button.getColor());
}
if (button.getBold() != null) {
buttonJson.addProperty("is_bold", button.getBold());
}
buttonJsonArray.add(buttonJson);
}
private void article2Json(JsonArray articleJsonArray, MpnewsArticle article) {
JsonObject articleJson = new JsonObject();
articleJson.addProperty("title", article.getTitle());
articleJson.addProperty("thumb_media_id", article.getThumbMediaId());
articleJson.addProperty("author", article.getAuthor());
articleJson.addProperty("content_source_url", article.getContentSourceUrl());
articleJson.addProperty("content", article.getContent());
articleJson.addProperty("digest", article.getDigest());
articleJson.addProperty("show_cover_pic", article.getShowCoverPic());
articleJsonArray.add(articleJson);
}
}

View File

@ -22,6 +22,8 @@ public interface WxMpQrcodeService {
*
* @param sceneId 场景值ID临时二维码时为32位非0整型
* @param expireSeconds 该二维码有效时间以秒为单位 最大不超过2592000即30天此字段如果不填则默认有效期为30秒
* @return the wx mp qr code ticket
* @throws WxErrorException the wx error exception
*/
WxMpQrCodeTicket qrCodeCreateTmpTicket(int sceneId, Integer expireSeconds) throws WxErrorException;
@ -34,6 +36,8 @@ public interface WxMpQrcodeService {
*
* @param sceneStr 场景值ID字符串形式的ID字符串类型长度限制为1到64
* @param expireSeconds 该二维码有效时间以秒为单位 最大不超过2592000即30天此字段如果不填则默认有效期为30秒
* @return the wx mp qr code ticket
* @throws WxErrorException the wx error exception
*/
WxMpQrCodeTicket qrCodeCreateTmpTicket(String sceneStr, Integer expireSeconds) throws WxErrorException;
@ -44,6 +48,8 @@ public interface WxMpQrcodeService {
* </pre>
*
* @param sceneId 场景值ID最大值为100000目前参数只支持1--100000
* @return the wx mp qr code ticket
* @throws WxErrorException the wx error exception
*/
WxMpQrCodeTicket qrCodeCreateLastTicket(int sceneId) throws WxErrorException;
@ -54,6 +60,8 @@ public interface WxMpQrcodeService {
* </pre>
*
* @param sceneStr 参数字符串类型长度现在为1到64
* @return the wx mp qr code ticket
* @throws WxErrorException the wx error exception
*/
WxMpQrCodeTicket qrCodeCreateLastTicket(String sceneStr) throws WxErrorException;
@ -64,6 +72,8 @@ public interface WxMpQrcodeService {
* </pre>
*
* @param ticket 二维码ticket
* @return the file
* @throws WxErrorException the wx error exception
*/
File qrCodePicture(WxMpQrCodeTicket ticket) throws WxErrorException;
@ -75,6 +85,8 @@ public interface WxMpQrcodeService {
*
* @param ticket 二维码ticket
* @param needShortUrl 是否需要压缩的二维码地址
* @return the string
* @throws WxErrorException the wx error exception
*/
String qrCodePictureUrl(String ticket, boolean needShortUrl) throws WxErrorException;
@ -85,6 +97,8 @@ public interface WxMpQrcodeService {
* </pre>
*
* @param ticket 二维码ticket
* @return the string
* @throws WxErrorException the wx error exception
*/
String qrCodePictureUrl(String ticket) throws WxErrorException;