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

View File

@@ -65,10 +65,13 @@ public class BookChapterEntity implements Serializable {
@TableLogic
private Integer delFlag;
@TableField(exist = false)
private Integer isFree;
@TableField(exist = false)
private String bookImage;
@TableField(exist = false)
private String picAndWord;
}

View File

@@ -147,6 +147,12 @@ public class BookEntity implements Serializable {
@TableField(exist = false)
private String publisherName;
@TableField(exist = false)
private AuthorEntity author;
@TableField(exist = false)
private PublisherEntity publisher;
@TableField(exist = false)
private String authorName;
@@ -168,14 +174,12 @@ public class BookEntity implements Serializable {
@TableField(exist = false)
private Integer forumNum;
// @TableField(exist = false)
// private Boolean bookAuthen;
@TableField("can_listen")
private Boolean canListen;
@TableField(exist = false)
private Integer productId;
private Integer clockIn;

View File

@@ -31,5 +31,8 @@ public interface ShopProductService extends IService<ShopProductEntity> {
PageUtils queryPageproductSales(Map<String, Object> params);
PageUtils queryPageactivityprice(Map<String, Object> params);
}

View File

@@ -17,4 +17,6 @@ public interface ShopProudictBookService extends IService<ShopProudictBookEntity
List<Integer> getBookidsByProductId(Integer productId);
Integer getProductByBookId(Integer bookId);
}

View File

@@ -1,6 +1,10 @@
package com.peanut.modules.book.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
import com.peanut.modules.book.entity.ShopCategoryEntity;
import com.peanut.modules.book.entity.ShopProudictBookEntity;
import com.peanut.modules.book.service.ShopProudictBookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
@@ -20,6 +24,7 @@ import com.peanut.modules.book.service.ShopProductService;
@Service("shopProductService")
public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProductEntity> implements ShopProductService {
@Override
public PageUtils queryPage(Map<String, Object> params) {
String userid = (String) params.get("userid");
@@ -73,7 +78,6 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
new Query<ShopProductEntity>().getPage(params),
new QueryWrapper<ShopProductEntity>().orderByDesc("sum_sales")
);
System.out.println("page"+page);
return new PageUtils(page);
}
@@ -86,4 +90,5 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
return new PageUtils(page);
}
}

View File

@@ -1,4 +1,5 @@
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.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -82,5 +83,30 @@ public class ShopProudictBookServiceImpl extends ServiceImpl<ShopProudictBookDa
return ids;
}
@Override
public Integer getProductByBookId(Integer bookId) {
LambdaQueryWrapper<ShopProudictBookEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ShopProudictBookEntity::getBookId,bookId);
wrapper.eq(ShopProudictBookEntity::getDelFlag,0);
wrapper.groupBy(ShopProudictBookEntity::getProudictId);
List<ShopProudictBookEntity> shopProudictBookEntities = this.getBaseMapper().selectList(wrapper);
List ids = new ArrayList();
for (ShopProudictBookEntity s : shopProudictBookEntities){
ids.add(s.getProudictId());
}
if(ids.size()==0){
return null;
}
LambdaQueryWrapper<ShopProductEntity> wrapper1 = new LambdaQueryWrapper<>();
wrapper1.eq(ShopProductEntity::getDelFlag,0);
wrapper1.in(ShopProductEntity::getProductId,ids);
wrapper1.orderByAsc(ShopProductEntity::getPrice);
wrapper1.last("limit 1");
List<ShopProductEntity> shopProductEntities = shopProductService.getBaseMapper().selectList(wrapper1);
ShopProductEntity shopProductEntity = shopProductEntities.get(0);
return shopProductEntity.getProductId();
}
}