图书类型 中医经典 中医基础 各家学说 中医临床 文学 哲学

This commit is contained in:
wuchunlei
2024-01-09 15:10:48 +08:00
parent 27e11c968e
commit be33a443dc
3 changed files with 61 additions and 15 deletions

View File

@@ -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);

View File

@@ -7,6 +7,7 @@ import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
import com.peanut.modules.book.dao.ShopProductLabelDao;
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.ShopProductLabelEntity;
import com.peanut.modules.book.entity.ShopProductToLabelEntity;
@@ -103,16 +104,21 @@ public class ShopProductLabelController {
* @return
*/
@RequestMapping("/getProductsByLabel")
public R getProductsByLabel(@RequestParam Integer splId,@RequestParam Integer limit,@RequestParam Integer page){
MPJLambdaWrapper<ShopProductToLabelEntity> shopProductEntityMPJLambdaWrapper = new MPJLambdaWrapper<ShopProductToLabelEntity>();
shopProductEntityMPJLambdaWrapper.selectAll(ShopProduct.class);
shopProductEntityMPJLambdaWrapper.leftJoin(ShopProduct.class, ShopProduct::getProductId,ShopProductToLabelEntity::getProductId);
shopProductEntityMPJLambdaWrapper.eq(ShopProductToLabelEntity::getSplId,splId);
shopProductEntityMPJLambdaWrapper.eq(ShopProductToLabelEntity::getDelFlag,0);
shopProductEntityMPJLambdaWrapper.eq(ShopProduct::getDelFlag,0);
shopProductEntityMPJLambdaWrapper.gt(ShopProduct::getProductStock,0);
Page<ShopProduct> shopProductEntityPage = shopProductToLabelDao.selectJoinPage(new Page<ShopProduct>(page, limit), ShopProduct.class, shopProductEntityMPJLambdaWrapper);
public R getProductsByLabel(Integer splId,Integer limit,Integer page,Integer type){
MPJLambdaWrapper<ShopProductToLabelEntity> wrapper = new MPJLambdaWrapper<ShopProductToLabelEntity>();
wrapper.selectAll(ShopProduct.class);
wrapper.leftJoin(ShopProduct.class, ShopProduct::getProductId,ShopProductToLabelEntity::getProductId);
wrapper.eq(ShopProductToLabelEntity::getSplId,splId);
wrapper.eq(ShopProductToLabelEntity::getDelFlag,0);
wrapper.eq(ShopProduct::getDelFlag,0);
wrapper.gt(ShopProduct::getProductStock,0);
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);
}
}

View File

@@ -190,5 +190,11 @@ public class BookEntity implements Serializable {
private Integer clockIn;
/**
* 图书类型 中医经典 中医基础 各家学说 中医临床 文学 哲学
*/
@TableField(exist = false)
private String medicaldesBookType;
}