From 6f9087b48d4febbb52aff76e1a9b01272db5d4fa Mon Sep 17 00:00:00 2001 From: wuchunlei Date: Thu, 5 Dec 2024 17:07:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=AC=E4=B9=A6=E4=BA=BA?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bookAbroad/controller/HomeController.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) 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); } //获取当前书的阅读记录