From a17d2fc8403441af96ee4807b333981508912e9c Mon Sep 17 00:00:00 2001 From: wangjinlei <751475802@qq.com> Date: Sat, 7 Oct 2023 18:10:50 +0800 Subject: [PATCH] 20231007 --- .../BookForumArticlesServiceController.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) 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 e7e54b4e..898a7604 100644 --- a/src/main/java/com/peanut/modules/book/controller/BookForumArticlesServiceController.java +++ b/src/main/java/com/peanut/modules/book/controller/BookForumArticlesServiceController.java @@ -138,6 +138,56 @@ public class BookForumArticlesServiceController { return R.ok().put("page",bookEntityPage); } + /** + * 书集----已购图书 + * @param userId + * @param limit + * @param page + * @return + */ + @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"; + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(BookEntity::getDelFlag,0); + wrapper.exists(ex_sql); + wrapper.exists(existSql); + Page bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper); + for (BookEntity b : bookEntityPage.getRecords()){ + b.setForums(bookForumArticlesService.getForumsLimit(b.getId(), 4)); + b.setForumNum(bookForumArticlesService.getForumsCount(b.getId())); + } + + return R.ok().put("page",bookEntityPage); + } + + /** + * 书集----推荐图书 + * @param userId + * @param limit + * @param page + * @return + */ + @RequestMapping("/getBestForumsAndBook") + public R getBestForumsAndBook(@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"; + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(BookEntity::getDelFlag,0); + wrapper.notExists(ex_sql); + wrapper.exists(existSql); + Page bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper); + for (BookEntity b : bookEntityPage.getRecords()){ + b.setForums(bookForumArticlesService.getForumsLimit(b.getId(), 4)); + b.setForumNum(bookForumArticlesService.getForumsCount(b.getId())); + } + + return R.ok().put("page",bookEntityPage); + } + /** * 点赞书评帖子 * @param forum_id