|
|
@ -1,11 +1,18 @@
|
|
|
|
package com.luojia_channel.modules.post.service.impl;
|
|
|
|
package com.luojia_channel.modules.post.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
|
|
|
import com.luojia_channel.common.domain.page.PageResponse;
|
|
|
|
import com.luojia_channel.common.exception.PostException;
|
|
|
|
import com.luojia_channel.common.exception.PostException;
|
|
|
|
|
|
|
|
import com.luojia_channel.common.utils.PageUtil;
|
|
|
|
|
|
|
|
import com.luojia_channel.modules.post.dto.req.CommentPageQueryDTO;
|
|
|
|
import com.luojia_channel.modules.post.dto.resp.CommentInfoDTO;
|
|
|
|
import com.luojia_channel.modules.post.dto.resp.CommentInfoDTO;
|
|
|
|
|
|
|
|
import com.luojia_channel.modules.post.dto.resp.PostBasicInfoDTO;
|
|
|
|
import com.luojia_channel.modules.post.entity.Comment;
|
|
|
|
import com.luojia_channel.modules.post.entity.Comment;
|
|
|
|
|
|
|
|
import com.luojia_channel.modules.post.entity.Post;
|
|
|
|
import com.luojia_channel.modules.post.mapper.CommentMapper;
|
|
|
|
import com.luojia_channel.modules.post.mapper.CommentMapper;
|
|
|
|
import com.luojia_channel.modules.post.service.CommentService;
|
|
|
|
import com.luojia_channel.modules.post.service.CommentService;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
@ -48,22 +55,12 @@ public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> impl
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Page<CommentInfoDTO> getCommentsByPostId(Long postId, int pageNum, int pageSize) {
|
|
|
|
public PageResponse<CommentInfoDTO> getCommentsByPostId(CommentPageQueryDTO commentPageQueryDTO) {
|
|
|
|
LambdaQueryWrapper<Comment> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
LambdaQueryWrapper<Comment> queryWrapper = Wrappers.lambdaQuery(Comment.class)
|
|
|
|
queryWrapper.eq(Comment::getPostId, postId)
|
|
|
|
.eq(Comment::getPostId, commentPageQueryDTO.getPostId())
|
|
|
|
.isNull(Comment::getParentCommentId)
|
|
|
|
.orderByDesc(Comment::getCreateTime);
|
|
|
|
.orderByAsc(Comment::getCreateTime);
|
|
|
|
IPage<Comment> commentPage = commentMapper.selectPage(PageUtil.convert(commentPageQueryDTO), queryWrapper);
|
|
|
|
|
|
|
|
return PageUtil.convert(commentPage, CommentInfoDTO.class);
|
|
|
|
Page<Comment> page = new Page<>(pageNum, pageSize);
|
|
|
|
|
|
|
|
commentMapper.selectPage(page, queryWrapper);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Page<CommentInfoDTO> commentInfoDTOS = new Page<>();
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(page, commentInfoDTOS, "records");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<CommentInfoDTO> records = convertToDTO(page.getRecords());
|
|
|
|
|
|
|
|
commentInfoDTOS.setRecords(records);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return commentInfoDTOS;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|