商品图库附图新增

This commit is contained in:
liyj 2025-11-28 11:07:11 +08:00
parent 2ed1fba191
commit c3e72256ef
2 changed files with 20 additions and 7 deletions

View File

@ -195,6 +195,7 @@ public class LibraryProductImpl extends BaseServiceImpl<LibraryProductMapper, Li
}
List<String> updateTableIds=new ArrayList<>();
List<LibraryProductImage> updateProductImageList=new ArrayList<>();
List<LibraryProductImage> addProductImageList=new ArrayList<>();
products.forEach(product->{
if (null==product.getId()){
throw new ApiException("id is null");
@ -207,10 +208,19 @@ public class LibraryProductImpl extends BaseServiceImpl<LibraryProductMapper, Li
if(null!=product.getProduct_image_list()&&!product.getProduct_image_list().isEmpty()){
for(LibraryProductDTO.ProductImage productImage: product.getProduct_image_list()){
LibraryProductImage libraryProductImage=new LibraryProductImage();
libraryProductImage.setId(productImage.getId());
libraryProductImage.setImageUrl(productImage.getImageUrl());
libraryProductImage.setProductId(productImage.getProductId());
updateProductImageList.add(libraryProductImage);
if(null!=productImage.getId()){
libraryProductImage.setId(productImage.getId());
libraryProductImage.setImageUrl(productImage.getImageUrl());
libraryProductImage.setProductId(productImage.getProductId());
updateProductImageList.add(libraryProductImage);
}else {
libraryProductImage.setImageUrl(productImage.getImageUrl());
libraryProductImage.setProductId(productImage.getProductId());
libraryProductImage.setStatus(1);
libraryProductImage.setIsMain(false);
addProductImageList.add(libraryProductImage);
}
}
}
updateProductList.add(libraryProduct);
@ -221,6 +231,9 @@ public class LibraryProductImpl extends BaseServiceImpl<LibraryProductMapper, Li
if(!updateProductImageList.isEmpty()){
libraryProductImageService.updateBatchById(updateProductImageList,updateProductImageList.size());
}
if(!addProductImageList.isEmpty()){
libraryProductImageService.saveBatch(addProductImageList,addProductImageList.size());
}
if(result){
redisService.del(updateTableIds);

View File

@ -19,9 +19,9 @@
<!-- 商品库商品图片集合映射-->
<collection property="product_image_list"
ofType="com.suisung.mall.common.pojo.dto.LibraryProductDTO$ProductImage">
<result property="product_id" column="product_id"/>
<result property="image_url" column="image_url"/>
<result property="is_main" column="is_main"/>
<result property="product_id" column="productId"/>
<result property="image_url" column="imageUrl"/>
<result property="is_main" column="isMain"/>
<result property="seq" column="seq"/>
</collection>
</resultMap>