删除海外读书模块
This commit is contained in:
@@ -1,118 +0,0 @@
|
||||
package com.peanut.modules.bookAbroad.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.modules.bookAbroad.service.BookAbroadCommentLikeService;
|
||||
import com.peanut.modules.bookAbroad.service.BookAbroadCommentService;
|
||||
import com.peanut.modules.bookAbroad.service.BookAbroadLableService;
|
||||
import com.peanut.modules.bookAbroad.service.BookAbroadToLableService;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.service.MyUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@RestController("bookAbroad")
|
||||
@RequestMapping("bookAbroad")
|
||||
public class BookAbroadController {
|
||||
|
||||
@Autowired
|
||||
private MyUserService userService;
|
||||
@Autowired
|
||||
private BookAbroadCommentService bookAbroadCommentService;
|
||||
@Autowired
|
||||
private BookAbroadCommentLikeService bookAbroadCommentLikeService;
|
||||
|
||||
//评论
|
||||
@RequestMapping("/insertBookAbroadComment")
|
||||
public R insertBookAbroadComment(@RequestBody BookAbroadComment comment){
|
||||
comment.setUserId(ShiroUtils.getUId());
|
||||
bookAbroadCommentService.save(comment);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//评论树
|
||||
@RequestMapping("/getBookAbroadCommentTree")
|
||||
public R getBookAbroadCommentTree(@RequestBody Map<String,Object> params) {
|
||||
int current = Integer.parseInt(params.get("current").toString())-1;
|
||||
int limit = Integer.parseInt(params.get("limit").toString());
|
||||
List<BookAbroadComment> comments = bookAbroadCommentService.list(new LambdaQueryWrapper<BookAbroadComment>()
|
||||
.eq(BookAbroadComment::getBookId,params.get("bookId"))
|
||||
.orderByDesc(BookAbroadComment::getId));
|
||||
int commentsCount = comments.stream().filter((bookAbroadComment) -> bookAbroadComment.getPid() == 0).collect(Collectors.toList()).size();
|
||||
List<BookAbroadComment> commentsTree = comments.stream()
|
||||
.filter((bookAbroadComment) -> bookAbroadComment.getPid() == 0)
|
||||
.map((comment)->{
|
||||
comment.setIsLike(bookAbroadCommentLikeService.count(new LambdaQueryWrapper<BookAbroadCommentLike>()
|
||||
.eq(BookAbroadCommentLike::getCommentId,comment.getId())
|
||||
.eq(BookAbroadCommentLike::getUserId,ShiroUtils.getUId())));
|
||||
comment.setLikeCount(bookAbroadCommentLikeService.count(new LambdaQueryWrapper<BookAbroadCommentLike>()
|
||||
.eq(BookAbroadCommentLike::getCommentId,comment.getId())));
|
||||
comment.setUserEntity(userService.getOne(new LambdaQueryWrapper<MyUserEntity>()
|
||||
.select(MyUserEntity::getId,MyUserEntity::getName,MyUserEntity::getNickname,MyUserEntity::getAvatar)
|
||||
.eq(MyUserEntity::getId,comment.getUserId())));
|
||||
comment.setChildren(getLabelChildrens(comment,comments));
|
||||
return comment; })
|
||||
.sorted((comment1,comment2)->{
|
||||
return comment2.getLikeCount() - comment1.getLikeCount();})
|
||||
.collect(Collectors.toList())
|
||||
.subList(current*limit,((current*limit)+limit)<commentsCount?((current*limit)+limit):commentsCount);
|
||||
return R.ok().put("commentsCount",commentsCount).put("commentsTree",commentsTree);
|
||||
}
|
||||
|
||||
private List<BookAbroadComment> getLabelChildrens(BookAbroadComment root,List<BookAbroadComment> all){
|
||||
List<BookAbroadComment> children = all.stream().filter(bookAbroadComment -> {
|
||||
return root.getId().equals(bookAbroadComment.getPid());
|
||||
}).map(bookAbroadComment -> {
|
||||
bookAbroadComment.setIsLike(bookAbroadCommentLikeService.count(new LambdaQueryWrapper<BookAbroadCommentLike>()
|
||||
.eq(BookAbroadCommentLike::getCommentId,bookAbroadComment.getId())
|
||||
.eq(BookAbroadCommentLike::getUserId,ShiroUtils.getUId())));
|
||||
bookAbroadComment.setLikeCount(bookAbroadCommentLikeService.count(new LambdaQueryWrapper<BookAbroadCommentLike>()
|
||||
.eq(BookAbroadCommentLike::getCommentId,bookAbroadComment.getId())));
|
||||
bookAbroadComment.setUserEntity(userService.getOne(new LambdaQueryWrapper<MyUserEntity>()
|
||||
.select(MyUserEntity::getId,MyUserEntity::getName,MyUserEntity::getNickname,MyUserEntity::getAvatar)
|
||||
.eq(MyUserEntity::getId,bookAbroadComment.getUserId())));
|
||||
bookAbroadComment.setChildren(getLabelChildrens(bookAbroadComment, all));
|
||||
return bookAbroadComment;
|
||||
}).collect(Collectors.toList());
|
||||
return children;
|
||||
}
|
||||
//删除评论
|
||||
@RequestMapping("/delBookAbroadComment")
|
||||
public R delBookAbroadComment(@RequestBody Map<String,Object> params){
|
||||
bookAbroadCommentService.removeById(params.get("commentId").toString());
|
||||
return R.ok();
|
||||
}
|
||||
//点赞
|
||||
@RequestMapping("/insertBookAbroadCommentLike")
|
||||
public R insertBookAbroadCommentLike(@RequestBody BookAbroadCommentLike commentLike){
|
||||
int count = bookAbroadCommentLikeService.count(new LambdaQueryWrapper<BookAbroadCommentLike>()
|
||||
.eq(BookAbroadCommentLike::getCommentId,commentLike.getCommentId())
|
||||
.eq(BookAbroadCommentLike::getUserId,ShiroUtils.getUId()));
|
||||
if (count > 0) {
|
||||
return R.error("已点赞");
|
||||
}
|
||||
commentLike.setUserId(ShiroUtils.getUId());
|
||||
bookAbroadCommentLikeService.save(commentLike);
|
||||
return R.ok();
|
||||
}
|
||||
//取消点赞
|
||||
@RequestMapping("/delBookAbroadCommentLike")
|
||||
public R delBookAbroadCommentLike(@RequestBody Map<String,Object> params){
|
||||
bookAbroadCommentLikeService.remove(new LambdaQueryWrapper<BookAbroadCommentLike>()
|
||||
.eq(BookAbroadCommentLike::getCommentId,params.get("commentId"))
|
||||
.eq(BookAbroadCommentLike::getUserId,ShiroUtils.getUId()));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,304 +0,0 @@
|
||||
package com.peanut.modules.bookAbroad.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.DateUtil;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.modules.book.service.*;
|
||||
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;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@RestController("bookAbroadHome")
|
||||
@RequestMapping("bookAbroad/home")
|
||||
public class HomeController {
|
||||
|
||||
@Autowired
|
||||
private BookReadRateService bookReadRateService;
|
||||
@Autowired
|
||||
private UserEbookBuyService userEbookBuyService;
|
||||
@Autowired
|
||||
private BookListeningService bookListeningService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private BookAbroadLableService lableService;
|
||||
@Autowired
|
||||
private BookAbroadToLableService toLableService;
|
||||
@Autowired
|
||||
private AuthorService authorService;
|
||||
@Autowired
|
||||
private BookChapterService bookChapterService;
|
||||
@Autowired
|
||||
private BookChapterContentService bookChapterContentService;
|
||||
@Autowired
|
||||
private BuyOrderService buyOrderService;
|
||||
|
||||
//我的图书
|
||||
@RequestMapping("/getMyBooks")
|
||||
public R getMyBooks(@RequestBody Map<String,Object> params){
|
||||
MPJLambdaWrapper<UserEbookBuyEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.leftJoin(BookEntity.class,BookEntity::getId,UserEbookBuyEntity::getBookId);
|
||||
wrapper.eq(UserEbookBuyEntity::getUserId,ShiroUtils.getUId());
|
||||
wrapper.select(BookEntity::getId,BookEntity::getName,BookEntity::getImages);
|
||||
wrapper.groupBy(UserEbookBuyEntity::getBookId);
|
||||
Page p = userEbookBuyService.pageMaps(new Page<>(
|
||||
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
|
||||
List<Map<String,Object>> list = p.getRecords();
|
||||
for (Map<String,Object> map:list) {
|
||||
BookReadRateEntity brr = bookReadRateService.getOne(new LambdaQueryWrapper<BookReadRateEntity>()
|
||||
.eq(BookReadRateEntity::getUserId, ShiroUtils.getUId())
|
||||
.eq(BookReadRateEntity::getBookId,map.get("id")));
|
||||
map.put("precent",brr==null?"0":brr.getPrecent()==null?"0":brr.getPrecent());
|
||||
map.put("sort",brr==null?0:brr.getUpdateTime()==null?0:brr.getUpdateTime().getTime());
|
||||
}
|
||||
list = list.stream().sorted((map1,map2)->{
|
||||
return Long.compare((Long) map2.get("sort"),(Long) map1.get("sort"));
|
||||
}).collect(Collectors.toList());
|
||||
p.setRecords(list);
|
||||
return R.ok().put("page",p);
|
||||
}
|
||||
|
||||
//推荐图书
|
||||
@RequestMapping("/getRecommendBooks")
|
||||
public R getRecommendBooks(){
|
||||
//查询已购买图书
|
||||
LambdaQueryWrapper<UserEbookBuyEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(UserEbookBuyEntity::getUserId,ShiroUtils.getUId());
|
||||
wrapper.groupBy(UserEbookBuyEntity::getBookId);
|
||||
Set<Integer> bookIds = userEbookBuyService.getBaseMapper().selectList(wrapper).stream()
|
||||
.map(UserEbookBuyEntity::getBookId).collect(Collectors.toSet());
|
||||
//查询未购买图书
|
||||
List<BookEntity> noBooks = bookService.list(new LambdaQueryWrapper<BookEntity>()
|
||||
.eq(BookEntity::getState,1)
|
||||
.eq(BookEntity::getBookType,0)
|
||||
.notIn(BookEntity::getId,bookIds.size()==0?0:bookIds)
|
||||
.last("limit 2"));
|
||||
Set<BookEntity> books = new HashSet<>();
|
||||
//查询阅读进度
|
||||
List<BookReadRateEntity> readRateList = bookReadRateService.list(new LambdaQueryWrapper<BookReadRateEntity>()
|
||||
.eq(BookReadRateEntity::getUserId,ShiroUtils.getUId())
|
||||
.orderByDesc(BookReadRateEntity::getUpdateTime));
|
||||
//根据阅读记录,查询同标签下书籍
|
||||
if (readRateList.size()>0){
|
||||
//书籍绑定的标签
|
||||
List<BookAbroadToLable> tolableBookList = toLableService.list(new LambdaQueryWrapper<BookAbroadToLable>()
|
||||
.eq(BookAbroadToLable::getBookId,readRateList.get(0).getBookId()));
|
||||
for (BookAbroadToLable tolableBook : tolableBookList) {
|
||||
//标签下的书籍
|
||||
List<BookAbroadToLable> tolableLableList = toLableService.list(new LambdaQueryWrapper<BookAbroadToLable>()
|
||||
.eq(BookAbroadToLable::getLableId,tolableBook.getLableId()));
|
||||
for (BookAbroadToLable tolableLable : tolableLableList) {
|
||||
if (bookIds.add(tolableLable.getBookId())) {
|
||||
books.add(bookService.getById(tolableLable.getBookId()));
|
||||
if (books.size()==2){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//补充标签未填满位置
|
||||
if (books.size()!=2){
|
||||
int surplus = 2-books.size();
|
||||
for (int i=0;i<surplus; i++){
|
||||
books.add(noBooks.get(i));
|
||||
}
|
||||
}
|
||||
return R.ok().put("books",books);
|
||||
}
|
||||
|
||||
//获取标签列表
|
||||
@RequestMapping("/getBookAbroadLableList")
|
||||
public R getBookAbroadLableList(@RequestBody Map<String,Object> params) {
|
||||
List<BookAbroadLable> list = lableService.list(new LambdaQueryWrapper<BookAbroadLable>()
|
||||
.eq(BookAbroadLable::getPid,0)
|
||||
.eq(BookAbroadLable::getType,params.get("type")));
|
||||
return R.ok().put("lableList",list);
|
||||
}
|
||||
|
||||
//获取子标签
|
||||
@RequestMapping("/getBookAbroadLableListByPid")
|
||||
public R getBookAbroadLableListByPid(@RequestBody Map<String,Object> params) {
|
||||
List<BookAbroadLable> list = lableService.list(new LambdaQueryWrapper<BookAbroadLable>()
|
||||
.eq(BookAbroadLable::getPid,params.get("pid")));
|
||||
return R.ok().put("lableList",list);
|
||||
}
|
||||
|
||||
//通过标签获取绑定图书
|
||||
@RequestMapping("/getAbroadBookListByLable")
|
||||
public R getAbroadBookListByLable(@RequestBody Map<String,Object> params) {
|
||||
MPJLambdaWrapper<BookAbroadToLable> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.leftJoin(BookEntity.class,BookEntity::getId,BookAbroadToLable::getBookId);
|
||||
wrapper.selectAs(BookAbroadToLable::getId,"toLableId");
|
||||
wrapper.selectAs(BookEntity::getId,"bookId");
|
||||
wrapper.selectAs(BookEntity::getAbroadPrice,"abroadPrice");
|
||||
wrapper.select(BookEntity::getImages);
|
||||
wrapper.select(BookEntity::getName);
|
||||
wrapper.eq(BookAbroadToLable::getLableId,params.get("lableId"));
|
||||
wrapper.orderByAsc(BookAbroadToLable::getSort);
|
||||
List<Map<String,Object>> list = toLableService.listMaps(wrapper);
|
||||
for (Map<String, Object> map : list) {
|
||||
int readCount = bookReadRateService.count(new LambdaQueryWrapper<BookReadRateEntity>()
|
||||
.eq(BookReadRateEntity::getBookId,map.get("bookId")));
|
||||
int buyCount = userEbookBuyService.count(new LambdaQueryWrapper<UserEbookBuyEntity>()
|
||||
.eq(UserEbookBuyEntity::getBookId,map.get("bookId")));
|
||||
int listenCount = bookListeningService.count(new LambdaQueryWrapper<BookListeningEntity>()
|
||||
.eq(BookListeningEntity::getBookId,map.get("bookId")));
|
||||
map.put("readCount",readCount);
|
||||
map.put("buyCount",buyCount);
|
||||
map.put("listenCount",listenCount);
|
||||
}
|
||||
return R.ok().put("bookList",list);
|
||||
}
|
||||
|
||||
//图书详情
|
||||
@RequestMapping("/getBookInfo")
|
||||
public R getBookInfo(@RequestBody Map<String,Object> params) {
|
||||
BookEntity bookEntity = bookService.getById(params.get("bookId").toString());
|
||||
bookEntity.setAuthor(authorService.getById(bookEntity.getAuthorId()));
|
||||
bookEntity.setIsBuy(false);
|
||||
int count = userEbookBuyService.count(new LambdaQueryWrapper<UserEbookBuyEntity>()
|
||||
.eq(UserEbookBuyEntity::getUserId,ShiroUtils.getUId())
|
||||
.eq(UserEbookBuyEntity::getBookId,params.get("bookId")));
|
||||
if (count > 0) {
|
||||
bookEntity.setIsBuy(true);
|
||||
}
|
||||
return R.ok().put("bookInfo",bookEntity);
|
||||
}
|
||||
|
||||
//图书章节
|
||||
@RequestMapping("/getBookChapter")
|
||||
public R getBookChapter(@RequestBody Map<String,Object> params) {
|
||||
List<BookChapterEntity> chapterList = bookChapterService.list(new LambdaQueryWrapper<BookChapterEntity>()
|
||||
.eq(BookChapterEntity::getBookId,params.get("bookId"))
|
||||
.orderByAsc(BookChapterEntity::getId));
|
||||
return R.ok().put("chapterList",chapterList);
|
||||
}
|
||||
|
||||
//章节内容
|
||||
@RequestMapping("/getBookChapterContent")
|
||||
public R getBookChapterContent(@RequestBody Map<String,Object> params) {
|
||||
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){
|
||||
int readCount = bookReadRateService.count(new LambdaQueryWrapper<BookReadRateEntity>()
|
||||
.eq(BookReadRateEntity::getBookId,params.get("bookId")));
|
||||
int buyCount = userEbookBuyService.count(new LambdaQueryWrapper<UserEbookBuyEntity>()
|
||||
.eq(UserEbookBuyEntity::getBookId,params.get("bookId")));
|
||||
int listenCount = bookListeningService.count(new LambdaQueryWrapper<BookListeningEntity>()
|
||||
.eq(BookListeningEntity::getBookId,params.get("bookId")));
|
||||
return R.ok().put("readCount",readCount).put("buyCount",buyCount).put("listenCount",listenCount);
|
||||
}
|
||||
|
||||
//获取当前书的阅读记录
|
||||
@RequestMapping("/getBookReadRate")
|
||||
public R getBookReadRate(@RequestBody Map<String,Object> params){
|
||||
BookReadRateEntity brr = bookReadRateService.getOne(new LambdaQueryWrapper<BookReadRateEntity>()
|
||||
.eq(BookReadRateEntity::getUserId,ShiroUtils.getUId())
|
||||
.eq(BookReadRateEntity::getBookId,params.get("bookId")));
|
||||
return R.ok().put("bookReadRate",brr);
|
||||
}
|
||||
|
||||
//新增阅读记录
|
||||
@RequestMapping("/insertBookReadRate")
|
||||
public R insertBookReadRate(@RequestBody BookReadRateEntity bookReadRate){
|
||||
//计算百分比
|
||||
int count = bookChapterContentService.count(new LambdaQueryWrapper<BookChapterContentEntity>()
|
||||
.eq(BookChapterContentEntity::getBookId,bookReadRate.getBookId()));
|
||||
BookChapterContentEntity bcc = bookChapterContentService.getById(bookReadRate.getContentId());
|
||||
int pre = bcc.getNumber()*100/count;
|
||||
bookReadRate.setPrecent(pre);
|
||||
BookReadRateEntity brr = bookReadRateService.getOne(new LambdaQueryWrapper<BookReadRateEntity>()
|
||||
.eq(BookReadRateEntity::getUserId,ShiroUtils.getUId())
|
||||
.eq(BookReadRateEntity::getBookId,bookReadRate.getBookId()));
|
||||
if (brr==null){
|
||||
bookReadRate.setUserId(ShiroUtils.getUId());
|
||||
bookReadRateService.save(bookReadRate);
|
||||
}else {
|
||||
brr.setChapterId(bookReadRate.getChapterId());
|
||||
brr.setChapterName(bookReadRate.getChapterName());
|
||||
brr.setContentId(bookReadRate.getContentId());
|
||||
brr.setPrecent(bookReadRate.getPrecent());
|
||||
brr.setUpdateTime(new Date());
|
||||
bookReadRateService.updateById(brr);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//相关图书
|
||||
@RequestMapping("/getRecommendBook")
|
||||
public R getRecommendBook(@RequestBody Map<String,Object> params){
|
||||
Set<BookEntity> bookList = new HashSet<>();
|
||||
//书籍绑定的标签
|
||||
List<BookAbroadToLable> tolableBookList = toLableService.list(new LambdaQueryWrapper<BookAbroadToLable>()
|
||||
.eq(BookAbroadToLable::getBookId,params.get("bookId")));
|
||||
for (BookAbroadToLable tolableBook : tolableBookList) {
|
||||
//标签下的书籍
|
||||
List<BookAbroadToLable> tolableLableList = toLableService.list(new LambdaQueryWrapper<BookAbroadToLable>()
|
||||
.eq(BookAbroadToLable::getLableId,tolableBook.getLableId()));
|
||||
for (BookAbroadToLable tolableLable : tolableLableList) {
|
||||
bookList.add(bookService.getById(tolableLable.getBookId()));
|
||||
}
|
||||
}
|
||||
return R.ok().put("bookList",bookList);
|
||||
}
|
||||
|
||||
//订单列表
|
||||
@RequestMapping("/getAbroadOrderList")
|
||||
public R getAbroadOrderList(@RequestBody Map<String,Object> params){
|
||||
Page<BuyOrder> orders = buyOrderService.page(new Page<>(
|
||||
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),new LambdaQueryWrapper<BuyOrder>()
|
||||
.eq(BuyOrder::getUserId,ShiroUtils.getUId())
|
||||
.eq(BuyOrder::getCome,3)
|
||||
.eq(BuyOrder::getOrderType,"abroadBook")
|
||||
.eq(BuyOrder::getOrderStatus,"3"));
|
||||
for (BuyOrder bo:orders.getRecords()){
|
||||
if ("abroadBook".equals(bo.getOrderType())){
|
||||
bo.setBookEntity(bookService.getById(bo.getAbroadBookId()));
|
||||
}
|
||||
}
|
||||
return R.ok().put("orders",orders);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
package com.peanut.modules.bookAbroad.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.github.promeg.pinyinhelper.Pinyin;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.config.Constants;
|
||||
import com.peanut.modules.book.service.BuyOrderService;
|
||||
import com.peanut.modules.book.service.TransactionDetailsService;
|
||||
import com.peanut.modules.book.service.UserEbookBuyService;
|
||||
import com.peanut.modules.common.entity.BookEntity;
|
||||
import com.peanut.modules.common.entity.BuyOrder;
|
||||
import com.peanut.modules.common.entity.MyUserEntity;
|
||||
import com.peanut.modules.common.service.BookService;
|
||||
import com.peanut.modules.common.service.MyUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController("bookAbroadOrder")
|
||||
@RequestMapping("bookAbroad/order")
|
||||
public class OrderController {
|
||||
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private MyUserService myUserService;
|
||||
@Autowired
|
||||
private BuyOrderService buyOrderService;
|
||||
@Autowired
|
||||
private TransactionDetailsService transactionDetailsService;
|
||||
@Autowired
|
||||
private UserEbookBuyService userEbookBuyService;
|
||||
|
||||
//海外读书下单
|
||||
@RequestMapping("/placeOrder")
|
||||
@Transactional
|
||||
public R createOrder(@RequestBody BuyOrder buyOrder){
|
||||
buyOrder.setUserId(ShiroUtils.getUId());
|
||||
buyOrder.setCome(3);//3 海外读书
|
||||
BookEntity bookEntity = bookService.getById(buyOrder.getAbroadBookId());
|
||||
BigDecimal totalPrice = buyOrder.getOrderMoney();
|
||||
//校验价格
|
||||
if (totalPrice.compareTo(new BigDecimal(0))<=0){
|
||||
return R.error("订单价格不能为0");
|
||||
}
|
||||
if (totalPrice.compareTo(bookEntity.getAbroadPrice())!=0){
|
||||
return R.error("订单价格异常");
|
||||
}
|
||||
buyOrder.setRealMoney(totalPrice);
|
||||
buyOrder.setRemark("Purchase the e-book '"+ Pinyin.toPinyin(bookEntity.getName(), " ").toLowerCase()+"'");
|
||||
buyOrder.setOrderStatus("0");
|
||||
buyOrder.setOrderType("abroadBook");
|
||||
String timeId = IdWorker.getTimeId().substring(0, 32);
|
||||
buyOrder.setOrderSn(timeId);
|
||||
buyOrderService.save(buyOrder);
|
||||
// 1. 虚拟币支付
|
||||
if (Constants.PAYMENT_METHOD_VIRTUAL.equals(buyOrder.getPaymentMethod())) {
|
||||
MyUserEntity user = ShiroUtils.getUser();
|
||||
if (user.getPeanutCoin().compareTo(totalPrice)>=0){
|
||||
//更新虚拟币
|
||||
user.setPeanutCoin(user.getPeanutCoin().subtract(totalPrice));
|
||||
myUserService.updateById(user);
|
||||
//更新订单状态
|
||||
buyOrderService.updateOrderStatus(user.getId(), buyOrder.getOrderSn(), "2");
|
||||
//记录用户虚拟币消费
|
||||
transactionDetailsService.recordTransaction(buyOrder, user, totalPrice);
|
||||
//开通电子书权限
|
||||
userEbookBuyService.addBookForUser(user.getId(), Arrays.asList(buyOrder.getAbroadBookId()));
|
||||
}else {
|
||||
return R.error(500, "天医币余额不足!");
|
||||
}
|
||||
}
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("orderSn", buyOrder.getOrderSn());
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.peanut.modules.bookAbroad.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.BookAbroadCommentLike;
|
||||
|
||||
public interface BookAbroadCommentLikeService extends IService<BookAbroadCommentLike> {
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.peanut.modules.bookAbroad.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.BookAbroadComment;
|
||||
|
||||
public interface BookAbroadCommentService extends IService<BookAbroadComment> {
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.peanut.modules.bookAbroad.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.BookAbroadLable;
|
||||
|
||||
public interface BookAbroadLableService extends IService<BookAbroadLable> {
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.peanut.modules.bookAbroad.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.BookAbroadToLable;
|
||||
|
||||
public interface BookAbroadToLableService extends IService<BookAbroadToLable> {
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.peanut.modules.bookAbroad.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.bookAbroad.service.BookAbroadCommentLikeService;
|
||||
import com.peanut.modules.common.dao.BookAbroadCommentLikeDao;
|
||||
import com.peanut.modules.common.entity.BookAbroadCommentLike;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service("bookAbroadCommentLikeService")
|
||||
public class BookAbroadCommentLikeServiceImpl extends ServiceImpl<BookAbroadCommentLikeDao, BookAbroadCommentLike> implements BookAbroadCommentLikeService {
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.peanut.modules.bookAbroad.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.common.dao.BookAbroadCommentDao;
|
||||
import com.peanut.modules.common.entity.BookAbroadComment;
|
||||
import com.peanut.modules.bookAbroad.service.BookAbroadCommentService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service("bookAbroadComment")
|
||||
public class BookAbroadCommentServiceImpl extends ServiceImpl<BookAbroadCommentDao, BookAbroadComment> implements BookAbroadCommentService {
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.peanut.modules.bookAbroad.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.common.dao.BookAbroadLableDao;
|
||||
import com.peanut.modules.common.entity.BookAbroadLable;
|
||||
import com.peanut.modules.bookAbroad.service.BookAbroadLableService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service("bookAbroadLableService")
|
||||
public class BookAbroadLableServiceImpl extends ServiceImpl<BookAbroadLableDao, BookAbroadLable> implements BookAbroadLableService {
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.peanut.modules.bookAbroad.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.bookAbroad.service.BookAbroadToLableService;
|
||||
import com.peanut.modules.common.dao.BookAbroadToLableDao;
|
||||
import com.peanut.modules.common.entity.BookAbroadToLable;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service("bookAbroadToLableService")
|
||||
public class BookAbroadToLableServiceImpl extends ServiceImpl<BookAbroadToLableDao, BookAbroadToLable> implements BookAbroadToLableService {
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.peanut.modules.common.dao;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.peanut.modules.common.entity.BookAbroadComment;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface BookAbroadCommentDao extends MPJBaseMapper<BookAbroadComment> {
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.peanut.modules.common.dao;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.peanut.modules.common.entity.BookAbroadCommentLike;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface BookAbroadCommentLikeDao extends MPJBaseMapper<BookAbroadCommentLike> {
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.peanut.modules.common.dao;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.peanut.modules.common.entity.BookAbroadLable;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface BookAbroadLableDao extends MPJBaseMapper<BookAbroadLable> {
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.peanut.modules.common.dao;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.peanut.modules.common.entity.BookAbroadToLable;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface BookAbroadToLableDao extends MPJBaseMapper<BookAbroadToLable> {
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.peanut.modules.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
//海外书籍评论
|
||||
@Data
|
||||
@TableName("book_abroad_comment")
|
||||
public class BookAbroadComment implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId
|
||||
private Integer id;
|
||||
//父id
|
||||
private Integer pid;
|
||||
//书籍id
|
||||
private Integer bookId;
|
||||
//用户id
|
||||
private Integer userId;
|
||||
//评论内容
|
||||
private String content;
|
||||
//创建时间
|
||||
private Date createTime;
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
private int isLike;
|
||||
@TableField(exist = false)
|
||||
private int likeCount;
|
||||
@TableField(exist = false)
|
||||
private MyUserEntity userEntity;
|
||||
@TableField(exist = false)
|
||||
private List<BookAbroadComment> children;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.peanut.modules.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
//海外书籍评论点赞
|
||||
@Data
|
||||
@TableName("book_abroad_comment_like")
|
||||
public class BookAbroadCommentLike implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId
|
||||
private Integer id;
|
||||
//评论id
|
||||
private Integer commentId;
|
||||
//用户id
|
||||
private Integer userId;
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package com.peanut.modules.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
//海外书籍分类
|
||||
@Data
|
||||
@TableName("book_abroad_lable")
|
||||
public class BookAbroadLable implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 父id
|
||||
*/
|
||||
private Integer pid;
|
||||
|
||||
/**
|
||||
* 类型0分类标签 1营销标签
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String etitle;
|
||||
|
||||
/**
|
||||
* 0否1是
|
||||
*/
|
||||
private Integer isLast;
|
||||
|
||||
/**
|
||||
* 权重
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
@TableField(exist = false)
|
||||
private List<BookAbroadLable> children;
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.peanut.modules.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
//海外书籍分类绑定表
|
||||
@Data
|
||||
@TableName("book_abroad_to_lable")
|
||||
public class BookAbroadToLable implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 书籍id
|
||||
*/
|
||||
private Integer bookId;
|
||||
|
||||
/**
|
||||
* 标签id
|
||||
*/
|
||||
private Integer lableId;
|
||||
|
||||
/**
|
||||
* 权重
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
package com.peanut.modules.master.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.service.BookService;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.master.service.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@RestController("masterBookAbroad")
|
||||
@RequestMapping("master/bookAbroad")
|
||||
public class BookAbroadController {
|
||||
|
||||
@Autowired
|
||||
private BookAbroadCommentService bookAbroadCommentService;
|
||||
@Autowired
|
||||
private com.peanut.modules.bookAbroad.service.BookAbroadLableService labelService;
|
||||
@Autowired
|
||||
private com.peanut.modules.bookAbroad.service.BookAbroadToLableService toLableService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
|
||||
//评论列表
|
||||
@RequestMapping("/getBookAbroadCommentList")
|
||||
public R getBookAbroadCommentList(@RequestBody Map<String,Object> params) {
|
||||
Page comments = bookAbroadCommentService.page(
|
||||
new Page<>(Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),
|
||||
new LambdaQueryWrapper<BookAbroadComment>().like(BookAbroadComment::getContent,params.get("content")));
|
||||
return R.ok().put("comments",comments);
|
||||
}
|
||||
//删除评论
|
||||
@RequestMapping("/delBookAbroadComment")
|
||||
public R delBookAbroadComment(@RequestBody Map<String,Object> params){
|
||||
bookAbroadCommentService.removeById(params.get("commentId").toString());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//新增标签
|
||||
@RequestMapping("/insertBookAbroadLable")
|
||||
public R insertBookAbroadLable(@RequestBody BookAbroadLable lable){
|
||||
labelService.save(lable);
|
||||
return R.ok().put("bookAbroadLable",lable);
|
||||
}
|
||||
|
||||
//标签详情
|
||||
@RequestMapping("/bookAbroadLableInfo")
|
||||
public R bookAbroadLableInfo(@RequestBody Map<String,Object> params){
|
||||
BookAbroadLable lable = labelService.getById(params.get("id").toString());
|
||||
return R.ok().put("lable",lable);
|
||||
}
|
||||
|
||||
//修改标签
|
||||
@RequestMapping("/updateBookAbroadLable")
|
||||
public R updateBookAbroadLable(@RequestBody BookAbroadLable lable){
|
||||
BookAbroadLable oldLable = labelService.getById(lable.getId());
|
||||
if (oldLable.getIsLast()!=lable.getIsLast()) {
|
||||
int count = toLableService.count(new LambdaQueryWrapper<BookAbroadToLable>()
|
||||
.eq(BookAbroadToLable::getLableId,lable.getId()));
|
||||
if (count > 0){
|
||||
return R.error("存在绑定书籍,删除后再操作");
|
||||
}
|
||||
}
|
||||
labelService.updateById(lable);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//删除标签
|
||||
@RequestMapping("/delBookAbroadLable")
|
||||
public R delBookAbroadLable(@RequestBody Map<String,Object> params){
|
||||
BookAbroadLable oldLable = labelService.getById(params.get("id").toString());
|
||||
if (oldLable.getIsLast()!=1){
|
||||
return R.error("不是最下级,禁止删除");
|
||||
}
|
||||
int count = toLableService.count(new LambdaQueryWrapper<BookAbroadToLable>()
|
||||
.eq(BookAbroadToLable::getLableId,params.get("id").toString()));
|
||||
if (count > 0){
|
||||
return R.error("存在绑定书籍,删除后再操作");
|
||||
}
|
||||
labelService.removeById(oldLable.getId());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//绑定图书和标签
|
||||
@RequestMapping("/insertBookAbroadToLable")
|
||||
public R insertBookAbroadToLable(@RequestBody BookAbroadToLable toLable){
|
||||
BookAbroadLable oldLable = labelService.getById(toLable.getLableId());
|
||||
if (oldLable.getIsLast()!=1){
|
||||
return R.error("不是最下级,禁止绑定");
|
||||
}
|
||||
int count = toLableService.count(new LambdaQueryWrapper<BookAbroadToLable>()
|
||||
.eq(BookAbroadToLable::getBookId,toLable.getBookId())
|
||||
.eq(BookAbroadToLable::getLableId,toLable.getLableId()));
|
||||
if (count > 0) {
|
||||
return R.error("已存在");
|
||||
}
|
||||
toLableService.save(toLable);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//解绑
|
||||
@RequestMapping("/delBookAbroadToLable")
|
||||
public R delBookAbroadToLable(@RequestBody Map<String,Object> params){
|
||||
String[] strings = params.get("ids").toString().split(",");
|
||||
toLableService.removeByIds(Arrays.asList(strings));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//标签可绑定图书
|
||||
@RequestMapping("/getBookListCanToLable")
|
||||
public R getBookListCanToLable(@RequestBody Map<String,Object> params) {
|
||||
List<Integer> collect = toLableService.list(new LambdaQueryWrapper<BookAbroadToLable>()
|
||||
.eq(BookAbroadToLable::getLableId, params.get("lableId")))
|
||||
.stream().map(BookAbroadToLable::getBookId).collect(Collectors.toList());
|
||||
LambdaQueryWrapper<BookEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
if (collect.size() != 0){
|
||||
wrapper.notIn(BookEntity::getId,collect);
|
||||
}
|
||||
wrapper.like(StringUtils.isNotBlank(params.get("bookName").toString()),BookEntity::getTitle,params.get("bookName"));
|
||||
Page<BookEntity> page = bookService.page(new Page<>(Long.valueOf(params.get("current").toString()),Long.valueOf(params.get("limit").toString())), wrapper);
|
||||
return R.ok().put("page",page);
|
||||
}
|
||||
|
||||
//通过标签获取绑定图书
|
||||
@RequestMapping("/getAbroadBookListByLable")
|
||||
public R getAbroadBookListByLable(@RequestBody Map<String,Object> params) {
|
||||
MPJLambdaWrapper<BookAbroadToLable> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.leftJoin(BookEntity.class,BookEntity::getId,BookAbroadToLable::getBookId);
|
||||
wrapper.selectAs(BookAbroadToLable::getId,"id");
|
||||
wrapper.select(BookEntity::getName);
|
||||
wrapper.select(BookAbroadToLable::getSort);
|
||||
wrapper.select(BookAbroadToLable::getBookId);
|
||||
wrapper.eq(BookAbroadToLable::getLableId,params.get("lableId"));
|
||||
wrapper.orderByAsc(BookAbroadToLable::getSort);
|
||||
return R.ok().put("bookList",toLableService.listMaps(wrapper));
|
||||
}
|
||||
|
||||
//修改排序
|
||||
@RequestMapping("/updateToLableSort")
|
||||
public R updateToLableSort(@RequestBody Map<String,Object> params){
|
||||
BookAbroadToLable toLable = toLableService.getById(params.get("toLableId").toString());
|
||||
toLable.setSort(Integer.parseInt(params.get("sort").toString()));
|
||||
toLableService.updateById(toLable);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//标签树
|
||||
@RequestMapping("/getLableTree")
|
||||
public R getLableTree(@RequestBody Map<String,Object> params) {
|
||||
List<BookAbroadLable> labels = labelService.list(new LambdaQueryWrapper<BookAbroadLable>()
|
||||
.eq(BookAbroadLable::getType,params.get("type")));
|
||||
List<BookAbroadLable> labelsTree = labels.stream().filter((bookAbroadLable) ->
|
||||
bookAbroadLable.getPid() == 0
|
||||
).map((label)->{
|
||||
label.setChildren(getLabelChildrens(label,labels));
|
||||
return label;
|
||||
}).sorted((label1,label2)->{
|
||||
return (label1.getSort() == null? 0 : label1.getSort()) - (label2.getSort()==null?0:label2.getSort());
|
||||
}).collect(Collectors.toList());
|
||||
return R.ok().put("labelsTree",labelsTree);
|
||||
}
|
||||
|
||||
private List<BookAbroadLable> getLabelChildrens(BookAbroadLable root,List<BookAbroadLable> all){
|
||||
List<BookAbroadLable> children = all.stream().filter(bookAbroadLable -> {
|
||||
return root.getId().equals(bookAbroadLable.getPid());
|
||||
}).map(bookAbroadLable -> {
|
||||
bookAbroadLable.setChildren(getLabelChildrens(bookAbroadLable, all));
|
||||
return bookAbroadLable;
|
||||
}).sorted((label1,label2)->{
|
||||
return (label1.getSort()==null?0:label1.getSort()) - (label2.getSort()==null?0:label2.getSort());
|
||||
}).collect(Collectors.toList());
|
||||
return children;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.peanut.modules.master.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.BookAbroadCommentLike;
|
||||
|
||||
public interface BookAbroadCommentLikeService extends IService<BookAbroadCommentLike> {
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.peanut.modules.master.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.BookAbroadComment;
|
||||
|
||||
public interface BookAbroadCommentService extends IService<BookAbroadComment> {
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.peanut.modules.master.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.BookAbroadLable;
|
||||
|
||||
public interface BookAbroadLableService extends IService<BookAbroadLable> {
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.peanut.modules.master.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.BookAbroadToLable;
|
||||
|
||||
public interface BookAbroadToLableService extends IService<BookAbroadToLable> {
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.peanut.modules.master.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.common.dao.BookAbroadCommentLikeDao;
|
||||
import com.peanut.modules.common.entity.BookAbroadCommentLike;
|
||||
import com.peanut.modules.master.service.BookAbroadCommentLikeService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service("masterBookAbroadCommentLikeService")
|
||||
public class BookAbroadCommentLikeServiceImpl extends ServiceImpl<BookAbroadCommentLikeDao, BookAbroadCommentLike> implements BookAbroadCommentLikeService {
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.peanut.modules.master.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.common.dao.BookAbroadCommentDao;
|
||||
import com.peanut.modules.common.entity.BookAbroadComment;
|
||||
import com.peanut.modules.master.service.BookAbroadCommentService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service("masterBookAbroadCommentService")
|
||||
public class BookAbroadCommentServiceImpl extends ServiceImpl<BookAbroadCommentDao, BookAbroadComment> implements BookAbroadCommentService {
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.peanut.modules.master.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.common.dao.BookAbroadLableDao;
|
||||
import com.peanut.modules.common.entity.BookAbroadLable;
|
||||
import com.peanut.modules.master.service.BookAbroadLableService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service("masterBookAbroadLableService")
|
||||
public class BookAbroadLableServiceImpl extends ServiceImpl<BookAbroadLableDao, BookAbroadLable> implements BookAbroadLableService {
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.peanut.modules.master.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.common.dao.BookAbroadToLableDao;
|
||||
import com.peanut.modules.common.entity.BookAbroadToLable;
|
||||
import com.peanut.modules.master.service.BookAbroadToLableService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service("masterBookAbroadToLableService")
|
||||
public class BookAbroadToLableServiceImpl extends ServiceImpl<BookAbroadToLableDao, BookAbroadToLable> implements BookAbroadToLableService {
|
||||
}
|
||||
Reference in New Issue
Block a user