Commit 30e71f2b authored by 刘基明's avatar 刘基明

Merge branch 'dev' into 'master'

Dev

See merge request !6
parents 74eaf872 39f251c0
......@@ -18,6 +18,7 @@ import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoOrg;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp;
import com.tanpu.community.api.beans.vo.feign.fund.FundCompanySimpleVO;
import com.tanpu.community.api.enums.*;
import com.tanpu.community.cache.RedisCache;
import com.tanpu.community.dao.entity.community.FollowRelEntity;
import com.tanpu.community.dao.mapper.community.FollowRelMapper;
import com.tanpu.community.feign.course.FeignClientForCourse;
......@@ -38,6 +39,8 @@ import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import static com.tanpu.community.api.constants.RedisKeyConstant.CACHE_FEIGN_USER_INFO;
@Service
public class HomePageManager {
......@@ -55,6 +58,8 @@ public class HomePageManager {
private FeignForFund feignForFund;
@Resource
private FeignForPublicFund feignForPublicFund;
@Resource
private RedisCache redisCache;
//查询 个人中心 相关信息
public UserInfoResp queryUsersInfo(String userIdMyself, String userId) {
......@@ -155,6 +160,9 @@ public class HomePageManager {
CommonResp<Integer> integerCommonResp = feignClientForCourse.getStudyCourseCount(userId);
if (integerCommonResp.isSuccess()) userInfoNew.setCourseNumber(integerCommonResp.getData());
}
//刷新用户缓存
redisCache.put(StringUtils.joinWith("_", CACHE_FEIGN_USER_INFO, userId), userInfoNew, 60);
return userInfoNew;
}
......
......@@ -173,7 +173,6 @@ public class ThemeManager {
themeEntity.setContent(JsonUtil.toJson(req.getContent()));
if (StringUtils.isBlank(req.getEditThemeId())) {
// 新建
themeService.insertTheme(themeEntity);
......@@ -209,11 +208,11 @@ public class ThemeManager {
*/
private void checkAttachment(List<ThemeContentReq> themeAttachments) {
for (ThemeContentReq content : themeAttachments) {
if (content.getType() == null ) {
if (content.getType() == null) {
throw new IllegalArgumentException("主题内容ThemeContentReq缺少类型");
}
Set<String> types = Arrays.stream(RelTypeEnum.values()).map(o->o.type).collect(Collectors.toSet());
if (!types.contains(content.getType())){
Set<String> types = Arrays.stream(RelTypeEnum.values()).map(o -> o.type).collect(Collectors.toSet());
if (!types.contains(content.getType())) {
throw new IllegalArgumentException("主题内容ThemeContentReq类型错误");
}
if (content.getType().equals(RelTypeEnum.FUND.type)) {
......@@ -258,7 +257,6 @@ public class ThemeManager {
/**
* 查询主题列表:推荐/关注/热门/最新
*
*/
// 查询主题列表:推荐/关注/热门/最新
public ThemeListResp queryList(ThemeListReq req, String userId) {
......@@ -358,7 +356,6 @@ public class ThemeManager {
themeQo.setFormerTheme(former);
// 点赞,收藏,转发
Integer likeCount = redisCache.getObject(StringUtils.joinWith("_", THEME_LIKE_COUNT, themeId), 60,
() -> collectionService.getCountByTypeAndId(themeId, CollectionTypeEnum.LIKE_THEME), Integer.class);
......@@ -436,15 +433,18 @@ public class ThemeManager {
}
List<ThemeQo> themeQos = convertEntityToQo(themeEntities, userId);
if (userId.equals(req.getUserId()) && !ThemeRecordTypeEnum.COLLECT_LIST.getCode().equals(req.getRecordType())
&& !ThemeRecordTypeEnum.LIKE_LIST.getCode().equals(req.getRecordType())) {
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));
themeQos.forEach(o -> {
if (o.getAuthorId().equals(userId)) {
reBuildAuthorInfo(o, user);
}
});
redisCache.put(StringUtils.joinWith("_", CACHE_FEIGN_USER_INFO, userId), user, 60);
}
......@@ -693,7 +693,7 @@ public class ThemeManager {
themeQo.setWorkshopIntroduction(userInfo.getWorkshopIntroduction());
}
private void evictThemeCache(String themeId){
private void evictThemeCache(String themeId) {
redisCache.evict(StringUtils.joinWith("_", CACHE_FORWARD_THEME_ID, themeId));
redisCache.evict(StringUtils.joinWith("_", CACHE_THEME_ID, themeId));
}
......
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