Bläddra i källkod

相册逻辑修改,默认的环境和视频相册没有了。

zhangchen 2 dagar sedan
förälder
incheckning
bb102e54be

+ 37 - 18
alien-store/src/main/java/shop/alien/store/controller/StoreImgController.java

@@ -90,6 +90,25 @@ public class StoreImgController {
         }
         Integer imgType = storeImgInfoVo.getImgType();
         Integer storeId = storeImgInfoVo.getStoreId();
+        // imgType=38:仅落库 store_img,不走环境相册、门店图片模式、异步取色、头图审核状态等分支
+        if (Integer.valueOf(38).equals(imgType)) {
+            int deleteCount = storeImgService.saveOrUpdateImg(storeId, imgType);
+            log.info("StoreImgController.saveOrUpdateImg imgType=38 store_img only, deleteCount={}", deleteCount);
+            for (StoreImg storeImg : storeImgList) {
+                if (storeImg != null) {
+                    storeImg.setStoreId(storeId);
+                    storeImg.setImgType(imgType);
+                }
+            }
+            Integer id = storeImgList.get(0).getId();
+            if (storeImgService.saveOrUpdateBatch(storeImgList)) {
+                if (id != null) {
+                    return R.success("修改成功");
+                }
+                return R.success("新增成功");
+            }
+            return R.fail("失败");
+        }
         // 图片由前端直连 AI 审核;服务端不再对门店图调用 moderate,避免保存被误拦截(仅与环境相册查询并行占位)
         CompletableFuture<AiContentModerationUtil.AuditResult> auditFuture = CompletableFuture
                 .completedFuture(new AiContentModerationUtil.AuditResult(true, null));
@@ -104,24 +123,24 @@ public class StoreImgController {
         if (!auditResult.isPassed()) {
             return R.fail(auditResult.getFailureReason());
         }
-        if (imgType != null && imgType == 4) {
-            List<StoreOfficialAlbum> albumList;
-            try {
-                albumList = albumFuture.get(10, TimeUnit.SECONDS);
-            } catch (Exception e) {
-                log.error("查询环境相册异常", e);
-                return R.fail("查询环境相册失败");
-            }
-            if (albumList == null || albumList.isEmpty()) {
-                return R.fail("没有默认环境相册");
-            }
-            StoreOfficialAlbum album = albumList.get(0);
-            storeImgList.forEach(storeImg -> storeImg.setBusinessId(album.getId()));
-            storeOfficialAlbumService.lambdaUpdate()
-                    .eq(StoreOfficialAlbum::getId, album.getId())
-                    .setSql("img_count = img_count + " + storeImgList.size())
-                    .update();
-        }
+//        if (imgType != null && imgType == 4) {
+//            List<StoreOfficialAlbum> albumList;
+//            try {
+//                albumList = albumFuture.get(10, TimeUnit.SECONDS);
+//            } catch (Exception e) {
+//                log.error("查询环境相册异常", e);
+//                return R.fail("查询环境相册失败");
+//            }
+//            if (albumList == null || albumList.isEmpty()) {
+//                return R.fail("没有默认环境相册");
+//            }
+//            StoreOfficialAlbum album = albumList.get(0);
+//            storeImgList.forEach(storeImg -> storeImg.setBusinessId(album.getId()));
+//            storeOfficialAlbumService.lambdaUpdate()
+//                    .eq(StoreOfficialAlbum::getId, album.getId())
+//                    .setSql("img_count = img_count + " + storeImgList.size())
+//                    .update();
+//        }
         boolean isHeadImage = imgType != null && (imgType == 20 || imgType == 21);
         // 清空storeid,imgType下图片
         int deleteCount = storeImgService.saveOrUpdateImg(storeImgInfoVo.getStoreId(),storeImgInfoVo.getImgType());

+ 2 - 2
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -1288,14 +1288,14 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         environmentAlbum.setAlbumName("环境");
         environmentAlbum.setImgCount(0);
         environmentAlbum.setIsFixed(1); // 1-固定相册
-        storeOfficialAlbumMapper.insert(environmentAlbum);
+        //storeOfficialAlbumMapper.insert(environmentAlbum);
         // 创建视频相册
         StoreOfficialAlbum videoAlbum = new StoreOfficialAlbum();
         videoAlbum.setStoreId(storeInfo.getId());
         videoAlbum.setAlbumName("视频");
         videoAlbum.setImgCount(0);
         videoAlbum.setIsFixed(1); // 1-固定相册
-        storeOfficialAlbumMapper.insert(videoAlbum);
+        //storeOfficialAlbumMapper.insert(videoAlbum);
         if (StringUtils.isNotEmpty(storeInfoDto.getStorePositionLongitude()) && StringUtils.isNotEmpty(storeInfoDto.getStorePositionLatitude())) {
             nearMeService.inGeolocation(new Point(Double.parseDouble(storeInfoDto.getStorePositionLongitude()), Double.parseDouble(storeInfoDto.getStorePositionLatitude())), storeInfo.getId().toString(), Boolean.TRUE);
         }

+ 3 - 1
alien-store/src/main/java/shop/alien/store/service/impl/StoreOfficialAlbumServiceImpl.java

@@ -111,7 +111,9 @@ public class StoreOfficialAlbumServiceImpl extends ServiceImpl<StoreOfficialAlbu
         if(StringUtils.isNotBlank(storeId)) {
             //查询出店铺官方相册img数量并更新
             List<StoreOfficialAlbum> storeOfficialAlbumList = storeOfficialAlbumMapper.getStoreOfficialAlbumImgCount(Integer.parseInt(storeId));
-            this.updateBatchById(storeOfficialAlbumList);
+            if(CollectionUtils.isNotEmpty(storeOfficialAlbumList)) {
+                this.updateBatchById(storeOfficialAlbumList);
+            }
 
             // 查询官方相册列表
             List<StoreOfficialAlbumVo> albumVoList = storeOfficialAlbumMapper.getStoreOfficialAlbumList(Integer.parseInt(storeId));