Commit 2a8caa1a authored by 王亚雷's avatar 王亚雷

Merge remote-tracking branch 'origin/v2.2.7' into dev

parents 4b52cb59 3314de2c
......@@ -11,6 +11,7 @@ import com.tanpu.community.api.beans.req.comment.QueryCommentReq;
import com.tanpu.community.api.beans.req.comment.ReportCommentReq;
import com.tanpu.community.api.beans.req.page.Page;
import com.tanpu.community.manager.CommentManager;
import com.tanpu.community.util.HttpServletHelper;
import com.tanpu.community.util.PageUtils;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
......@@ -32,6 +33,9 @@ public class CommentController {
@Resource
private UserHolder userHolder;
@Resource
HttpServletHelper httpServletHelper;
@ApiOperation("发表评论")
@AuthLogin
@PostMapping(value = "/publishComment")
......@@ -42,12 +46,11 @@ public class CommentController {
}
@ApiOperation("评论列表")
@AuthLogin
@PostMapping(value = "/queryComment")
@ResponseBody
public CommonResp<Page<CommentQo>> queryComment(@Validated @RequestBody QueryCommentReq req) {
String userId = userHolder.getUserId();
List<CommentQo> result = commentManager.queryComments(req.getThemeId(), userId);
String selfUserId = httpServletHelper.getCurrentUserId();
List<CommentQo> result = commentManager.queryComments(req.getThemeId(), selfUserId);
return CommonResp.success(PageUtils.page(req.getPage(), result));
}
......
......@@ -76,10 +76,9 @@ public class HomePageController {
@PostMapping(value = "/followList")
@ApiOperation("查询关注/粉丝列表")
@ResponseBody
@AuthLogin
public CommonResp<Page<FollowQo>> queryFollowList(@RequestBody QueryFollowReq req) {
String userId = userHolder.getUserId();
return CommonResp.success(homePageManager.queryFollow(req, userId));
String selfUserId = httpServletHelper.getCurrentUserId();
return CommonResp.success(homePageManager.queryFollow(req, selfUserId));
}
@PostMapping(value = "/addIdol")
......@@ -95,10 +94,9 @@ public class HomePageController {
@PostMapping(value = "/themeList")
@ApiOperation("用户的帖子列表")
@ResponseBody
@AuthLogin
public CommonResp<List<ThemeQo>> likeList(@Validated @RequestBody QueryRecordThemeReq req) {
String userId = userHolder.getUserId();
return CommonResp.success(themeManager.queryThemesByUser(req, userId));
String selfUserId = httpServletHelper.getCurrentUserId();
return CommonResp.success(themeManager.queryThemesByUser(req, selfUserId));
}
}
package com.tanpu.community.manager;
import com.google.common.collect.Sets;
import com.tanpu.biz.common.enums.community.CollectionTypeEnum;
import com.tanpu.biz.common.enums.community.CommentTypeEnum;
import com.tanpu.biz.common.enums.community.ReportTypeEnum;
......@@ -116,7 +117,12 @@ public class CommentManager {
List<CommentEntity> commentEntities = commentService.selectByThemeId(themeId);
List<CommentQo> commentQos = ConvertUtil.commentEntity2Qos(commentEntities);
Set<String> likeCommentList = collectionService.getSetByUser(userId, CollectionTypeEnum.LIKE_COMMENT);
Set<String> likeCommentList;
if (StringUtils.isNotEmpty(userId)) {
likeCommentList = collectionService.getSetByUser(userId, CollectionTypeEnum.LIKE_COMMENT);
} else {
likeCommentList = Sets.newHashSetWithExpectedSize(0);
}
for (CommentQo commentQo : commentQos) {
// 封装用户信息
......
package com.tanpu.community.manager;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.google.common.collect.Lists;
import com.tanpu.biz.common.enums.user.UserLevelEnum;
import com.tanpu.biz.common.enums.user.UserTypeEnum;
import com.tanpu.common.api.CommonResp;
......@@ -46,6 +47,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.validation.constraints.NotEmpty;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
......@@ -257,26 +259,26 @@ public class HomePageManager {
Page<String> userIdsPage = QueryFollowTypeEnum.QUERY_FANS.getCode().equals(req.getQueryType()) ?
followRelService.queryFansByIdolId(req.userId, pageNumber, pageSize)
: followRelService.queryIdolsByFansId(req.userId, pageNumber, pageSize);
List<FollowQo> followQos = new ArrayList<>();
if (!CollectionUtils.isEmpty(userIdsPage.getContent())) {
List<UserInfoResp> userInfoNews = feignClientForFatools.queryUserListNew(userIdsPage.getContent());
List<FollowQo> collect = userInfoNews.stream().map(ConvertUtil::userInfoNew2FollowQo).collect(Collectors.toList());
followQos = judgeFollowed(collect, userId);
if (CollectionUtils.isEmpty(userIdsPage.getContent())) {
return PageUtils.page(userIdsPage, Lists.newArrayListWithCapacity(0));
}
List<UserInfoResp> userInfoNews = feignClientForFatools.queryUserListNew(userIdsPage.getContent());
List<FollowQo> followQos = userInfoNews.stream().map(ConvertUtil::userInfoNew2FollowQo).collect(Collectors.toList());
if (StringUtils.isNotEmpty(userId)) {
judgeFollowed(followQos, userId);
}
return PageUtils.page(userIdsPage, followQos);
}
//判断返回列表中的用户是否被当前用户关注
public List<FollowQo> judgeFollowed(List<FollowQo> followQos, String followerId) {
public void judgeFollowed(List<FollowQo> followQos, @NotEmpty String followerId) {
Set<String> idolSet = new HashSet<>(followRelService.queryIdolsByFansId(followerId));
return followQos.stream().map(o -> {
followQos.stream().peek(o -> {
if (idolSet.contains(o.getUserId())) {
o.setFollowed(true);
}
return o;
}).collect(Collectors.toList());
});
}
public void addFollowRel(FollowRelReq req, String followerId) {
......
......@@ -653,7 +653,7 @@ public class ThemeManager {
}
List<ThemeQo> themeQos = convertEntityToQo(themeEntities, userId);
if (userId.equals(req.getUserId())) {
if (StringUtils.equals(userId, req.getUserId())) {
//如果用户是查询自己的帖子,需要实时查询用户自己的个人信息,防止数据不一致(非收藏类型)
CommonResp<UserInfoResp> userInfoNewCommonResp = feignClientForFatools.queryUserInfoNew(userId);
if (userInfoNewCommonResp.isNotSuccess()) {
......@@ -913,7 +913,8 @@ public class ThemeManager {
.content(Collections.singletonList(commentContent))
.commentId(commentEntity.getCommentId())
.themeType(ThemeTypeEnum.RES_COMMENT.getCode())
.follow(followRelService.checkFollow(userId, userId))
// 回复列表不需要关注按钮
// .follow(followRelService.checkFollow(userInfo.getUserId(), userId))
.upToNowTime(TimeUtils.calUpToNowTime(commentEntity.getCreateTime()))
.build();
......
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