huanghongfa
2021-07-24 34e50f2c23ff7cc7f0dbf2a40e3d038b30aec12f
测试社区动态
1个文件已修改
14 ■■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/WxOfficialApi.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/WxOfficialApi.java
@@ -154,27 +154,23 @@
                try {
                    String url = "https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token=" + token;
                    String result = getActicle(url);
//                    log.info("通过token获取文章列表成功,返回结果:" + result);
                    log.info("通过token获取文章列表成功,返回结果:" + result);
                    JSONObject resultJson = JSON.parseObject(result);
                    if(resultJson != null){
                        List<JSONObject> itemList = JSON.parseArray(resultJson.getString("item"),JSONObject.class);
                        if(!itemList.isEmpty()){
                            for (JSONObject object : itemList) {
                                String mediaId = object.getString("media_id");
                                String newsId = object.getString("media_id");
                                JSONObject contentJson = JSON.parseObject(object.getString("content"));
                                List<JSONObject> newsItemList = JSON.parseArray(contentJson.getString("news_item"),JSONObject.class);
                                String newsUrl = newsItemList.get(0).getString("url");
                                log.info("对象信息设置前:" + newsItemList.get(0));
                                newsItemList.get(0).put("news_id",mediaId);
                                log.info("对象信息设置后:" + newsItemList.get(0));
                                log.info("对象集合数据:" + newsItemList);
                                newsItemList.get(0).put("news_id",newsId);
                                contentJson.put("news_item",newsItemList);
                                object.put("content",contentJson);
                                ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue();
                                valueOperations.set(UserConstants.NEWS_ID + mediaId, newsUrl + "", 2, TimeUnit.DAYS);
                                valueOperations.set(UserConstants.NEWS_ID + newsId, newsUrl + "", 2, TimeUnit.DAYS);
                            }
                        }
                        resultJson.put("item",itemList);
@@ -190,7 +186,7 @@
    @ApiOperation(value = "获取公众号文章链接")
    @GetMapping(value = "/get/noToken")
    public R getDiscuss(@RequestParam("mediaId") Long mediaId){
    public R getDiscuss(@RequestParam("mediaId") String mediaId){
        String key = UserConstants.NEWS_ID + mediaId;
        Boolean hasKey = stringRedisTemplate.hasKey(key);