注释掉删除图片的代码,以后可以进行统一的图片管理

master
OPGame 7 years ago
parent c8896cb30c
commit c35a67e8eb

@ -84,9 +84,9 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
deleteBrandsAndAttributes(category.getCategoryId()); deleteBrandsAndAttributes(category.getCategoryId());
insertBrandsAndAttributes(category); insertBrandsAndAttributes(category);
// 如果以前有图片,并且图片与现在不同,则删除以前的图片 // 如果以前有图片,并且图片与现在不同,则删除以前的图片
if (StrUtil.isNotBlank(dbCategory.getPic()) && !dbCategory.getPic().equals(category.getPic())) { // if (StrUtil.isNotBlank(dbCategory.getPic()) && !dbCategory.getPic().equals(category.getPic())) {
attachFileService.deleteFile(dbCategory.getPic()); // attachFileService.deleteFile(dbCategory.getPic());
} // }
} }
@Override @Override
@ -96,9 +96,9 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
categoryMapper.deleteById(categoryId); categoryMapper.deleteById(categoryId);
deleteBrandsAndAttributes(categoryId); deleteBrandsAndAttributes(categoryId);
if (StrUtil.isNotBlank(category.getPic())) { // if (StrUtil.isNotBlank(category.getPic())) {
attachFileService.deleteFile(category.getPic()); // attachFileService.deleteFile(category.getPic());
} // }
} }

@ -79,10 +79,10 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
productMapper.updateById(product); productMapper.updateById(product);
List<Long> dbSkuIds = dbProduct.getSkuList().stream().map(Sku::getSkuId).collect(Collectors.toList()); List<Long> dbSkuIds = dbProduct.getSkuList().stream().map(Sku::getSkuId).collect(Collectors.toList());
// 2019/04/c0244be79909484fb67bc6d5f70cae18.jpg // 2019/04/c0244be79909484fb67bc6d5f70cae18.jpg
if (!Objects.equals(dbProduct.getPic(), product.getPic()) && StrUtil.isNotBlank(dbProduct.getPic())) { // if (!Objects.equals(dbProduct.getPic(), product.getPic()) && StrUtil.isNotBlank(dbProduct.getPic())) {
// 删除数据库中的商品图片 // // 删除数据库中的商品图片
attachFileService.deleteFile(dbProduct.getPic()); // attachFileService.deleteFile(dbProduct.getPic());
} // }
// 将所有该商品的sku标记为已删除状态 // 将所有该商品的sku标记为已删除状态
skuMapper.deleteByProdId(product.getProdId()); skuMapper.deleteByProdId(product.getProdId());
@ -141,12 +141,12 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
.eq(ProdTagReference::getProdId, prodId)); .eq(ProdTagReference::getProdId, prodId));
// 删除数据库中的商品图片 // 删除数据库中的商品图片
if (StrUtil.isNotBlank(dbProduct.getImgs())) { // if (StrUtil.isNotBlank(dbProduct.getImgs())) {
String[] imgs = dbProduct.getImgs().split(StrUtil.COMMA); // String[] imgs = dbProduct.getImgs().split(StrUtil.COMMA);
for (String img : imgs) { // for (String img : imgs) {
attachFileService.deleteFile(img); // attachFileService.deleteFile(img);
} // }
} // }
} }
@Override @Override

@ -46,23 +46,23 @@ public class ShopDetailServiceImpl extends ServiceImpl<ShopDetailMapper, ShopDet
public void updateShopDetail(ShopDetail shopDetail,ShopDetail dbShopDetail) { public void updateShopDetail(ShopDetail shopDetail,ShopDetail dbShopDetail) {
// 更新除数据库中的信息,再删除图片 // 更新除数据库中的信息,再删除图片
shopDetailMapper.updateById(shopDetail); shopDetailMapper.updateById(shopDetail);
if (!Objects.equals(dbShopDetail.getShopLogo(), shopDetail.getShopLogo())) { // if (!Objects.equals(dbShopDetail.getShopLogo(), shopDetail.getShopLogo())) {
// 删除logo // // 删除logo
attachFileService.deleteFile(shopDetail.getShopLogo()); // attachFileService.deleteFile(shopDetail.getShopLogo());
} // }
// 店铺图片 // // 店铺图片
String shopPhotos = shopDetail.getShopPhotos(); // String shopPhotos = shopDetail.getShopPhotos();
String[] shopPhotoArray =StrUtil.isBlank(shopPhotos)?new String[]{}: shopPhotos.split(","); // String[] shopPhotoArray =StrUtil.isBlank(shopPhotos)?new String[]{}: shopPhotos.split(",");
//
// 数据库中的店铺图片 // // 数据库中的店铺图片
String dbShopPhotos = dbShopDetail.getShopPhotos(); // String dbShopPhotos = dbShopDetail.getShopPhotos();
String[] dbShopPhotoArray =StrUtil.isBlank(dbShopPhotos)?new String[]{}: dbShopPhotos.split(","); // String[] dbShopPhotoArray =StrUtil.isBlank(dbShopPhotos)?new String[]{}: dbShopPhotos.split(",");
for (String dbShopPhoto : dbShopPhotoArray) { // for (String dbShopPhoto : dbShopPhotoArray) {
// 如果新插入的图片中没有旧数据中的图片,则删除旧数据中的图片 // // 如果新插入的图片中没有旧数据中的图片,则删除旧数据中的图片
if (!ArrayUtil.contains(shopPhotoArray, dbShopPhoto)) { // if (!ArrayUtil.contains(shopPhotoArray, dbShopPhoto)) {
attachFileService.deleteFile(dbShopPhoto); // attachFileService.deleteFile(dbShopPhoto);
} // }
} // }
} }
@Override @Override
@ -72,17 +72,17 @@ public class ShopDetailServiceImpl extends ServiceImpl<ShopDetailMapper, ShopDet
// 先删除数据库中的信息,再删除图片 // 先删除数据库中的信息,再删除图片
shopDetailMapper.deleteById(shopId); shopDetailMapper.deleteById(shopId);
ShopDetail shopDetail = shopDetailMapper.selectById(shopId); // ShopDetail shopDetail = shopDetailMapper.selectById(shopId);
// 删除logo // 删除logo
attachFileService.deleteFile(shopDetail.getShopLogo()); // attachFileService.deleteFile(shopDetail.getShopLogo());
// 删除店铺图片 // // 删除店铺图片
String shopPhotos = shopDetail.getShopPhotos(); // String shopPhotos = shopDetail.getShopPhotos();
if (StrUtil.isNotBlank(shopPhotos)) { // if (StrUtil.isNotBlank(shopPhotos)) {
String[] shopPhotoArray = shopPhotos.split(","); // String[] shopPhotoArray = shopPhotos.split(",");
for (String shopPhoto : shopPhotoArray) { // for (String shopPhoto : shopPhotoArray) {
attachFileService.deleteFile(shopPhoto); // attachFileService.deleteFile(shopPhoto);
} // }
} // }
} }
@Override @Override

Loading…
Cancel
Save