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

This commit is contained in:
OPGame
2019-08-12 10:35:29 +08:00
parent c8896cb30c
commit c35a67e8eb
3 changed files with 43 additions and 43 deletions

View File

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

View File

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

View File

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