feat:cms comment list

main
wangqing 10 months ago
parent 6be1f10e51
commit dcc14f9190

@ -71,6 +71,13 @@ public class CommentController extends BaseController {
}
@GetMapping("/{page}/{size}")
public Result search(@PathVariable int page,@PathVariable int size){
Page<Comment> pageData = commentService.search(page,size);
return Result.success(new PageResult<Comment>(pageData.getTotalElements(),pageData.getContent()));
}
@GetMapping("/{commentId}")
public Result findById(@PathVariable String commentId){
return Result.success(commentService.findById(commentId));

@ -9,4 +9,6 @@ public interface CommentDao extends MongoRepository<Comment,String> {
public Page<Comment> findByParentId(String parentId, Pageable pageable);
public Page<Comment> findByJournalId(String journalId, Pageable pageable);
public Page<Comment> findAllByOrderByPublishTimeDesc(Pageable pageable);
}

@ -127,4 +127,9 @@ public class CommentService {
userMessageDto.setSendUserNickName(userLoginDto.getNickName());
rabbitTemplate.convertAndSend("userMessage",userMessageDto);
}
public Page<Comment> search(int page, int size) {
Pageable pageable = PageRequest.of(page-1,size);
return commentDao.findAllByOrderByPublishTimeDesc(pageable);
}
}

Loading…
Cancel
Save