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

@@ -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);