Selaa lähdekoodia

优化官方相册功能

zhangchen 1 viikko sitten
vanhempi
commit
4270ddedb2

+ 0 - 1
alien-store/src/main/java/shop/alien/store/controller/StoreOfficialAlbumController.java

@@ -30,7 +30,6 @@ import java.util.List;
 public class StoreOfficialAlbumController {
     private final StoreOfficialAlbumService storeOfficialAlbumService;
 
-
     @ApiOperation("创建/更新官方相册")
     @ApiOperationSupport(order = 1)
     @PostMapping("/createOrUpdateOfficialAlbum")

+ 25 - 5
alien-store/src/main/java/shop/alien/store/service/impl/StoreOfficialAlbumServiceImpl.java

@@ -1,7 +1,6 @@
 package shop.alien.store.service.impl;
 
 import com.alibaba.excel.util.CollectionUtils;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
@@ -27,10 +26,15 @@ public class StoreOfficialAlbumServiceImpl extends ServiceImpl<StoreOfficialAlbu
     private final StoreOfficialAlbumMapper storeOfficialAlbumMapper;
     private final StoreImgMapper storeImgMapper;
 
+    /**
+     * 创建官方相册
+     *
+     * @param storeOfficialAlbum 官方相册信息
+     * @return storeOfficialAlbum 官方相册信息
+     */
     @Override
     @Transactional(rollbackFor = Exception.class)
     public StoreOfficialAlbum createOrUpdateOfficialAlbum(StoreOfficialAlbum storeOfficialAlbum) {
-
         Integer id= storeOfficialAlbum.getId();
         if (id!=null && id > 0) {
             boolean updateSuccess = storeOfficialAlbumMapper.updateById(storeOfficialAlbum) > 0;
@@ -46,26 +50,42 @@ public class StoreOfficialAlbumServiceImpl extends ServiceImpl<StoreOfficialAlbu
         return storeOfficialAlbum;
     }
 
+    /**
+     * 根据storeId查询官方相册列表
+     *
+     * @param storeId 店铺ID
+     * @return List<StoreOfficialAlbumVo> 官方相册列表
+     */
     @Override
     public List<StoreOfficialAlbumVo> getOfficialAlbumList(String storeId) {
         if(StringUtils.isNotBlank(storeId)) {
             //查询出店铺官方相册img数量并更新
             List<StoreOfficialAlbum> storeOfficialAlbumList = storeOfficialAlbumMapper.getStoreOfficialAlbumImgCount(Integer.parseInt(storeId));
             this.updateBatchById(storeOfficialAlbumList);
+
+            // 查询官方相册列表
             return storeOfficialAlbumMapper.getStoreOfficialAlbumList(Integer.parseInt(storeId));
         }
         return Collections.emptyList();
     }
 
+    /**
+     * 根据storeId查询官方相册列表
+     *
+     * @param storeOfficialAlbumList 根据官方相册信息删除官方相册及图片
+     * @return result 删除结果
+     */
     @Override
     @Transactional(rollbackFor = Exception.class)
     public int deleteOfficialAlbum(List<StoreOfficialAlbum> storeOfficialAlbumList) {
+
+        // 校验官方相册列表
         if (storeOfficialAlbumList == null || storeOfficialAlbumList.isEmpty()) {
-            return 0;
+            return CommonConstant.ERROR_CODE_INVALID_PARAMS;
         }
         List<Integer> albumIds =storeOfficialAlbumList.stream().map(StoreOfficialAlbum::getId).collect(Collectors.toList());
         if (CollectionUtils.isEmpty(albumIds)) {
-            return 0;
+            return CommonConstant.ERROR_CODE_INVALID_PARAMS;
         }
 
         // 删除相册
@@ -75,6 +95,6 @@ public class StoreOfficialAlbumServiceImpl extends ServiceImpl<StoreOfficialAlbu
                 .in(StoreImg::getBusinessId, albumIds)
                 .eq(StoreImg::getImgType, CommonConstant.STORE_IMG_ALBUM);
         storeImgMapper.delete(wrapper);
-        return 1;
+        return CommonConstant.ERROR_CODE_VALID_PARAMS;
     }
 }