添加听书人数

This commit is contained in:
wuchunlei
2024-12-05 17:07:08 +08:00
parent e908760c71
commit 6f9087b48d

View File

@@ -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<Map<String,Object>> list = toLableService.listMaps(wrapper);
for (Map<String, Object> map : list) {
int readCount = bookReadRateService.count(new LambdaQueryWrapper<BookReadRateEntity>()
.eq(BookReadRateEntity::getBookId,params.get("bookId")));
int buyCount = userEbookBuyService.count(new LambdaQueryWrapper<UserEbookBuyEntity>()
.eq(UserEbookBuyEntity::getBookId,params.get("bookId")));
int listenCount = bookListeningService.count(new LambdaQueryWrapper<BookListeningEntity>()
.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<UserEbookBuyEntity>()
.eq(UserEbookBuyEntity::getBookId,params.get("bookId")));
return R.ok().put("readCount",readCount).put("buyCount",buyCount);
int listenCount = bookListeningService.count(new LambdaQueryWrapper<BookListeningEntity>()
.eq(BookListeningEntity::getBookId,params.get("bookId")));
return R.ok().put("readCount",readCount).put("buyCount",buyCount).put("listenCount",listenCount);
}
//获取当前书的阅读记录