|
11 | 11 | import com.anyshare.service.eventdriven.event.ResourceUpdateEvent;
|
12 | 12 | import lombok.extern.slf4j.Slf4j;
|
13 | 13 | import me.chanjar.weixin.common.error.WxErrorException;
|
| 14 | +import me.chanjar.weixin.mp.api.WxMpFreePublishService; |
14 | 15 | import me.chanjar.weixin.mp.api.WxMpMaterialService;
|
| 16 | +import me.chanjar.weixin.mp.bean.freepublish.WxMpFreePublishArticles; |
| 17 | +import me.chanjar.weixin.mp.bean.freepublish.WxMpFreePublishItem; |
| 18 | +import me.chanjar.weixin.mp.bean.freepublish.WxMpFreePublishList; |
15 | 19 | import me.chanjar.weixin.mp.bean.material.WxMpMaterialCountResult;
|
16 | 20 | import me.chanjar.weixin.mp.bean.material.WxMpMaterialNewsBatchGetResult;
|
17 | 21 | import me.chanjar.weixin.mp.bean.material.WxMpNewsArticle;
|
@@ -231,6 +235,50 @@ public void materialNewsSynchronizer(String appTag, WxMpMaterialService wxMpMate
|
231 | 235 | }
|
232 | 236 | }
|
233 | 237 |
|
| 238 | + /** |
| 239 | + * 拉取永久素材中的图文 |
| 240 | + */ |
| 241 | + @Override |
| 242 | + public void freePublishSynchronizer(String appTag, WxMpFreePublishService freePublishService) throws WxErrorException { |
| 243 | + int startIndex = 0; |
| 244 | + int size = 10; |
| 245 | + Integer totalCount; |
| 246 | + Integer itemCount; |
| 247 | + do { |
| 248 | + WxMpFreePublishList wxMpFreePublishList = freePublishService.getPublicationRecords(startIndex, size); |
| 249 | + totalCount = wxMpFreePublishList.getTotalCount(); |
| 250 | + itemCount = wxMpFreePublishList.getItemCount(); |
| 251 | + log.info("appTag = {}, totalCount = {}, itemCount = {}", appTag, totalCount, itemCount); |
| 252 | + List<WxMpFreePublishItem> items = wxMpFreePublishList.getItems(); |
| 253 | + if (CollectionUtils.isNotEmpty(items)) { |
| 254 | + for (WxMpFreePublishItem item : items) { |
| 255 | + if (item != null && item.getContent() != null && item.getContent().getNewsItem() != null) { |
| 256 | + List<WxMpFreePublishArticles> freePublishArticles = item.getContent().getNewsItem(); |
| 257 | + for (WxMpFreePublishArticles freePublishArticle : freePublishArticles) { |
| 258 | + WxMpNewsArticlePO wxMpNewsArticle = WxMpNewsArticlePO.createDefault(WxMpNewsArticlePO.class); |
| 259 | + wxMpNewsArticle.setUrl(freePublishArticle.getUrl()); |
| 260 | + wxMpNewsArticle.setThumbMediaId(freePublishArticle.getThumbMediaId()); |
| 261 | + wxMpNewsArticle.setAuthor(freePublishArticle.getAuthor()); |
| 262 | + wxMpNewsArticle.setTitle(freePublishArticle.getTitle()); |
| 263 | + wxMpNewsArticle.setContentSourceUrl(freePublishArticle.getContentSourceUrl()); |
| 264 | + wxMpNewsArticle.setContent(freePublishArticle.getContent()); |
| 265 | + wxMpNewsArticle.setDigest(freePublishArticle.getDigest()); |
| 266 | + Integer showCoverPic = freePublishArticle.getShowCoverPic(); |
| 267 | + wxMpNewsArticle.setShowCoverPic(showCoverPic != null && showCoverPic == 1); |
| 268 | + wxMpNewsArticle.setUrl(freePublishArticle.getUrl()); |
| 269 | + Integer needOpenComment = freePublishArticle.getNeedOpenComment(); |
| 270 | + wxMpNewsArticle.setNeedOpenComment(needOpenComment != null && needOpenComment == 1); |
| 271 | + Integer onlyFansCanComment = freePublishArticle.getOnlyFansCanComment(); |
| 272 | + wxMpNewsArticle.setOnlyFansCanComment(onlyFansCanComment != null && onlyFansCanComment == 1); |
| 273 | + wxMpNewsArticle.setAppTag(appTag); |
| 274 | + wxMpNewsArticleService.insert(appTag, wxMpNewsArticle); |
| 275 | + } |
| 276 | + } |
| 277 | + } |
| 278 | + } |
| 279 | + } while (startIndex > (totalCount + size)); |
| 280 | + } |
| 281 | + |
234 | 282 | @Override
|
235 | 283 | public void reindexEsContent(String appTag) {
|
236 | 284 | if (reindexEsContentLock.tryLock()) {
|
|
0 commit comments