Commit 3314de2c authored by 王亚雷's avatar 王亚雷

游客权限

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