This commit is contained in:
wangjinlei
2023-09-27 15:57:35 +08:00
parent 1755a78a8d
commit c3ba1d9691
9 changed files with 144 additions and 12 deletions

View File

@@ -8,6 +8,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.peanut.common.utils.BaiduVoicesUtils;
import com.peanut.modules.book.entity.*;
@@ -51,6 +52,8 @@ public class BookChapterContentController {
private MyUserService myUserService;
@Autowired
private UserEbookBuyService userEbookBuyService;
@Autowired
private ShopProudictBookService shopProudictBookService;
/**
* 列表
@@ -346,14 +349,36 @@ public class BookChapterContentController {
}
/**
* 获取章节音频地址
* @return
*/
@RequestMapping("/getBooksCatalogue")
public R getBooksCatalogue(@RequestParam Integer chapterId,
@RequestParam Integer bookId,
@RequestParam Integer userId){
//鉴权阶段
BookEntity book_info = bookService.getById(bookId);
BookChapterEntity chapter_info = bookChapterService.getById(chapterId);
UserEbookBuyEntity userEbookBuyEntity = userEbookBuyService.getBaseMapper().selectOne(new LambdaQueryWrapper<UserEbookBuyEntity>().
eq(UserEbookBuyEntity::getUserId,userId).eq(UserEbookBuyEntity::getBookId,bookId));
if(chapter_info.getNumber()>book_info.getFreeChapterCount()&&userEbookBuyEntity==null){
Integer productByBookId = shopProudictBookService.getProductByBookId(bookId);
return R.ok().put("jq",false).put("product",productByBookId);
}
return R.ok().put("chapter",chapter_info);
}
/**
* app 获取电子书章节内容 2.0 (在用鉴权)
*/
@RequestMapping("/appBooksChapterContent")
public R getBooksCatalogue(@RequestParam("chapterid") Integer id,
@RequestMapping("/appBooksChapterContent1")
public R getBooksCatalogue1(@RequestParam("chapterid") Integer id,
@RequestParam("bookid") Integer bookid,
@RequestParam("userId") Integer userId) {
// TODO 验证 当前请求的书 是否存在免费章节数

View File

@@ -137,6 +137,17 @@ public class BookChapterController {
}
@RequestMapping("/updateBookChapter")
public R updateBookChapter(@RequestBody BookChapterEntity bookChapter){
BookChapterEntity old_info = bookChapterService.getById(bookChapter.getId());
if(!old_info.getContent().equals(bookChapter.getContent())){
bookChapter.setVoices(""); // 设置voices字段为空
}
bookChapterService.updateById(bookChapter);
return R.ok();
}
/**
* 修改
*/

View File

@@ -2,6 +2,8 @@ package com.peanut.modules.book.controller;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
@@ -52,6 +54,10 @@ public class BookController {
private UserEbookBuyService userEbookBuyService;
@Autowired
private BookDao bookDao;
@Autowired
private ShopProductService shopProductService;
@Autowired
private ShopProudictBookService shopProudictBookService;
final ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10);
/**
@@ -89,6 +95,27 @@ public class BookController {
}
/**
* 获取书详情
* @param bookId
* @return
*/
@RequestMapping("/getBookInfo")
public R getBookInfo(@RequestParam Integer bookId,@RequestParam Integer userId){
BookEntity book_info = bookService.getById(bookId);
book_info.setAuthor(authorService.getById(book_info.getAuthorId()));
book_info.setPublisher(publisherService.getById(book_info.getPublisherId()));
book_info.setProductId(shopProudictBookService.getProductByBookId(bookId));
LambdaQueryWrapper<UserEbookBuyEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(UserEbookBuyEntity::getUserId,userId);
wrapper.eq(UserEbookBuyEntity::getBookId,bookId);
List<UserEbookBuyEntity> userEbookBuyEntities = userEbookBuyService.getBaseMapper().selectList(wrapper);
book_info.setIsBuy(userEbookBuyEntities==null?false:true);
return R.ok().put("book",book_info);
}
/**
* 信息
*/
@@ -339,10 +366,36 @@ public class BookController {
}
/**
* app 获取电子书目录
* 获取书的章节
* @param bookId
* @param userId
* @return
*/
@RequestMapping("/getBookCatalogue")
public R getBookCatalogue(@RequestParam("bookid") Integer id,
public R getBookCatalogue(@RequestParam Integer bookId,@RequestParam Integer userId){
BookEntity book_info = bookService.getById(bookId);
LambdaQueryWrapper<BookChapterEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(BookChapterEntity::getBookId,bookId);
wrapper.eq(BookChapterEntity::getDelFlag,0);
wrapper.orderByAsc(BookChapterEntity::getNumber);
List<BookChapterEntity> chapters = bookChapterService.getBaseMapper().selectList(wrapper);
for (BookChapterEntity b : chapters){
if(b.getNumber()<=book_info.getFreeChapterCount()){
b.setIsFree(1);
}else{
b.setIsFree(0);
}
b.setBookImage(book_info.getImages());
}
return R.ok().put("BookCatalogue",chapters);
}
/**
* app 获取电子书目录
*/
@RequestMapping("/getBookCatalogue1")
public R getBookCatalogue1(@RequestParam("bookid") Integer id,
@RequestParam("userid") Integer userid) {
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);