mirror of
https://github.com/201206030/novel-cloud.git
synced 2025-06-24 14:06:39 +00:00
修复部分分页接口的查询bug
This commit is contained in:
@ -3,6 +3,7 @@ package com.java2nb.novel.book.api;
|
||||
import com.java2nb.novel.book.entity.Book;
|
||||
import com.java2nb.novel.book.entity.BookComment;
|
||||
import com.java2nb.novel.book.vo.BookCommentVO;
|
||||
import com.java2nb.novel.common.bean.PageBean;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@ -70,7 +71,7 @@ public interface BookApi {
|
||||
* @return 评论数据
|
||||
* */
|
||||
@GetMapping("api/book/listUserCommentByPage")
|
||||
List<BookComment> listUserCommentByPage(@RequestParam("userId") Long userId,@RequestParam("page") int page, @RequestParam("pageSize") int pageSize);
|
||||
PageBean<BookComment> listUserCommentByPage(@RequestParam("userId") Long userId, @RequestParam("page") int page, @RequestParam("pageSize") int pageSize);
|
||||
|
||||
/**
|
||||
* 查询网络图片的小说
|
||||
|
@ -3,6 +3,7 @@ package com.java2nb.novel.book.api.fallback;
|
||||
import com.java2nb.novel.book.api.BookApi;
|
||||
import com.java2nb.novel.book.entity.Book;
|
||||
import com.java2nb.novel.book.entity.BookComment;
|
||||
import com.java2nb.novel.common.bean.PageBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@ -43,8 +44,8 @@ public class BookApiFallback implements BookApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BookComment> listUserCommentByPage(Long userId, int page, int pageSize) {
|
||||
return new ArrayList<>();
|
||||
public PageBean<BookComment> listUserCommentByPage(Long userId, int page, int pageSize) {
|
||||
return new PageBean<>(new ArrayList<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -107,7 +107,7 @@ public class BookController {
|
||||
@ApiOperation("书籍评论列表分页查询接口")
|
||||
@GetMapping("listCommentByPage")
|
||||
public ResultBean<List<BookCommentVO>> listCommentByPage(@ApiParam("小说ID") @RequestParam("bookId") Long bookId, @ApiParam("当前页码") @RequestParam(value = "curr", defaultValue = "1") int page, @ApiParam("分页大小") @RequestParam(value = "limit", defaultValue = "5") int pageSize) {
|
||||
return ResultBean.ok(new PageBean<>(bookService.listBookCommentByPage(bookId,page,pageSize)));
|
||||
return ResultBean.ok(bookService.listBookCommentByPage(bookId,page,pageSize));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,6 +4,7 @@ import com.java2nb.novel.book.entity.Book;
|
||||
import com.java2nb.novel.book.entity.BookComment;
|
||||
import com.java2nb.novel.book.service.BookService;
|
||||
import com.java2nb.novel.book.vo.BookCommentVO;
|
||||
import com.java2nb.novel.common.bean.PageBean;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
@ -89,7 +90,7 @@ public class BookApi {
|
||||
* @return 评论数据
|
||||
* */
|
||||
@GetMapping("listUserCommentByPage")
|
||||
List<BookComment> listUserCommentByPage(@RequestParam("userId") Long userId,@RequestParam("page") int page, @RequestParam("pageSize") int pageSize){
|
||||
PageBean<BookComment> listUserCommentByPage(@RequestParam("userId") Long userId, @RequestParam("page") int page, @RequestParam("pageSize") int pageSize){
|
||||
return bookService.listUserCommentByPage(userId,page,pageSize);
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package com.java2nb.novel.book.service;
|
||||
|
||||
import com.java2nb.novel.book.entity.*;
|
||||
import com.java2nb.novel.book.vo.BookCommentVO;
|
||||
import com.java2nb.novel.common.bean.PageBean;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@ -84,9 +85,9 @@ public interface BookService {
|
||||
* @param bookId 书籍ID
|
||||
* @param page 页码
|
||||
* @param pageSize 分页大小
|
||||
* @return 评论集合
|
||||
* @return 评论集合分页数据
|
||||
* */
|
||||
List<BookCommentVO> listBookCommentByPage( Long bookId, int page, int pageSize);
|
||||
PageBean<BookComment> listBookCommentByPage(Long bookId, int page, int pageSize);
|
||||
|
||||
/**
|
||||
* 查询目录列表
|
||||
@ -135,7 +136,7 @@ public interface BookService {
|
||||
* @param pageSize 分页大小
|
||||
* @return 评论数据
|
||||
* */
|
||||
List<BookComment> listUserCommentByPage(Long userId, int page, int pageSize);
|
||||
PageBean<BookComment> listUserCommentByPage(Long userId, int page, int pageSize);
|
||||
|
||||
/**
|
||||
* 查询网络图片的小说
|
||||
|
@ -6,6 +6,7 @@ import com.java2nb.novel.book.feign.UserFeignClient;
|
||||
import com.java2nb.novel.book.mapper.*;
|
||||
import com.java2nb.novel.book.service.BookService;
|
||||
import com.java2nb.novel.book.vo.BookCommentVO;
|
||||
import com.java2nb.novel.common.bean.PageBean;
|
||||
import com.java2nb.novel.common.enums.ResponseStatus;
|
||||
import com.java2nb.novel.common.exception.BusinessException;
|
||||
import com.java2nb.novel.common.utils.BeanUtil;
|
||||
@ -170,7 +171,7 @@ public class BookServiceImpl implements BookService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BookCommentVO> listBookCommentByPage(Long bookId, int page, int pageSize) {
|
||||
public PageBean<BookComment> listBookCommentByPage(Long bookId, int page, int pageSize) {
|
||||
//分页查询小说评论数据
|
||||
PageHelper.startPage(page, pageSize);
|
||||
List<BookComment> bookCommentList = bookCommentMapper.selectMany(
|
||||
@ -189,9 +190,9 @@ public class BookServiceImpl implements BookService {
|
||||
|
||||
Map<Long, User> userMap = users.stream().collect(Collectors.toMap(User::getId, Function.identity(), (key1, key2) -> key2));
|
||||
|
||||
//将评论数据和评论人数据关联起来
|
||||
//将评论数据和评论人数据关联起来 TODO 评论表增加用户相关的冗余字段,用户信息更新后用户服务通过mq发送message,其他服务消费message更新所有的冗余字段
|
||||
List<BookCommentVO> resultList = new ArrayList<>(bookCommentList.size());
|
||||
for (BookComment bookComment : bookCommentList) {
|
||||
bookCommentList.forEach(bookComment->{
|
||||
BookCommentVO bookCommentVO = new BookCommentVO();
|
||||
BeanUtils.copyProperties(bookComment, bookCommentVO);
|
||||
User user = userMap.get(bookComment.getCreateUserId());
|
||||
@ -200,9 +201,11 @@ public class BookServiceImpl implements BookService {
|
||||
bookCommentVO.setCreateUserPhoto(user.getUserPhoto());
|
||||
}
|
||||
resultList.add(bookCommentVO);
|
||||
}
|
||||
});
|
||||
PageBean<BookComment> pageBean = new PageBean<>(bookCommentList);
|
||||
pageBean.setList(resultList);
|
||||
|
||||
return resultList;
|
||||
return pageBean;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -308,9 +311,9 @@ public class BookServiceImpl implements BookService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BookComment> listUserCommentByPage(Long userId, int page, int pageSize) {
|
||||
public PageBean<BookComment> listUserCommentByPage(Long userId, int page, int pageSize) {
|
||||
PageHelper.startPage(page, pageSize);
|
||||
return bookCommentMapper.selectMany(
|
||||
return new PageBean<>(bookCommentMapper.selectMany(
|
||||
select(BookCommentDynamicSqlSupport.id, BookCommentDynamicSqlSupport.bookId,
|
||||
BookCommentDynamicSqlSupport.createUserId,
|
||||
BookCommentDynamicSqlSupport.commentContent, BookCommentDynamicSqlSupport.replyCount,
|
||||
@ -319,7 +322,7 @@ public class BookServiceImpl implements BookService {
|
||||
.where(BookCommentDynamicSqlSupport.createUserId, isEqualTo(userId))
|
||||
.orderBy(BookCommentDynamicSqlSupport.createTime.descending())
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3));
|
||||
.render(RenderingStrategies.MYBATIS3)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user