新版
This commit is contained in:
@@ -2,6 +2,7 @@ package com.peanut.modules.book.controller;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@@ -111,7 +112,7 @@ public class BookController {
|
||||
wrapper.eq(UserEbookBuyEntity::getUserId,userId);
|
||||
wrapper.eq(UserEbookBuyEntity::getBookId,bookId);
|
||||
List<UserEbookBuyEntity> userEbookBuyEntities = userEbookBuyService.getBaseMapper().selectList(wrapper);
|
||||
book_info.setIsBuy(userEbookBuyEntities==null?false:true);
|
||||
book_info.setIsBuy(userEbookBuyEntities.size()==0?false:true);
|
||||
return R.ok().put("book",book_info);
|
||||
}
|
||||
|
||||
@@ -653,6 +654,53 @@ public class BookController {
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取我的已购图书
|
||||
* @param userId
|
||||
* @param limit
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getMyBooks")
|
||||
public R getMyBooks(@RequestParam Integer userId,@RequestParam Integer limit,@RequestParam Integer page){
|
||||
LambdaQueryWrapper<UserEbookBuyEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(UserEbookBuyEntity::getUserId,userId);
|
||||
wrapper.groupBy(UserEbookBuyEntity::getBookId);
|
||||
List<Integer> bookIds = userEbookBuyService.getBaseMapper().selectList(wrapper).stream().map(UserEbookBuyEntity::getBookId).collect(Collectors.toList());
|
||||
|
||||
LambdaQueryWrapper<BookEntity> wrapper1 = new LambdaQueryWrapper<>();
|
||||
wrapper1.eq(BookEntity::getDelFlag,0);
|
||||
wrapper1.in(BookEntity::getId,bookIds);
|
||||
Page<BookEntity> bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper1);
|
||||
|
||||
return R.ok().put("page",bookEntityPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取我的推荐图书
|
||||
* @param userId
|
||||
* @param limit
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getBestBooks")
|
||||
public R getBestBooks(@RequestParam Integer userId,@RequestParam Integer limit,@RequestParam Integer page){
|
||||
LambdaQueryWrapper<UserEbookBuyEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(UserEbookBuyEntity::getUserId,userId);
|
||||
wrapper.groupBy(UserEbookBuyEntity::getBookId);
|
||||
List<Integer> bookIds = userEbookBuyService.getBaseMapper().selectList(wrapper).stream().map(UserEbookBuyEntity::getBookId).collect(Collectors.toList());
|
||||
|
||||
LambdaQueryWrapper<BookEntity> wrapper1 = new LambdaQueryWrapper<>();
|
||||
wrapper1.eq(BookEntity::getDelFlag,0);
|
||||
wrapper1.notIn(BookEntity::getId,bookIds);
|
||||
Page<BookEntity> bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper1);
|
||||
for (BookEntity b : bookEntityPage.getRecords()){
|
||||
b.setProductId(shopProudictBookService.getProductByBookId(b.getId()));
|
||||
}
|
||||
|
||||
return R.ok().put("page",bookEntityPage);
|
||||
}
|
||||
|
||||
|
||||
//新书
|
||||
@RequestMapping("/getNewBook")
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.peanut.modules.book.entity.BookEntity;
|
||||
import com.peanut.modules.book.entity.BookTeachEntity;
|
||||
import com.peanut.modules.book.service.BookService;
|
||||
import com.peanut.modules.book.service.BookTeachService;
|
||||
import com.peanut.modules.book.service.ShopProudictBookService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -23,6 +24,8 @@ public class BookTeachController {
|
||||
private BookTeachService bookTeachService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private ShopProudictBookService shopProudictBookService;
|
||||
|
||||
/**
|
||||
* 获取讲书列表
|
||||
@@ -59,8 +62,9 @@ public class BookTeachController {
|
||||
*/
|
||||
@RequestMapping("/getTeachDetail")
|
||||
public R getTeachDetail(@RequestParam Integer teachId){
|
||||
BookTeachEntity byId = bookTeachService.getById(teachId);
|
||||
return R.ok().put("bookTeach",byId);
|
||||
BookTeachEntity teach_info = bookTeachService.getById(teachId);
|
||||
Integer productByBookId = shopProudictBookService.getProductByBookId(teach_info.getBookId());
|
||||
return R.ok().put("bookTeach",teach_info).put("product",productByBookId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user