图书类型 中医经典 中医基础 各家学说 中医临床 文学 哲学
This commit is contained in:
@@ -8,6 +8,7 @@ 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.plugins.pagination.Page;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.common.utils.ReadProvinceUtil;
|
||||
import com.peanut.modules.book.dao.BookDao;
|
||||
@@ -15,6 +16,7 @@ import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.book.vo.BookIndexVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -63,6 +65,8 @@ public class BookController {
|
||||
private ShopProductBookService shopProductBookService;
|
||||
@Autowired
|
||||
private ShopProductToLabelService shopProductToLabelService;
|
||||
@Autowired
|
||||
private MedicaldesBookService medicaldesBookService;
|
||||
final ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10);
|
||||
|
||||
/**
|
||||
@@ -235,7 +239,16 @@ public class BookController {
|
||||
|
||||
public R save(@RequestBody BookEntity book) {
|
||||
bookService.save(book);
|
||||
|
||||
//添加图书类型关系表
|
||||
String[] types = book.getMedicaldesBookType().split(",");
|
||||
if (types.length > 0) {
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
MedicaldesBook medicaldesBook = new MedicaldesBook();
|
||||
medicaldesBook.setBookId(book.getId());
|
||||
medicaldesBook.setTypeId(Integer.parseInt(types[i]));
|
||||
medicaldesBookService.save(medicaldesBook);
|
||||
}
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -276,7 +289,24 @@ public class BookController {
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody BookEntity book) {
|
||||
bookService.updateById(book);
|
||||
|
||||
//修改图书类型关系表
|
||||
//先删除
|
||||
LambdaQueryWrapper<MedicaldesBook> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(MedicaldesBook::getBookId,book.getId());
|
||||
List list = medicaldesBookService.list(wrapper);
|
||||
if (list.size() > 0) {
|
||||
medicaldesBookService.removeByIds(list);
|
||||
}
|
||||
//再添加
|
||||
String[] types = book.getMedicaldesBookType().split(",");
|
||||
if (types.length > 0) {
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
MedicaldesBook medicaldesBook = new MedicaldesBook();
|
||||
medicaldesBook.setBookId(book.getId());
|
||||
medicaldesBook.setTypeId(Integer.parseInt(types[i]));
|
||||
medicaldesBookService.save(medicaldesBook);
|
||||
}
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -690,17 +720,21 @@ public class BookController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getMyBooks")
|
||||
public R getMyBooks(@RequestParam Integer userId,@RequestParam Integer limit,@RequestParam Integer page){
|
||||
public R getMyBooks(Integer userId,Integer limit,Integer page,Integer type){
|
||||
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<>();
|
||||
MPJLambdaWrapper<BookEntity> wrapper1 = new MPJLambdaWrapper<>();
|
||||
wrapper1.eq(BookEntity::getDelFlag,0);
|
||||
if(bookIds.size()>0){
|
||||
wrapper1.in(BookEntity::getId,bookIds);
|
||||
}
|
||||
if (type!=null){
|
||||
wrapper1.selectAll(BookEntity.class);
|
||||
wrapper1.leftJoin(MedicaldesBook.class,MedicaldesBook::getBookId,BookEntity::getId);
|
||||
wrapper1.eq(MedicaldesBook::getTypeId,type);
|
||||
}
|
||||
Page<BookEntity> bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper1);
|
||||
|
||||
return R.ok().put("page",bookEntityPage);
|
||||
|
||||
Reference in New Issue
Block a user