|  |  |  | @ -1,11 +1,18 @@ | 
			
		
	
		
			
				
					|  |  |  |  | package com.luojia_channel.modules.post.service.impl; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 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.service.impl.ServiceImpl; | 
			
		
	
		
			
				
					|  |  |  |  | import com.luojia_channel.common.domain.page.PageResponse; | 
			
		
	
		
			
				
					|  |  |  |  | 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.PostBasicInfoDTO; | 
			
		
	
		
			
				
					|  |  |  |  | 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.service.CommentService; | 
			
		
	
		
			
				
					|  |  |  |  | import lombok.RequiredArgsConstructor; | 
			
		
	
	
		
			
				
					|  |  |  | @ -48,22 +55,12 @@ public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> impl | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |  |     public Page<CommentInfoDTO> getCommentsByPostId(Long postId, int pageNum, int pageSize) { | 
			
		
	
		
			
				
					|  |  |  |  |         LambdaQueryWrapper<Comment> queryWrapper = new LambdaQueryWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |  |         queryWrapper.eq(Comment::getPostId, postId) | 
			
		
	
		
			
				
					|  |  |  |  |                 .isNull(Comment::getParentCommentId) | 
			
		
	
		
			
				
					|  |  |  |  |                 .orderByAsc(Comment::getCreateTime); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         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; | 
			
		
	
		
			
				
					|  |  |  |  |     public PageResponse<CommentInfoDTO> getCommentsByPostId(CommentPageQueryDTO commentPageQueryDTO) { | 
			
		
	
		
			
				
					|  |  |  |  |         LambdaQueryWrapper<Comment> queryWrapper = Wrappers.lambdaQuery(Comment.class) | 
			
		
	
		
			
				
					|  |  |  |  |                 .eq(Comment::getPostId, commentPageQueryDTO.getPostId()) | 
			
		
	
		
			
				
					|  |  |  |  |                 .orderByDesc(Comment::getCreateTime); | 
			
		
	
		
			
				
					|  |  |  |  |         IPage<Comment> commentPage = commentMapper.selectPage(PageUtil.convert(commentPageQueryDTO), queryWrapper); | 
			
		
	
		
			
				
					|  |  |  |  |         return PageUtil.convert(commentPage, CommentInfoDTO.class); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Override | 
			
		
	
	
		
			
				
					|  |  |  | 
 |