| | |
| | | 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){ |
| | |
| | | |
| | | @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); |