This commit is contained in:
yc13649764453
2023-09-18 09:41:19 +08:00
parent 8d3c128f3b
commit 9ada233eb7
60 changed files with 8255 additions and 655 deletions

View File

@@ -80,25 +80,22 @@ public class BookController {
@PathVariable("userId") Integer userId) {
// 判断用户是否够买书籍
BookEntity book = bookService.getById(id);
book.setIsBuy(0);
Boolean canListen = book.getCanListen();
// Integer isVip = book.getIsVip(); // 0-免费 1-会免 2-付费
book.setIsBuy(true);
boolean b = myUserService.bookAuthenticate(id, userId);
boolean b = myUserService.bookAuthen(id, userId);
if (!b) {
// 无权限
book.setIsBuy(0);
book.setIsBuy(false);
}
//书籍详情返回,购买状态,免费章节数
// if (canListen==false) {
// // 无权限
// return R.error("该图书暂未开通听书功能");
// }
String authorName = "";
@@ -163,8 +160,7 @@ public class BookController {
book.setAuthorName(authorName);
book.setPublisherName(publisherName);
book.setFlag(flag);
return R.ok().put("book", book).put("canListen",canListen);
return R.ok().put("book", book);
}
/**
@@ -333,8 +329,68 @@ public class BookController {
/**
* 对外图标列表
* app 电子书目录
*/
@RequestMapping("/getCatalogue")
public R getCatalogue(@RequestParam("bookid") Integer id
) {
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
if (bookEntity == null) {
return R.error("当前图书不存在或已删除");
}
String images = bookEntity.getImages() ;
Integer number=null;
List<BookChapterEntity> bookChapterEntities = bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>().eq("book_id", id));
List<HashMap<Object, Object>> chapterList = new ArrayList<>();
for (BookChapterEntity bookEntitys : bookChapterEntities) {
number = bookEntitys.getNumber();
HashMap<Object, Object> map = new HashMap<>();
map.put("bookid",id);
map.put("number", bookEntitys.getNumber());
map.put("chapterId", bookEntitys.getId());
map.put("chapterName", bookEntitys.getChapter());
//freeChapterCount
map.put("images",images);
chapterList.add(map);
}
if (number==null) {
return R.error("当前电子书目录为空");
}else{
return R.ok().put("BookCatalogue",chapterList);
}
}
//书籍详情返回,购买状态,免费章节数
/**
* app 获取免费章节数
*/
@RequestMapping("/getfreeChapter")
public R getfreeChapter(@RequestParam("bookid") Integer id
) {
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
if (bookEntity == null) {
return R.error("当前图书不存在或已删除");
}
Integer freeChapterCount = bookEntity.getFreeChapterCount();
if (freeChapterCount == null) {
return R.error("当前电子书目录为空");
} else {
return R.ok().put("freeChapterCount", freeChapterCount);
}
}
/**
* 对外图标列表
*/
@RequestMapping("/listForWebsite")
// @RequiresPermissions("book:book:list")
public R listForWebsite(@RequestParam Map<String, Object> params) {