huanghongfa
2021-07-24 34e50f2c23ff7cc7f0dbf2a40e3d038b30aec12f
springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/WxOfficialApi.java
@@ -161,16 +161,19 @@
                        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);
                                newsItemList.get(0).put("news_id",mediaId);
                                String newsUrl = newsItemList.get(0).getString("url");
                                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);
                    }
                    resultList.add(resultJson);
                }catch (Exception e){
@@ -183,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);