Commit cb457094 authored by 刘基明's avatar 刘基明

个人信息缓存 fix

parent 6bb304f9
...@@ -183,15 +183,16 @@ public class ThemeManager { ...@@ -183,15 +183,16 @@ public class ThemeManager {
/** /**
* 参数校验 * 参数校验
*
* @param themeAttachments * @param themeAttachments
*/ */
private void checkAttachment( List<ThemeContentReq> themeAttachments) { private void checkAttachment(List<ThemeContentReq> themeAttachments) {
for (ThemeContentReq content : themeAttachments) { for (ThemeContentReq content : themeAttachments) {
if (content.getType()==null){ if (content.getType() == null) {
throw new IllegalArgumentException("主题内容ThemeContentReq缺少类型"); throw new IllegalArgumentException("主题内容ThemeContentReq缺少类型");
} }
if (content.getType().equals(RelTypeEnum.FUND.type)){ if (content.getType().equals(RelTypeEnum.FUND.type)) {
if (content.getProductType()==null){ if (content.getProductType() == null) {
throw new IllegalArgumentException("附件产品FUND缺少类型"); throw new IllegalArgumentException("附件产品FUND缺少类型");
} }
} }
...@@ -258,7 +259,6 @@ public class ThemeManager { ...@@ -258,7 +259,6 @@ public class ThemeManager {
themes = RankUtils.sortThemeEntityByIds(themes, recmdIds).stream().limit(pageSize).collect(Collectors.toList()); themes = RankUtils.sortThemeEntityByIds(themes, recmdIds).stream().limit(pageSize).collect(Collectors.toList());
} else if (ThemeListTypeEnum.FOLLOW.getCode().equals(req.getType())) { } else if (ThemeListTypeEnum.FOLLOW.getCode().equals(req.getType())) {
// 根据关注列表查询,按时间倒序 // 根据关注列表查询,按时间倒序
List<String> fansList = followRelService.queryIdolsByFollowerId(userId); List<String> fansList = followRelService.queryIdolsByFollowerId(userId);
...@@ -314,7 +314,7 @@ public class ThemeManager { ...@@ -314,7 +314,7 @@ public class ThemeManager {
} }
// 和用户相关信息 // 和用户相关信息
buildThemeExtraInfoByUser(userId,themeQos); buildThemeExtraInfoByUser(userId, themeQos);
return themeQos; return themeQos;
} }
...@@ -391,6 +391,18 @@ public class ThemeManager { ...@@ -391,6 +391,18 @@ public class ThemeManager {
break; break;
} }
List<ThemeQo> themeQos = convertEntityToQo(themeEntities, userId); List<ThemeQo> themeQos = convertEntityToQo(themeEntities, userId);
if (userId.equals(req.getUserId())) {
//如果用户是查询自己的帖子,需要实时查询用户自己的个人信息,防止数据不一致
CommonResp<UserInfoResp> userInfoNewCommonResp = feignClientForFatools.queryUsersListNew(userId);
if (userInfoNewCommonResp.isNotSuccess()) {
throw new BizException("内部接口调用失败");
}
UserInfoResp user = userInfoNewCommonResp.getData();
themeQos.stream().forEach(o->reBuildAuthorInfo(o,user));
redisCache.put(StringUtils.joinWith("_", CACHE_FEIGN_USER_INFO, userId), user, 60);
}
return themeQos; return themeQos;
} }
...@@ -485,8 +497,8 @@ public class ThemeManager { ...@@ -485,8 +497,8 @@ public class ThemeManager {
// 逻辑删除主题,校验用户 // 逻辑删除主题,校验用户
public void delete(String themeId,String userId) { public void delete(String themeId, String userId) {
themeService.deleteById(themeId,userId); themeService.deleteById(themeId, userId);
} }
...@@ -498,7 +510,7 @@ public class ThemeManager { ...@@ -498,7 +510,7 @@ public class ThemeManager {
private void checkContent(CreateThemeReq req) { private void checkContent(CreateThemeReq req) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (ThemeContentReq themeContentReq : req.getContent()) { for (ThemeContentReq themeContentReq : req.getContent()) {
if (RelTypeEnum.TEXT.type.equals(themeContentReq.getType())){ if (RelTypeEnum.TEXT.type.equals(themeContentReq.getType())) {
sb.append(themeContentReq.getValue()); sb.append(themeContentReq.getValue());
} }
} }
...@@ -610,4 +622,20 @@ public class ThemeManager { ...@@ -610,4 +622,20 @@ public class ThemeManager {
return userInfoNewCommonResp.getData(); return userInfoNewCommonResp.getData();
} }
private void reBuildAuthorInfo(ThemeQo themeQo,UserInfoResp userInfo){
themeQo.setNickName(userInfo.getNickName());
themeQo.setUserImg(userInfo.getHeadImageUrl());
themeQo.setUserIntroduction(userInfo.getIntroduction());
//认证标签相关
themeQo.setUserType(userInfo.getUserType());
themeQo.setLevelGrade(userInfo.getLevelGrade());
themeQo.setUserInvestorType(userInfo.getUserInvestorType());
themeQo.setBelongUserOrgId(userInfo.getBelongUserOrgId());
themeQo.setBelongUserOrgName(userInfo.getBelongUserOrgName());
//工作室相关
themeQo.setWorkshopName(userInfo.getWorkshopName());
themeQo.setWorkshopStatus(userInfo.getWorkshopStatus());
themeQo.setWorkshopIntroduction(userInfo.getWorkshopIntroduction());
}
} }
...@@ -39,8 +39,6 @@ public class RecommendService { ...@@ -39,8 +39,6 @@ public class RecommendService {
@Autowired @Autowired
private ThemeService themeService; private ThemeService themeService;
@Autowired
private VisitLogService visitLogService;
// 最新 // 最新
private List<ThemeAnalysDO> recentThemeList = new ArrayList<>(); private List<ThemeAnalysDO> recentThemeList = new ArrayList<>();
...@@ -133,7 +131,7 @@ public class RecommendService { ...@@ -133,7 +131,7 @@ public class RecommendService {
String id; String id;
while (hotTimes > 0 && hotThemeIds.size() > hotIdx) { while (hotTimes > 0 && hotThemeIds.size() > hotIdx) {
id = hotThemeIds.get(hotIdx); id = hotThemeIds.get(hotIdx);
if (!set.contains(id)){ if (!set.contains(id)) {
result.add(id); result.add(id);
set.add(id); set.add(id);
} }
...@@ -143,7 +141,7 @@ public class RecommendService { ...@@ -143,7 +141,7 @@ public class RecommendService {
} }
while (newTimes > 0 && newThemeIds.size() > newIdx) { while (newTimes > 0 && newThemeIds.size() > newIdx) {
id = newThemeIds.get(newIdx); id = newThemeIds.get(newIdx);
if (!set.contains(id)){ if (!set.contains(id)) {
result.add(id); result.add(id);
set.add(id); set.add(id);
} }
...@@ -153,7 +151,7 @@ public class RecommendService { ...@@ -153,7 +151,7 @@ public class RecommendService {
} }
while (recTimes > 0 && recThemeIds.size() > recIdx) { while (recTimes > 0 && recThemeIds.size() > recIdx) {
id = recThemeIds.get(recIdx); id = recThemeIds.get(recIdx);
if (!set.contains(id)){ if (!set.contains(id)) {
result.add(id); result.add(id);
set.add(id); set.add(id);
} }
......
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