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

缓存修复

parent d1466e17
......@@ -30,7 +30,7 @@ public class RedisKeyConstant {
public static final String THEME_APPEAR_IN_SEARCH_LIST = "THEME_APPEAR_IN_SEARCH_LIST_";
// 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_";
// 评论本身
......
......@@ -28,7 +28,7 @@ import java.util.List;
import java.util.Set;
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
public class CommentManager {
......@@ -74,7 +74,7 @@ public class CommentManager {
for (CommentQo commentQo : commentQos) {
//查询用户信息
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);
if (userInfo != null) {
commentQo.setUserImg(userInfo.getHeadImageUrl());
......
......@@ -439,7 +439,7 @@ public class ThemeManager {
//评论列表
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);
Set<String> replyThemeIds = commentEntities.stream().map(CommentEntity::getThemeId).collect(Collectors.toSet());
if (CollectionUtils.isEmpty(replyThemeIds)) {
......@@ -462,6 +462,10 @@ public class ThemeManager {
.build();
//原主题包装到FormerThemeQo中
ThemeQo themeQo = themeMap.get(themeId);
//如果原文被删除,跳过
if (themeQo==null){
continue;
}
FormerThemeQo f = ConvertUtil.themeQo2FormerThemeQo(themeQo);
//ThemeContentQo和原主题包装到FormerThemeQo中包装到ThemeQo中
ThemeQo commentThemeQo = ThemeQo.builder()
......
......@@ -21,7 +21,7 @@ import javax.annotation.Resource;
import java.util.*;
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
public class RankService {
......@@ -55,7 +55,7 @@ public class RankService {
*/
public void rankThemes() {
//7天内所有主题进行热度值排序
List<ThemeEntity> themeEntities = themeService.queryRecentdays(4);
List<ThemeEntity> themeEntities = themeService.queryRecentdays(7);
List<ThemeAnalysDO> themeAnalysDOS = ConvertUtil.themeEntityToAnalysDOs(themeEntities);
for (ThemeAnalysDO theme : themeAnalysDOS) {
String themeId = theme.getThemeId();
......@@ -71,7 +71,7 @@ public class RankService {
theme.setViewCount(viewCount);
//查询用户质量
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);
if (authorInfo == null || authorInfo.getLevelGrade() == null) {
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