恢复图书信息
This commit is contained in:
@@ -156,6 +156,72 @@ public class BookController {
|
||||
return R.ok().put("book",book_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/appinfo/{id}/{userId}")
|
||||
// @RequiresPermissions("book:book:info")
|
||||
public R appinfo(@PathVariable("id") Integer id,
|
||||
@PathVariable("userId") Integer userId) {
|
||||
BookEntity book = bookService.getById(id);
|
||||
book.setIsBuy(true);
|
||||
boolean b = myUserService.bookAuthen(id, userId);
|
||||
if (!b) {
|
||||
// 无权限
|
||||
book.setIsBuy(false);
|
||||
}
|
||||
//书籍详情返回,购买状态,免费章节数
|
||||
String authorName = "";
|
||||
String publisherName = "";
|
||||
String authorId = book.getAuthorId();
|
||||
String[] authorIds = authorId.split(",");
|
||||
List<String> authorList = Arrays.asList(authorIds);
|
||||
List<AuthorEntity> authorEntities = authorService.getBaseMapper().selectList(new QueryWrapper<AuthorEntity>().in("id", authorList));
|
||||
for (AuthorEntity authorEntity : authorEntities) {
|
||||
authorName += "," + authorEntity.getAuthorName();
|
||||
}
|
||||
authorName = authorName.startsWith(",") ? authorName.substring(1) : authorName;
|
||||
String publisherId = book.getPublisherId();
|
||||
String[] publisherIds = publisherId.split(",");
|
||||
List<String> publisherList = Arrays.asList(publisherIds);
|
||||
List<Publisher> publisherEntities = publisherService.getBaseMapper().selectList(new QueryWrapper<Publisher>().in("id", publisherList));
|
||||
|
||||
for (Publisher publisher : publisherEntities) {
|
||||
publisherName += "," + publisher.getPublisherName();
|
||||
}
|
||||
publisherName = publisherName.startsWith(",") ? publisherName.substring(1) : publisherName;
|
||||
//查询书籍阅读进度
|
||||
BookReadRateEntity bookReadRateEntity = bookReadRateService.getBaseMapper().selectOne(new QueryWrapper<BookReadRateEntity>()
|
||||
.eq("book_id", id)
|
||||
.eq("user_id", userId)
|
||||
);
|
||||
if (bookReadRateEntity != null) {
|
||||
Integer chapterId = bookReadRateEntity.getChapterId();
|
||||
String chapterName = bookReadRateEntity.getChapterName();
|
||||
book.setChapterName(chapterName);
|
||||
book.setChapterId(chapterId);
|
||||
// 查询 书籍 章节 number
|
||||
BookChapterEntity bookChapterEntity = bookChapterService.getById(chapterId);
|
||||
if (bookChapterEntity != null) {
|
||||
Integer number = bookChapterEntity.getNumber();
|
||||
book.setChapterNum(number);
|
||||
}
|
||||
}
|
||||
//查询书籍是否加入书架
|
||||
Long integer = bookShelfService.getBaseMapper().selectCount(new QueryWrapper<BookShelfEntity>()
|
||||
.eq("book_id", id)
|
||||
.eq("user_id", userId));
|
||||
|
||||
boolean flag = false;
|
||||
if (integer > 0) {
|
||||
flag = true;
|
||||
}
|
||||
book.setAuthorName(authorName);
|
||||
book.setPublisherName(publisherName);
|
||||
book.setFlag(flag);
|
||||
return R.ok().put("book", book);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
|
||||
@@ -22,6 +22,9 @@ public interface MyUserService extends IService<MyUserEntity> {
|
||||
|
||||
R sendCodeForRegister(String phone, String code, Integer areaCode) throws Exception;
|
||||
|
||||
//电子书针对听书鉴权
|
||||
boolean bookAuthen(Integer bookId,Integer userId);
|
||||
|
||||
List<BookForumArticlesEntity> getForumsLimit(Integer book_id, Integer limit);
|
||||
//充值花生币
|
||||
boolean rechargeHSPoint(MyUserEntity userEntity,Integer HSPoint);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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.toolkit.StringUtils;
|
||||
import com.peanut.common.utils.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
@@ -46,6 +47,17 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean bookAuthen(Integer bookId, Integer userId) {
|
||||
UserEbookBuyEntity userid = userEbookBuyService.getBaseMapper().selectOne(new QueryWrapper<UserEbookBuyEntity>()
|
||||
.eq("user_id", userId)
|
||||
.eq("book_id", bookId));
|
||||
if (userid == null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BookForumArticlesEntity> getForumsLimit(Integer book_id, Integer limit) {
|
||||
LambdaQueryWrapper<BookForumArticlesEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
Reference in New Issue
Block a user