Showing
1 changed file
with
13 additions
and
10 deletions
@@ -2233,7 +2233,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService { | @@ -2233,7 +2233,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService { | ||
2233 | public List<GrassArticleBlock> handleContentWithAt(List<GrassArticleBlock> blockList){ | 2233 | public List<GrassArticleBlock> handleContentWithAt(List<GrassArticleBlock> blockList){ |
2234 | List<GrassArticleBlock> textBlockList = blockList.stream().filter(articleBlock -> articleBlock.getTemplateKey().equals("text")).collect(Collectors.toList()); | 2234 | List<GrassArticleBlock> textBlockList = blockList.stream().filter(articleBlock -> articleBlock.getTemplateKey().equals("text")).collect(Collectors.toList()); |
2235 | List<Integer> uids = Lists.newArrayList(); | 2235 | List<Integer> uids = Lists.newArrayList(); |
2236 | - if(CollectionUtils.isEmpty(blockList)){ | 2236 | + if(CollectionUtils.isEmpty(textBlockList)){ |
2237 | return blockList; | 2237 | return blockList; |
2238 | } | 2238 | } |
2239 | Pattern p = Pattern.compile("@[0-9]+#"); | 2239 | Pattern p = Pattern.compile("@[0-9]+#"); |
@@ -2252,17 +2252,20 @@ public class GrassArticleServiceImpl implements IGrassArticleService { | @@ -2252,17 +2252,20 @@ public class GrassArticleServiceImpl implements IGrassArticleService { | ||
2252 | userInfoMap.put(userInfoRspBO.getUid(), userInfoRspBO); | 2252 | userInfoMap.put(userInfoRspBO.getUid(), userInfoRspBO); |
2253 | }); | 2253 | }); |
2254 | blockList.forEach(grassArticleBlock -> { | 2254 | blockList.forEach(grassArticleBlock -> { |
2255 | - String content = grassArticleBlock.getContentData(); | ||
2256 | - Matcher m = p.matcher(content); | ||
2257 | - while(m.find()){ | ||
2258 | - String uidStr = m.group(); | ||
2259 | - Integer uid = Integer.valueOf(uidStr.replaceAll("@","").replaceAll("#","")); | ||
2260 | - UserInfoRspBO userInfo = userInfoMap.get(uid); | ||
2261 | - if(userInfo != null){ | ||
2262 | - content = content.replace(uidStr, "@"+userInfo.getNickName()); | 2255 | + if(grassArticleBlock.getTemplateKey().equals("text")){ |
2256 | + String content = grassArticleBlock.getContentData(); | ||
2257 | + Matcher m = p.matcher(content); | ||
2258 | + while(m.find()){ | ||
2259 | + String uidStr = m.group(); | ||
2260 | + Integer uid = Integer.valueOf(uidStr.replaceAll("@","").replaceAll("#","")); | ||
2261 | + UserInfoRspBO userInfo = userInfoMap.get(uid); | ||
2262 | + if(userInfo != null){ | ||
2263 | + content = content.replace(uidStr, "@"+userInfo.getNickName()); | ||
2264 | + } | ||
2263 | } | 2265 | } |
2266 | + grassArticleBlock.setContentData(content); | ||
2264 | } | 2267 | } |
2265 | - grassArticleBlock.setContentData(content); | 2268 | + |
2266 | }); | 2269 | }); |
2267 | } | 2270 | } |
2268 | 2271 |
-
Please register or login to post a comment