图书类型 中医经典 中医基础 各家学说 中医临床 文学 哲学
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.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
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.Query;
|
||||||
import com.peanut.common.utils.ReadProvinceUtil;
|
import com.peanut.common.utils.ReadProvinceUtil;
|
||||||
import com.peanut.modules.book.dao.BookDao;
|
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.service.*;
|
||||||
import com.peanut.modules.book.vo.BookIndexVo;
|
import com.peanut.modules.book.vo.BookIndexVo;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -63,6 +65,8 @@ public class BookController {
|
|||||||
private ShopProductBookService shopProductBookService;
|
private ShopProductBookService shopProductBookService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ShopProductToLabelService shopProductToLabelService;
|
private ShopProductToLabelService shopProductToLabelService;
|
||||||
|
@Autowired
|
||||||
|
private MedicaldesBookService medicaldesBookService;
|
||||||
final ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10);
|
final ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -235,7 +239,16 @@ public class BookController {
|
|||||||
|
|
||||||
public R save(@RequestBody BookEntity book) {
|
public R save(@RequestBody BookEntity book) {
|
||||||
bookService.save(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();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,7 +289,24 @@ public class BookController {
|
|||||||
@RequestMapping("/update")
|
@RequestMapping("/update")
|
||||||
public R update(@RequestBody BookEntity book) {
|
public R update(@RequestBody BookEntity book) {
|
||||||
bookService.updateById(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();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -690,17 +720,21 @@ public class BookController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/getMyBooks")
|
@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<>();
|
LambdaQueryWrapper<UserEbookBuyEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(UserEbookBuyEntity::getUserId,userId);
|
wrapper.eq(UserEbookBuyEntity::getUserId,userId);
|
||||||
wrapper.groupBy(UserEbookBuyEntity::getBookId);
|
wrapper.groupBy(UserEbookBuyEntity::getBookId);
|
||||||
List<Integer> bookIds = userEbookBuyService.getBaseMapper().selectList(wrapper).stream().map(UserEbookBuyEntity::getBookId).collect(Collectors.toList());
|
List<Integer> bookIds = userEbookBuyService.getBaseMapper().selectList(wrapper).stream().map(UserEbookBuyEntity::getBookId).collect(Collectors.toList());
|
||||||
|
MPJLambdaWrapper<BookEntity> wrapper1 = new MPJLambdaWrapper<>();
|
||||||
LambdaQueryWrapper<BookEntity> wrapper1 = new LambdaQueryWrapper<>();
|
|
||||||
wrapper1.eq(BookEntity::getDelFlag,0);
|
wrapper1.eq(BookEntity::getDelFlag,0);
|
||||||
if(bookIds.size()>0){
|
if(bookIds.size()>0){
|
||||||
wrapper1.in(BookEntity::getId,bookIds);
|
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);
|
Page<BookEntity> bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper1);
|
||||||
|
|
||||||
return R.ok().put("page",bookEntityPage);
|
return R.ok().put("page",bookEntityPage);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.peanut.common.utils.PageUtils;
|
|||||||
import com.peanut.common.utils.R;
|
import com.peanut.common.utils.R;
|
||||||
import com.peanut.modules.book.dao.ShopProductLabelDao;
|
import com.peanut.modules.book.dao.ShopProductLabelDao;
|
||||||
import com.peanut.modules.book.dao.ShopProductToLabelDao;
|
import com.peanut.modules.book.dao.ShopProductToLabelDao;
|
||||||
|
import com.peanut.modules.book.entity.MedicaldesBook;
|
||||||
import com.peanut.modules.book.entity.ShopProduct;
|
import com.peanut.modules.book.entity.ShopProduct;
|
||||||
import com.peanut.modules.book.entity.ShopProductLabelEntity;
|
import com.peanut.modules.book.entity.ShopProductLabelEntity;
|
||||||
import com.peanut.modules.book.entity.ShopProductToLabelEntity;
|
import com.peanut.modules.book.entity.ShopProductToLabelEntity;
|
||||||
@@ -103,16 +104,21 @@ public class ShopProductLabelController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/getProductsByLabel")
|
@RequestMapping("/getProductsByLabel")
|
||||||
public R getProductsByLabel(@RequestParam Integer splId,@RequestParam Integer limit,@RequestParam Integer page){
|
public R getProductsByLabel(Integer splId,Integer limit,Integer page,Integer type){
|
||||||
MPJLambdaWrapper<ShopProductToLabelEntity> shopProductEntityMPJLambdaWrapper = new MPJLambdaWrapper<ShopProductToLabelEntity>();
|
MPJLambdaWrapper<ShopProductToLabelEntity> wrapper = new MPJLambdaWrapper<ShopProductToLabelEntity>();
|
||||||
shopProductEntityMPJLambdaWrapper.selectAll(ShopProduct.class);
|
wrapper.selectAll(ShopProduct.class);
|
||||||
shopProductEntityMPJLambdaWrapper.leftJoin(ShopProduct.class, ShopProduct::getProductId,ShopProductToLabelEntity::getProductId);
|
wrapper.leftJoin(ShopProduct.class, ShopProduct::getProductId,ShopProductToLabelEntity::getProductId);
|
||||||
shopProductEntityMPJLambdaWrapper.eq(ShopProductToLabelEntity::getSplId,splId);
|
wrapper.eq(ShopProductToLabelEntity::getSplId,splId);
|
||||||
shopProductEntityMPJLambdaWrapper.eq(ShopProductToLabelEntity::getDelFlag,0);
|
wrapper.eq(ShopProductToLabelEntity::getDelFlag,0);
|
||||||
shopProductEntityMPJLambdaWrapper.eq(ShopProduct::getDelFlag,0);
|
wrapper.eq(ShopProduct::getDelFlag,0);
|
||||||
shopProductEntityMPJLambdaWrapper.gt(ShopProduct::getProductStock,0);
|
wrapper.gt(ShopProduct::getProductStock,0);
|
||||||
Page<ShopProduct> shopProductEntityPage = shopProductToLabelDao.selectJoinPage(new Page<ShopProduct>(page, limit), ShopProduct.class, shopProductEntityMPJLambdaWrapper);
|
if (type!=null){
|
||||||
|
wrapper.leftJoin(MedicaldesBook.class, MedicaldesBook::getBookId,ShopProduct::getBookId);
|
||||||
|
wrapper.inSql(ShopProduct::getProductId,"select product_id from shop_product where book_Ids not like \"%,%\"");
|
||||||
|
wrapper.eq(MedicaldesBook::getTypeId,type);
|
||||||
|
}
|
||||||
|
Page<ShopProduct> shopProductEntityPage = shopProductToLabelDao.selectJoinPage(new Page<ShopProduct>(page, limit),
|
||||||
|
ShopProduct.class, wrapper);
|
||||||
return R.ok().put("page",shopProductEntityPage);
|
return R.ok().put("page",shopProductEntityPage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -190,5 +190,11 @@ public class BookEntity implements Serializable {
|
|||||||
|
|
||||||
private Integer clockIn;
|
private Integer clockIn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图书类型 中医经典 中医基础 各家学说 中医临床 文学 哲学
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String medicaldesBookType;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user