diff --git a/src/main/java/com/peanut/modules/book/controller/BookChapterController.java b/src/main/java/com/peanut/modules/book/controller/BookChapterController.java index f14103ca..ab0cf2be 100644 --- a/src/main/java/com/peanut/modules/book/controller/BookChapterController.java +++ b/src/main/java/com/peanut/modules/book/controller/BookChapterController.java @@ -277,6 +277,8 @@ public class BookChapterController { public R delete(@RequestBody Integer[] ids) { for(Integer id : ids){ + + BookChapterEntity chapter = bookChapterService.getBaseMapper().selectOne(new QueryWrapper() .eq("id", id) ); diff --git a/src/main/java/com/peanut/modules/book/controller/BookForumArticlesServiceController.java b/src/main/java/com/peanut/modules/book/controller/BookForumArticlesServiceController.java index d56ca515..edecec7e 100644 --- a/src/main/java/com/peanut/modules/book/controller/BookForumArticlesServiceController.java +++ b/src/main/java/com/peanut/modules/book/controller/BookForumArticlesServiceController.java @@ -34,6 +34,8 @@ public class BookForumArticlesServiceController { } + + /** * 列表 (修改时间倒叙) app页面 */ diff --git a/src/main/java/com/peanut/modules/book/controller/ShopProductController.java b/src/main/java/com/peanut/modules/book/controller/ShopProductController.java index aa1ae5b7..915cb408 100644 --- a/src/main/java/com/peanut/modules/book/controller/ShopProductController.java +++ b/src/main/java/com/peanut/modules/book/controller/ShopProductController.java @@ -215,6 +215,7 @@ public class ShopProductController { */ @RequestMapping("/getGlProductList") public R getGlProductList(@RequestParam int productId) { + //获取此商品下的books List ids = shopProudictBookService.getBookidsByProductId(productId); @@ -226,7 +227,10 @@ public class ShopProductController { ); List frag = new ArrayList<>(); - + //如果绑定的书为空,直接返回空值 + if(ids.size()==0){ + return R.ok(); + } for (ShopProudictBookEntity spbe : ss){ ShopProductEntity ca_sp = shopProductService.getById(spbe.getProudictId()); frag.add(ca_sp); @@ -335,8 +339,9 @@ public class ShopProductController { @RequestMapping("/update") public R update(@RequestBody ShopProductEntity shopProduct) { + //商品id Integer productId = shopProduct.getProductId(); - List list = new ArrayList<>(); + //多个图书id ArrayList bookId = shopProduct.getBookids(); shopProduct.setCreateTime(new Date()); @@ -351,70 +356,35 @@ public class ShopProductController { } else { shopProduct.setBookId(""); } + //传过来的proudictid只有一个,但是bookid可能有多个,对应的一个proudictid一个bookid为一条数据,一对多存储 List bookyList = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper() .eq("proudict_id", productId)); - for (ShopProudictBookEntity shopProudictBookEntity : bookyList) { - Integer bookId1 = shopProudictBookEntity.getBookId(); - list.add(bookId1); + +// List list = new ArrayList<>(); +// for (ShopProudictBookEntity shopProudictBookEntity : bookyList) { +// Integer proudictBookbookId1 = shopProudictBookEntity.getBookId(); +// list.add(proudictBookbookId1); +// +// } + Integer shop_book_ids [] = new Integer[bookyList.size()]; + for(int i=0; i 0){ + shopProudictBookService.getBaseMapper().deleteBatchIds(Arrays.asList(shop_book_ids)); } - List filteredBookIds = new ArrayList<>(); - for ( String s : bookId) { - if (!list.contains(s)) { - filteredBookIds.add(s); - } - } - - - if (bookyList.size() > bookId.size()) { - - if ( bookId.size()==0){ - List bookEntityList = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper() - .eq("proudict_id", productId)); - for (ShopProudictBookEntity shopProductBook :bookEntityList) { - Integer id = shopProductBook.getId(); - shopProudictBookService.removeById(id); - } - - - - }else { - List bookEntityList = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper() - .eq("proudict_id", productId) - .notIn("book_id", bookId) - ); - for (ShopProudictBookEntity shopProudictBookEntity : bookEntityList) { - - Integer id = shopProudictBookEntity.getId(); - shopProudictBookService.removeById(id); - } - - - } - - - - - } else if (bookyList.size() < bookId.size()) { - ShopProudictBookEntity shopProudictBookEntity = new ShopProudictBookEntity(); - for (String s : filteredBookIds) { - String bookidlist = s; - + ShopProudictBookEntity shopProudictBookEntity = new ShopProudictBookEntity(); + for (String s : shopProduct.getBookids()) { + String bookidlist = s; + if (bookidlist != null) { Integer proudict = shopProduct.getProductId(); shopProudictBookEntity.setProudictId(proudict); shopProudictBookEntity.setBookId(Integer.valueOf(bookidlist)); shopProudictBookService.save(shopProudictBookEntity); - } - - - //查询proudict中,不包含传过来的bookid - - - - - } + shopProductService.updateById(shopProduct); return R.ok(); } diff --git a/src/main/java/com/peanut/modules/book/entity/BookForumArticlesEntity.java b/src/main/java/com/peanut/modules/book/entity/BookForumArticlesEntity.java index 922ed0e3..ceb787f3 100644 --- a/src/main/java/com/peanut/modules/book/entity/BookForumArticlesEntity.java +++ b/src/main/java/com/peanut/modules/book/entity/BookForumArticlesEntity.java @@ -78,4 +78,10 @@ public class BookForumArticlesEntity { private String publishername; + @TableField("bookdesc") + private String bookdesc; + + + + } diff --git a/src/main/resources/mapper/book/BookForumArticlesDao.xml b/src/main/resources/mapper/book/BookForumArticlesDao.xml index caa3fcc3..55c0fe84 100644 --- a/src/main/resources/mapper/book/BookForumArticlesDao.xml +++ b/src/main/resources/mapper/book/BookForumArticlesDao.xml @@ -18,6 +18,7 @@ +