Commit 345b5acc authored by 刘基明's avatar 刘基明

缓存修复

parent d1466e17
...@@ -30,7 +30,7 @@ public class RedisKeyConstant { ...@@ -30,7 +30,7 @@ public class RedisKeyConstant {
public static final String THEME_APPEAR_IN_SEARCH_LIST = "THEME_APPEAR_IN_SEARCH_LIST_"; public static final String THEME_APPEAR_IN_SEARCH_LIST = "THEME_APPEAR_IN_SEARCH_LIST_";
// feign 查询用户信息 // feign 查询用户信息
public static final String CACGE_FEIGN_USER_INFO = "CACHE_FEIGN_USER_INFO_"; public static final String CACHE_FEIGN_USER_INFO = "CACHE_FEIGN_USER_INFO_";
// 主题下的评论 // 主题下的评论
public static final String CACHE_COMMENT_THEMEID = "CACHE_COMMENT_THEMEID_"; public static final String CACHE_COMMENT_THEMEID = "CACHE_COMMENT_THEMEID_";
// 评论本身 // 评论本身
......
...@@ -28,7 +28,7 @@ import java.util.List; ...@@ -28,7 +28,7 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.tanpu.community.api.constants.RedisKeyConstant.CACGE_FEIGN_USER_INFO; import static com.tanpu.community.api.constants.RedisKeyConstant.CACHE_FEIGN_USER_INFO;
@Service @Service
public class CommentManager { public class CommentManager {
...@@ -74,7 +74,7 @@ public class CommentManager { ...@@ -74,7 +74,7 @@ public class CommentManager {
for (CommentQo commentQo : commentQos) { for (CommentQo commentQo : commentQos) {
//查询用户信息 //查询用户信息
String authorId = commentQo.getAuthorId(); String authorId = commentQo.getAuthorId();
UserInfoNew userInfo = redisCache.getObject(StringUtils.joinWith(CACGE_FEIGN_USER_INFO, authorId), UserInfoNew userInfo = redisCache.getObject(StringUtils.joinWith(CACHE_FEIGN_USER_INFO, authorId),
60 * 10, () ->this.getUserInfo(authorId) , UserInfoNew.class); 60 * 10, () ->this.getUserInfo(authorId) , UserInfoNew.class);
if (userInfo != null) { if (userInfo != null) {
commentQo.setUserImg(userInfo.getHeadImageUrl()); commentQo.setUserImg(userInfo.getHeadImageUrl());
......
...@@ -439,7 +439,7 @@ public class ThemeManager { ...@@ -439,7 +439,7 @@ public class ThemeManager {
//评论列表 //评论列表
List<CommentEntity> commentEntities = commentService.queryThemesByUserId(req.getUserId(), req.getLastId(), req.getPageSize()); List<CommentEntity> commentEntities = commentService.queryThemesByUserId(req.getUserId(), req.getLastId(), req.getPageSize());
//当前用户信息 //当前用户信息
UserInfoNew userInfo = redisCache.getObject(StringUtils.joinWith(CACGE_FEIGN_USER_INFO, req.getUserId()), UserInfoNew userInfo = redisCache.getObject(StringUtils.joinWith(CACHE_FEIGN_USER_INFO, req.getUserId()),
60 * 10, () ->this.getUserInfo(req.getUserId()) , UserInfoNew.class); 60 * 10, () ->this.getUserInfo(req.getUserId()) , UserInfoNew.class);
Set<String> replyThemeIds = commentEntities.stream().map(CommentEntity::getThemeId).collect(Collectors.toSet()); Set<String> replyThemeIds = commentEntities.stream().map(CommentEntity::getThemeId).collect(Collectors.toSet());
if (CollectionUtils.isEmpty(replyThemeIds)) { if (CollectionUtils.isEmpty(replyThemeIds)) {
...@@ -462,6 +462,10 @@ public class ThemeManager { ...@@ -462,6 +462,10 @@ public class ThemeManager {
.build(); .build();
//原主题包装到FormerThemeQo中 //原主题包装到FormerThemeQo中
ThemeQo themeQo = themeMap.get(themeId); ThemeQo themeQo = themeMap.get(themeId);
//如果原文被删除,跳过
if (themeQo==null){
continue;
}
FormerThemeQo f = ConvertUtil.themeQo2FormerThemeQo(themeQo); FormerThemeQo f = ConvertUtil.themeQo2FormerThemeQo(themeQo);
//ThemeContentQo和原主题包装到FormerThemeQo中包装到ThemeQo中 //ThemeContentQo和原主题包装到FormerThemeQo中包装到ThemeQo中
ThemeQo commentThemeQo = ThemeQo.builder() ThemeQo commentThemeQo = ThemeQo.builder()
......
...@@ -21,7 +21,7 @@ import javax.annotation.Resource; ...@@ -21,7 +21,7 @@ import javax.annotation.Resource;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.tanpu.community.api.constants.RedisKeyConstant.CACGE_FEIGN_USER_INFO; import static com.tanpu.community.api.constants.RedisKeyConstant.CACHE_FEIGN_USER_INFO;
@Service @Service
public class RankService { public class RankService {
...@@ -55,7 +55,7 @@ public class RankService { ...@@ -55,7 +55,7 @@ public class RankService {
*/ */
public void rankThemes() { public void rankThemes() {
//7天内所有主题进行热度值排序 //7天内所有主题进行热度值排序
List<ThemeEntity> themeEntities = themeService.queryRecentdays(4); List<ThemeEntity> themeEntities = themeService.queryRecentdays(7);
List<ThemeAnalysDO> themeAnalysDOS = ConvertUtil.themeEntityToAnalysDOs(themeEntities); List<ThemeAnalysDO> themeAnalysDOS = ConvertUtil.themeEntityToAnalysDOs(themeEntities);
for (ThemeAnalysDO theme : themeAnalysDOS) { for (ThemeAnalysDO theme : themeAnalysDOS) {
String themeId = theme.getThemeId(); String themeId = theme.getThemeId();
...@@ -71,7 +71,7 @@ public class RankService { ...@@ -71,7 +71,7 @@ public class RankService {
theme.setViewCount(viewCount); theme.setViewCount(viewCount);
//查询用户质量 //查询用户质量
String authorId = theme.getAuthorId(); String authorId = theme.getAuthorId();
UserInfoNew authorInfo = redisCache.getObject(StringUtils.joinWith(CACGE_FEIGN_USER_INFO, authorId), UserInfoNew authorInfo = redisCache.getObject(StringUtils.joinWith(CACHE_FEIGN_USER_INFO, authorId),
60 * 10, () -> this.getUserInfo(authorId), UserInfoNew.class); 60 * 10, () -> this.getUserInfo(authorId), UserInfoNew.class);
if (authorInfo == null || authorInfo.getLevelGrade() == null) { if (authorInfo == null || authorInfo.getLevelGrade() == null) {
theme.setUserWeight(0.0); theme.setUserWeight(0.0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment