商品图库附图新增

This commit is contained in:
liyj 2025-11-28 11:07:11 +08:00
parent e1bd542c12
commit 30b24dda04
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<String> updateTableIds=new ArrayList<>();
List<LibraryProductImage> updateProductImageList=new ArrayList<>(); List<LibraryProductImage> updateProductImageList=new ArrayList<>();
List<LibraryProductImage> addProductImageList=new ArrayList<>();
products.forEach(product->{ products.forEach(product->{
if (null==product.getId()){ if (null==product.getId()){
throw new ApiException("id is null"); 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()){ if(null!=product.getProduct_image_list()&&!product.getProduct_image_list().isEmpty()){
for(LibraryProductDTO.ProductImage productImage: product.getProduct_image_list()){ for(LibraryProductDTO.ProductImage productImage: product.getProduct_image_list()){
LibraryProductImage libraryProductImage=new LibraryProductImage(); LibraryProductImage libraryProductImage=new LibraryProductImage();
libraryProductImage.setId(productImage.getId()); if(null!=productImage.getId()){
libraryProductImage.setImageUrl(productImage.getImageUrl()); libraryProductImage.setId(productImage.getId());
libraryProductImage.setProductId(productImage.getProductId()); libraryProductImage.setImageUrl(productImage.getImageUrl());
updateProductImageList.add(libraryProductImage); 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); updateProductList.add(libraryProduct);
@ -221,6 +231,9 @@ public class LibraryProductImpl extends BaseServiceImpl<LibraryProductMapper, Li
if(!updateProductImageList.isEmpty()){ if(!updateProductImageList.isEmpty()){
libraryProductImageService.updateBatchById(updateProductImageList,updateProductImageList.size()); libraryProductImageService.updateBatchById(updateProductImageList,updateProductImageList.size());
} }
if(!addProductImageList.isEmpty()){
libraryProductImageService.saveBatch(addProductImageList,addProductImageList.size());
}
if(result){ if(result){
redisService.del(updateTableIds); redisService.del(updateTableIds);

View File

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