diff --git a/src/main/java/com/peanut/modules/bookAbroad/controller/HomeController.java b/src/main/java/com/peanut/modules/bookAbroad/controller/HomeController.java index 5e02c919..800493a1 100644 --- a/src/main/java/com/peanut/modules/bookAbroad/controller/HomeController.java +++ b/src/main/java/com/peanut/modules/bookAbroad/controller/HomeController.java @@ -30,6 +30,8 @@ public class HomeController { @Autowired private UserEbookBuyService userEbookBuyService; @Autowired + private BookListeningService bookListeningService; + @Autowired private BookService bookService; @Autowired private BookAbroadLableService lableService; @@ -143,7 +145,19 @@ public class HomeController { wrapper.select(BookEntity::getImages); wrapper.select(BookEntity::getName); wrapper.eq(BookAbroadToLable::getLableId,params.get("lableId")); - return R.ok().put("bookList",toLableService.listMaps(wrapper)); + List> list = toLableService.listMaps(wrapper); + for (Map map : list) { + int readCount = bookReadRateService.count(new LambdaQueryWrapper() + .eq(BookReadRateEntity::getBookId,params.get("bookId"))); + int buyCount = userEbookBuyService.count(new LambdaQueryWrapper() + .eq(UserEbookBuyEntity::getBookId,params.get("bookId"))); + int listenCount = bookListeningService.count(new LambdaQueryWrapper() + .eq(BookListeningEntity::getBookId,params.get("bookId"))); + map.put("readCount",readCount); + map.put("buyCount",buyCount); + map.put("listenCount",listenCount); + } + return R.ok().put("bookList",list); } //图书详情 @@ -188,7 +202,9 @@ public class HomeController { .eq(BookReadRateEntity::getBookId,params.get("bookId"))); int buyCount = userEbookBuyService.count(new LambdaQueryWrapper() .eq(UserEbookBuyEntity::getBookId,params.get("bookId"))); - return R.ok().put("readCount",readCount).put("buyCount",buyCount); + int listenCount = bookListeningService.count(new LambdaQueryWrapper() + .eq(BookListeningEntity::getBookId,params.get("bookId"))); + return R.ok().put("readCount",readCount).put("buyCount",buyCount).put("listenCount",listenCount); } //获取当前书的阅读记录