--9.20提交修改
This commit is contained in:
@@ -277,6 +277,8 @@ public class BookChapterController {
|
||||
public R delete(@RequestBody Integer[] ids) {
|
||||
for(Integer id : ids){
|
||||
|
||||
|
||||
|
||||
BookChapterEntity chapter = bookChapterService.getBaseMapper().selectOne(new QueryWrapper<BookChapterEntity>()
|
||||
.eq("id", id)
|
||||
);
|
||||
|
||||
@@ -34,6 +34,8 @@ public class BookForumArticlesServiceController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 列表 (修改时间倒叙) app页面
|
||||
*/
|
||||
|
||||
@@ -215,6 +215,7 @@ public class ShopProductController {
|
||||
*/
|
||||
@RequestMapping("/getGlProductList")
|
||||
public R getGlProductList(@RequestParam int productId) {
|
||||
|
||||
//获取此商品下的books
|
||||
List<Integer> ids = shopProudictBookService.getBookidsByProductId(productId);
|
||||
|
||||
@@ -226,7 +227,10 @@ public class ShopProductController {
|
||||
);
|
||||
|
||||
List<ShopProductEntity> 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<Object> list = new ArrayList<>();
|
||||
|
||||
//多个图书id
|
||||
ArrayList<String> bookId = shopProduct.getBookids();
|
||||
shopProduct.setCreateTime(new Date());
|
||||
@@ -351,70 +356,35 @@ public class ShopProductController {
|
||||
} else {
|
||||
shopProduct.setBookId("");
|
||||
}
|
||||
//传过来的proudictid只有一个,但是bookid可能有多个,对应的一个proudictid一个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<Object> 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<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<>();
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}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;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -78,4 +78,10 @@ public class BookForumArticlesEntity {
|
||||
private String publishername;
|
||||
|
||||
|
||||
@TableField("bookdesc")
|
||||
private String bookdesc;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<result property="delflag" column="del_flag" />
|
||||
<result property="author" column="author" />
|
||||
<result property="publishername" column="publishername" />
|
||||
<result property="bookdesc" column="bookdesc" />
|
||||
|
||||
</resultMap>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user