--9.20提交修改

This commit is contained in:
yc13649764453
2023-09-20 15:01:44 +08:00
parent b67ccaf457
commit 4f614135a5
5 changed files with 37 additions and 56 deletions

View File

@@ -277,6 +277,8 @@ public class BookChapterController {
public R delete(@RequestBody Integer[] ids) { public R delete(@RequestBody Integer[] ids) {
for(Integer id : ids){ for(Integer id : ids){
BookChapterEntity chapter = bookChapterService.getBaseMapper().selectOne(new QueryWrapper<BookChapterEntity>() BookChapterEntity chapter = bookChapterService.getBaseMapper().selectOne(new QueryWrapper<BookChapterEntity>()
.eq("id", id) .eq("id", id)
); );

View File

@@ -34,6 +34,8 @@ public class BookForumArticlesServiceController {
} }
/** /**
* 列表 (修改时间倒叙) app页面 * 列表 (修改时间倒叙) app页面
*/ */

View File

@@ -215,6 +215,7 @@ public class ShopProductController {
*/ */
@RequestMapping("/getGlProductList") @RequestMapping("/getGlProductList")
public R getGlProductList(@RequestParam int productId) { public R getGlProductList(@RequestParam int productId) {
//获取此商品下的books //获取此商品下的books
List<Integer> ids = shopProudictBookService.getBookidsByProductId(productId); List<Integer> ids = shopProudictBookService.getBookidsByProductId(productId);
@@ -226,7 +227,10 @@ public class ShopProductController {
); );
List<ShopProductEntity> frag = new ArrayList<>(); List<ShopProductEntity> frag = new ArrayList<>();
//如果绑定的书为空,直接返回空值
if(ids.size()==0){
return R.ok();
}
for (ShopProudictBookEntity spbe : ss){ for (ShopProudictBookEntity spbe : ss){
ShopProductEntity ca_sp = shopProductService.getById(spbe.getProudictId()); ShopProductEntity ca_sp = shopProductService.getById(spbe.getProudictId());
frag.add(ca_sp); frag.add(ca_sp);
@@ -335,8 +339,9 @@ public class ShopProductController {
@RequestMapping("/update") @RequestMapping("/update")
public R update(@RequestBody ShopProductEntity shopProduct) { public R update(@RequestBody ShopProductEntity shopProduct) {
//商品id
Integer productId = shopProduct.getProductId(); Integer productId = shopProduct.getProductId();
List<Object> list = new ArrayList<>();
//多个图书id //多个图书id
ArrayList<String> bookId = shopProduct.getBookids(); ArrayList<String> bookId = shopProduct.getBookids();
shopProduct.setCreateTime(new Date()); shopProduct.setCreateTime(new Date());
@@ -351,70 +356,35 @@ public class ShopProductController {
} else { } else {
shopProduct.setBookId(""); shopProduct.setBookId("");
} }
//传过来的proudictid只有一个但是bookid可能有多个对应的一个proudictid一个bookid为一条数据一对多存储
List<ShopProudictBookEntity> bookyList = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>() List<ShopProudictBookEntity> bookyList = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>()
.eq("proudict_id", productId)); .eq("proudict_id", productId));
for (ShopProudictBookEntity shopProudictBookEntity : bookyList) {
Integer bookId1 = shopProudictBookEntity.getBookId(); // List<Object> list = new ArrayList<>();
list.add(bookId1); // for (ShopProudictBookEntity shopProudictBookEntity : bookyList) {
// Integer proudictBookbookId1 = shopProudictBookEntity.getBookId();
// list.add(proudictBookbookId1);
//
// }
Integer shop_book_ids [] = new Integer[bookyList.size()];
for(int i=0; i<bookyList.size(); i++){
shop_book_ids[i] = bookyList.get(i).getId();
}
if(null != shop_book_ids && shop_book_ids.length > 0){
shopProudictBookService.getBaseMapper().deleteBatchIds(Arrays.asList(shop_book_ids));
} }
List<String> filteredBookIds = new ArrayList<>(); ShopProudictBookEntity shopProudictBookEntity = new ShopProudictBookEntity();
for ( String s : bookId) { for (String s : shopProduct.getBookids()) {
if (!list.contains(s)) { String bookidlist = s;
filteredBookIds.add(s); if (bookidlist != null) {
}
}
if (bookyList.size() > bookId.size()) {
if ( bookId.size()==0){
List<ShopProudictBookEntity> bookEntityList = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>()
.eq("proudict_id", productId));
for (ShopProudictBookEntity shopProductBook :bookEntityList) {
Integer id = shopProductBook.getId();
shopProudictBookService.removeById(id);
}
}else {
List<ShopProudictBookEntity> bookEntityList = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>()
.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;
Integer proudict = shopProduct.getProductId(); Integer proudict = shopProduct.getProductId();
shopProudictBookEntity.setProudictId(proudict); shopProudictBookEntity.setProudictId(proudict);
shopProudictBookEntity.setBookId(Integer.valueOf(bookidlist)); shopProudictBookEntity.setBookId(Integer.valueOf(bookidlist));
shopProudictBookService.save(shopProudictBookEntity); shopProudictBookService.save(shopProudictBookEntity);
} }
//查询proudict中不包含传过来的bookid
} }
shopProductService.updateById(shopProduct); shopProductService.updateById(shopProduct);
return R.ok(); return R.ok();
} }

View File

@@ -78,4 +78,10 @@ public class BookForumArticlesEntity {
private String publishername; private String publishername;
@TableField("bookdesc")
private String bookdesc;
} }

View File

@@ -18,6 +18,7 @@
<result property="delflag" column="del_flag" /> <result property="delflag" column="del_flag" />
<result property="author" column="author" /> <result property="author" column="author" />
<result property="publishername" column="publishername" /> <result property="publishername" column="publishername" />
<result property="bookdesc" column="bookdesc" />
</resultMap> </resultMap>