Skip to content

Commit 3e2ebb0

Browse files
committed
Merge pull request #292 from kareanyi/develop
增加了获取图文素材中文章的封面图url
2 parents b56973f + 35697da commit 3e2ebb0

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMaterialNews.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ public static class WxMpMaterialNewsArticle {
4646
* (必填) 图文消息缩略图的media_id,可以在基础支持-上传多媒体文件接口中获得
4747
*/
4848
private String thumbMediaId;
49+
/**
50+
* 图文消息的封面url
51+
*/
52+
private String thumbUrl;
4953
/**
5054
* 图文消息的作者
5155
*/
@@ -141,9 +145,17 @@ public void setUrl(String url) {
141145
this.url = url;
142146
}
143147

148+
public String getThumbUrl() {
149+
return thumbUrl;
150+
}
151+
152+
public void setThumbUrl(String thumbUrl) {
153+
this.thumbUrl = thumbUrl;
154+
}
155+
144156
@Override
145157
public String toString() {
146-
return "WxMpMassNewsArticle [" + "thumbMediaId=" + thumbMediaId + ", author=" + author + ", title=" + title +
158+
return "WxMpMassNewsArticle [" + "thumbMediaId=" + thumbMediaId + "thumbUrl=" + thumbUrl + ", author=" + author + ", title=" + title +
147159
", contentSourceUrl=" + contentSourceUrl + ", content=" + content + ", digest=" + digest +
148160
", showCoverPic=" + showCoverPic +", url=" + url + "]";
149161
}

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMaterialNewsArticleGsonAdapter.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public JsonElement serialize(WxMpMaterialNews.WxMpMaterialNewsArticle article, T
2020
JsonObject articleJson = new JsonObject();
2121

2222
articleJson.addProperty("thumb_media_id", article.getThumbMediaId());
23+
articleJson.addProperty("thumb_url",article.getThumbUrl());
2324
articleJson.addProperty("title", article.getTitle());
2425
articleJson.addProperty("content", article.getContent());
2526
if (null != article.getAuthor()) {
@@ -66,6 +67,10 @@ public WxMpMaterialNews.WxMpMaterialNewsArticle deserialize(JsonElement jsonElem
6667
if (thumbMediaId != null && !thumbMediaId.isJsonNull()) {
6768
article.setThumbMediaId(GsonHelper.getAsString(thumbMediaId));
6869
}
70+
JsonElement thumbUrl = articleInfo.get("thumb_url");
71+
if(thumbUrl != null && !thumbUrl.isJsonNull()) {
72+
article.setThumbUrl(GsonHelper.getAsString(thumbUrl));
73+
}
6974
JsonElement showCoverPic = articleInfo.get("show_cover_pic");
7075
if (showCoverPic != null && !showCoverPic.isJsonNull()) {
7176
article.setShowCoverPic(GsonHelper.getAsBoolean(showCoverPic));

0 commit comments

Comments
 (0)