diff --git a/src/main/java/com/peanut/modules/book/controller/BookController.java b/src/main/java/com/peanut/modules/book/controller/BookController.java index b69dce14..8fbd2843 100644 --- a/src/main/java/com/peanut/modules/book/controller/BookController.java +++ b/src/main/java/com/peanut/modules/book/controller/BookController.java @@ -12,6 +12,7 @@ import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.peanut.common.utils.Query; import com.peanut.common.utils.ReadProvinceUtil; import com.peanut.modules.book.dao.BookDao; +import com.peanut.modules.book.dao.BookForumArticlesDao; import com.peanut.modules.book.entity.*; import com.peanut.modules.book.service.*; import com.peanut.modules.book.vo.BookIndexVo; @@ -67,6 +68,8 @@ public class BookController { private ShopProductToLabelService shopProductToLabelService; @Autowired private MedicaldesBookService medicaldesBookService; + @Autowired + private BookForumArticlesDao bookForumArticlesDao; final ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10); /** @@ -745,6 +748,12 @@ public class BookController { } bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper1); } + for (BookEntity b:bookEntityPage.getRecords()){ + LambdaQueryWrapper bookForumArticlesEntityLambdaQueryWrapper = new LambdaQueryWrapper<>(); + bookForumArticlesEntityLambdaQueryWrapper.eq(BookForumArticlesEntity::getBookid,b.getId()); + Integer integer = bookForumArticlesDao.selectCount(bookForumArticlesEntityLambdaQueryWrapper); + b.setForumNum(integer); + } return R.ok().put("page",bookEntityPage); } diff --git a/src/main/java/com/peanut/modules/book/controller/BookForumArticlesServiceController.java b/src/main/java/com/peanut/modules/book/controller/BookForumArticlesServiceController.java index 980e966c..306f9e23 100644 --- a/src/main/java/com/peanut/modules/book/controller/BookForumArticlesServiceController.java +++ b/src/main/java/com/peanut/modules/book/controller/BookForumArticlesServiceController.java @@ -165,7 +165,7 @@ public class BookForumArticlesServiceController { @RequestMapping("/getHasForumsAndBook") public R getHasForumsAndBook(@RequestParam Integer userId,@RequestParam Integer limit,@RequestParam Integer page){ String ex_sql = "select 1 from user_ebook_buy where book.id = book_id and user_id = "+userId; - String existSql = "select 1 from book_forum_articles where book.id = bookid"; + String existSql = "select 1 from book_forum_articles where del_flag=0 and book.id = bookid"; LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(BookEntity::getDelFlag,0);