|
@@ -25,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 评论接口
|
|
@@ -95,9 +96,11 @@ public class CommunityCommentController extends BaseController {
|
|
|
//该评论的点赞数量
|
|
|
vo.setCommentLikeCount(communityCommentLikeMapper.selectList(new QueryWrapper<CommunityCommentLike>().eq("comment_id", vo.getId())).size());
|
|
|
//设置首条评论
|
|
|
- List<CommunityCommentReply> replies = communityCommentReplyService.list(new QueryWrapper<CommunityCommentReply>().eq("comment_id", vo.getId()).and((wrapper) -> {
|
|
|
- wrapper.ne("is_delete", true).or().isNull("is_delete");
|
|
|
- }).orderByDesc("create_time"));
|
|
|
+ List<CommunityCommentReply> replies = communityCommentReplyService.list(new QueryWrapper<CommunityCommentReply>()
|
|
|
+ .eq("comment_id", vo.getId())
|
|
|
+ .and((wrapper) -> {
|
|
|
+ wrapper.ne("is_delete", true).or().isNull("is_delete");
|
|
|
+ }).orderByAsc("create_time"));
|
|
|
|
|
|
CommunityCommentReplyVo replyVo = null;
|
|
|
List<CommunityCommentReplyVo> replyVos = new ArrayList<>();
|
|
@@ -106,6 +109,7 @@ public class CommunityCommentController extends BaseController {
|
|
|
BeanUtils.copyProperties(reply, replyVo);
|
|
|
replyVo.setNickName(sysUserService.selectUserById(replyVo.getUserId()).getNickName());
|
|
|
replyVos.add(replyVo);
|
|
|
+ break;
|
|
|
}
|
|
|
vo.setFirstReply(replyVos);
|
|
|
//设置还剩多少评论
|
|
@@ -135,10 +139,20 @@ public class CommunityCommentController extends BaseController {
|
|
|
.orderByDesc("create_time")).getRecords();
|
|
|
CommunityCommentReplyVo replyVo = null;
|
|
|
List<CommunityCommentReplyVo> replyVos = new ArrayList<>();
|
|
|
- for (CommunityCommentReply reply : replies) {
|
|
|
+ for (final CommunityCommentReply reply : replies) {
|
|
|
replyVo = new CommunityCommentReplyVo();
|
|
|
+ SysUser sysUser = sysUserService.selectUserById(reply.getUserId());
|
|
|
+ final Long parentReplyId = reply.getParentReplyId();
|
|
|
BeanUtils.copyProperties(reply, replyVo);
|
|
|
- SysUser sysUser = sysUserService.selectUserById(replyVo.getUserId());
|
|
|
+ if (Objects.nonNull(parentReplyId)) {
|
|
|
+ CommunityCommentReply communityCommentReply = replies.stream()
|
|
|
+ .filter(item -> item.getId().equals(parentReplyId))
|
|
|
+ .collect(Collectors.toList()).get(0);
|
|
|
+ SysUser sysUser1 = sysUserService.selectUserById(communityCommentReply.getUserId());
|
|
|
+ replyVo.setParentNickName(sysUser1.getNickName());
|
|
|
+ replyVo.setParentUserId(sysUser1.getUserId());
|
|
|
+ replyVo.setParentAvatar(sysUser1.getAvatar());
|
|
|
+ }
|
|
|
replyVo.setNickName(sysUser.getNickName());
|
|
|
replyVo.setAvatar(sysUser.getAvatar());
|
|
|
replyVos.add(replyVo);
|