Fixing .gitignore
This commit is contained in:
@@ -334,6 +334,7 @@ public class ShopProductController {
|
||||
public R update(@RequestBody ShopProductEntity shopProduct) {
|
||||
|
||||
Integer productId = shopProduct.getProductId();
|
||||
List<Object> list = new ArrayList<>();
|
||||
//多个图书id
|
||||
ArrayList<String> bookId = shopProduct.getBookids();
|
||||
shopProduct.setCreateTime(new Date());
|
||||
@@ -348,32 +349,74 @@ public class ShopProductController {
|
||||
} else {
|
||||
shopProduct.setBookId("");
|
||||
}
|
||||
//查询proudict中,不包含传过来的bookid
|
||||
List<ShopProudictBookEntity> bookEntityList = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>()
|
||||
.eq("proudict_id", productId)
|
||||
.notIn("book_id", bookId)
|
||||
);
|
||||
List<ShopProudictBookEntity> bookyList = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>()
|
||||
.eq("proudict_id", productId));
|
||||
for (ShopProudictBookEntity shopProudictBookEntity : bookyList) {
|
||||
Integer bookId1 = shopProudictBookEntity.getBookId();
|
||||
list.add(bookId1);
|
||||
}
|
||||
|
||||
List<String> filteredBookIds = new ArrayList<>();
|
||||
for ( String s : bookId) {
|
||||
if (!list.contains(s)) {
|
||||
filteredBookIds.add(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
System.out.println("bookEntityList==========" + bookEntityList);
|
||||
}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);
|
||||
}
|
||||
|
||||
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();
|
||||
shopProudictBookEntity.setProudictId(proudict);
|
||||
shopProudictBookEntity.setBookId(Integer.valueOf(bookidlist));
|
||||
shopProudictBookService.save(shopProudictBookEntity);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//查询proudict中,不包含传过来的bookid
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
shopProductService.updateById(shopProduct);
|
||||
return R.ok();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user