From 94d7969340ab5b73ccac9708334ece631f4e7239 Mon Sep 17 00:00:00 2001 From: wuchunlei Date: Mon, 10 Nov 2025 16:09:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=81=A2=E5=A4=8D=E5=9B=BE=E4=B9=A6=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../book/controller/BookController.java | 66 +++++++++++++++++++ .../modules/book/service/MyUserService.java | 3 + .../book/service/impl/MyUserServiceImpl.java | 12 ++++ 3 files changed, 81 insertions(+) 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 a62a1558..6f078f6d 100644 --- a/src/main/java/com/peanut/modules/book/controller/BookController.java +++ b/src/main/java/com/peanut/modules/book/controller/BookController.java @@ -156,6 +156,72 @@ public class BookController { return R.ok().put("book",book_info); } + /** + * 信息 + */ + @RequestMapping("/appinfo/{id}/{userId}") +// @RequiresPermissions("book:book:info") + public R appinfo(@PathVariable("id") Integer id, + @PathVariable("userId") Integer userId) { + BookEntity book = bookService.getById(id); + book.setIsBuy(true); + boolean b = myUserService.bookAuthen(id, userId); + if (!b) { + // 无权限 + book.setIsBuy(false); + } + //书籍详情返回,购买状态,免费章节数 + String authorName = ""; + String publisherName = ""; + String authorId = book.getAuthorId(); + String[] authorIds = authorId.split(","); + List authorList = Arrays.asList(authorIds); + List authorEntities = authorService.getBaseMapper().selectList(new QueryWrapper().in("id", authorList)); + for (AuthorEntity authorEntity : authorEntities) { + authorName += "," + authorEntity.getAuthorName(); + } + authorName = authorName.startsWith(",") ? authorName.substring(1) : authorName; + String publisherId = book.getPublisherId(); + String[] publisherIds = publisherId.split(","); + List publisherList = Arrays.asList(publisherIds); + List publisherEntities = publisherService.getBaseMapper().selectList(new QueryWrapper().in("id", publisherList)); + + for (Publisher publisher : publisherEntities) { + publisherName += "," + publisher.getPublisherName(); + } + publisherName = publisherName.startsWith(",") ? publisherName.substring(1) : publisherName; + //查询书籍阅读进度 + BookReadRateEntity bookReadRateEntity = bookReadRateService.getBaseMapper().selectOne(new QueryWrapper() + .eq("book_id", id) + .eq("user_id", userId) + ); + if (bookReadRateEntity != null) { + Integer chapterId = bookReadRateEntity.getChapterId(); + String chapterName = bookReadRateEntity.getChapterName(); + book.setChapterName(chapterName); + book.setChapterId(chapterId); + // 查询 书籍 章节 number + BookChapterEntity bookChapterEntity = bookChapterService.getById(chapterId); + if (bookChapterEntity != null) { + Integer number = bookChapterEntity.getNumber(); + book.setChapterNum(number); + } + } + //查询书籍是否加入书架 + Long integer = bookShelfService.getBaseMapper().selectCount(new QueryWrapper() + .eq("book_id", id) + .eq("user_id", userId)); + + boolean flag = false; + if (integer > 0) { + flag = true; + } + book.setAuthorName(authorName); + book.setPublisherName(publisherName); + book.setFlag(flag); + return R.ok().put("book", book); + } + /** * 保存 */ diff --git a/src/main/java/com/peanut/modules/book/service/MyUserService.java b/src/main/java/com/peanut/modules/book/service/MyUserService.java index f7b64c62..701a6868 100644 --- a/src/main/java/com/peanut/modules/book/service/MyUserService.java +++ b/src/main/java/com/peanut/modules/book/service/MyUserService.java @@ -22,6 +22,9 @@ public interface MyUserService extends IService { R sendCodeForRegister(String phone, String code, Integer areaCode) throws Exception; + //电子书针对听书鉴权 + boolean bookAuthen(Integer bookId,Integer userId); + List getForumsLimit(Integer book_id, Integer limit); //充值花生币 boolean rechargeHSPoint(MyUserEntity userEntity,Integer HSPoint); diff --git a/src/main/java/com/peanut/modules/book/service/impl/MyUserServiceImpl.java b/src/main/java/com/peanut/modules/book/service/impl/MyUserServiceImpl.java index 5b1febf9..3ec3b1f4 100644 --- a/src/main/java/com/peanut/modules/book/service/impl/MyUserServiceImpl.java +++ b/src/main/java/com/peanut/modules/book/service/impl/MyUserServiceImpl.java @@ -1,6 +1,7 @@ package com.peanut.modules.book.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.peanut.common.utils.*; import com.peanut.modules.book.service.*; @@ -46,6 +47,17 @@ public class MyUserServiceImpl extends ServiceImpl impl } } + @Override + public boolean bookAuthen(Integer bookId, Integer userId) { + UserEbookBuyEntity userid = userEbookBuyService.getBaseMapper().selectOne(new QueryWrapper() + .eq("user_id", userId) + .eq("book_id", bookId)); + if (userid == null) { + return false; + } + return true; + } + @Override public List getForumsLimit(Integer book_id, Integer limit) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();