转音频

This commit is contained in:
wuchunlei
2024-12-11 09:23:30 +08:00
parent 5e232e932a
commit 00ec90334e
4 changed files with 292 additions and 59 deletions

View File

@@ -11,6 +11,7 @@ import com.peanut.modules.common.entity.*;
import com.peanut.modules.master.service.BookAbroadToLableService;
import com.peanut.modules.bookAbroad.service.BookAbroadLableService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.http.client.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
@@ -187,14 +188,30 @@ public class HomeController {
//章节内容
@RequestMapping("/getBookChapterContent")
public R getBookChapterContent(@RequestBody Map<String,Object> params) {
Page<BookChapterContentEntity> contentPage = bookChapterContentService.page(new Page<>(
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),
new LambdaQueryWrapper<BookChapterContentEntity>()
List<BookChapterContentEntity> contentPage = bookChapterContentService.list(new LambdaQueryWrapper<BookChapterContentEntity>()
.eq(BookChapterContentEntity::getBookChatperId,params.get("chapterId"))
.orderByAsc(BookChapterContentEntity::getNumber));
return R.ok().put("contentPage",contentPage);
}
//听书时章节内容
@RequestMapping("/getBookChapterContentListen")
public R getBookChapterContentListen(@RequestBody Map<String,Object> params) {
List<BookChapterContentEntity> bccs = bookChapterContentService.list(new LambdaQueryWrapper<BookChapterContentEntity>()
.eq(BookChapterContentEntity::getBookChatperId,params.get("chapterId"))
.notLike(BookChapterContentEntity::getContent,"http")
.orderByAsc(BookChapterContentEntity::getNumber));
//给每段话加上在总音频开始的秒数
double startInt = 0;
for (BookChapterContentEntity bcc : bccs) {
if (StringUtils.isNotBlank(bcc.getVoicesSize())){
bcc.setVoicesStart((int) startInt);
startInt+=Double.parseDouble(bcc.getVoicesSize());
}
}
return R.ok().put("bookChapterContents",bccs);
}
//已读\已买人数
@RequestMapping("/getBookReadCount")
public R getBookReadCount(@RequestBody Map<String,Object> params){