소스 검색

默认环境相册

李亚非 3 달 전
부모
커밋
e19b093a98

+ 1 - 1
alien-entity/src/main/java/shop/alien/mapper/StoreOfficialAlbumMapper.java

@@ -23,7 +23,7 @@ public interface StoreOfficialAlbumMapper extends BaseMapper<StoreOfficialAlbum>
      */
     //"图片类型, 0:其他, 1:入口图, 2:相册, 3:菜品, 4:环境, 5:价目表, 6:推荐菜, 7:菜单, 8:用户评论, 9:商家申诉, 10:商家头像, 11:店铺轮播图"
     @Select("SELECT a.*, b.img_url FROM store_official_album a LEFT JOIN store_img b ON b.id = " +
-            "(SELECT b2.id FROM store_img b2 WHERE b2.business_id = a.id and b2.img_type = '2' " +
+            "(SELECT b2.id FROM store_img b2 WHERE b2.business_id = a.id and b2.img_type in ( '2','4') " +
             "order by b2.img_sort LIMIT 1) where a.delete_flag = '0' and  a.store_id = #{storeId}")
     List<StoreOfficialAlbumVo> getStoreOfficialAlbumList(@Param("storeId") Integer storeId);
 

+ 17 - 2
alien-store/src/main/java/shop/alien/store/controller/StoreImgController.java

@@ -7,10 +7,12 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.*;
 import shop.alien.entity.result.R;
 import shop.alien.entity.store.StoreImg;
+import shop.alien.entity.store.StoreOfficialAlbum;
 import shop.alien.entity.store.vo.StoreImgInfoVo;
 import shop.alien.entity.store.vo.StoreImgTypeVo;
 import shop.alien.store.service.StoreImgService;
 import shop.alien.store.service.StoreInfoService;
+import shop.alien.store.service.StoreOfficialAlbumService;
 import shop.alien.store.util.GroupConstant;
 
 import java.util.List;
@@ -31,7 +33,7 @@ import java.util.List;
 public class StoreImgController {
     private final StoreImgService storeImgService;
     private final StoreInfoService storeInfoService;
-
+    private final StoreOfficialAlbumService storeOfficialAlbumService;
     @ApiOperation("获取图片")
     @ApiOperationSupport(order = 1)
     @ApiImplicitParams({@ApiImplicitParam(name = "storeId", value = "门店id", dataType = "Integer", paramType = "query", required = true),
@@ -79,7 +81,20 @@ public class StoreImgController {
         // 判断是否是头图(20:单图模式, 21:多图模式)
         Integer imgType = storeImgInfoVo.getImgType();
         boolean isHeadImage = (imgType == 20 || imgType == 21);
-        
+        if(imgType==4){
+            Integer storeId = storeImgInfoVo.getStoreId();
+            StoreOfficialAlbum album = storeOfficialAlbumService.lambdaQuery()
+                    .eq(StoreOfficialAlbum::getStoreId, storeId).one();
+            if (null == album) {
+                return R.fail("没有默认环境相册");
+            }
+            storeImgList.forEach(storeImg -> storeImg.setBusinessId(album.getId()));
+            // 添加图片时 ,修改数量
+            storeOfficialAlbumService.lambdaUpdate()
+                    .eq(StoreOfficialAlbum::getStoreId, storeId)
+                    .setSql("img_count = img_count + " + storeImgList.size())
+                    .update();
+        }
         // 清空storeid,imgType下图片
         int deleteCount = storeImgService.saveOrUpdateImg(storeImgInfoVo.getStoreId(),storeImgInfoVo.getImgType());
         log.info("StoreImgController.updateStoreImgModeInfo?deleteCount={}", deleteCount);

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

@@ -154,6 +154,8 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
 
     private final StoreImgService storeImgService;
 
+    private final StoreOfficialAlbumMapper storeOfficialAlbumMapper;
+
     /**
      * 运营活动数据访问对象
      */
@@ -1151,6 +1153,12 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
 
         storeInfoMapper.insert(storeInfo);
         result.setId(storeInfo.getId());
+        // 新建默认  环境 相册
+        StoreOfficialAlbum officialAlbum = new StoreOfficialAlbum();
+        officialAlbum.setStoreId(storeInfo.getId());
+        officialAlbum.setAlbumName("环境");
+        officialAlbum.setImgCount(0);
+        storeOfficialAlbumMapper.insert(officialAlbum);
         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);
         }
@@ -3070,7 +3078,7 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
                 return result;
             }
             int imgType = storeImgInfoVo.getImgType();
-            if (imgType == GroupConstant.IMG_TYPE_SINGLE_MODE || imgType == GroupConstant.IMG_TYPE_MULTI_MODE) {
+            if (imgType == GroupConstant.IMG_TYPE_SINGLE_MODE || imgType == GroupConstant.IMG_TYPE_MULTI_MODE||imgType==4) {
                 LambdaUpdateWrapper<StoreInfo> wrapper = new LambdaUpdateWrapper<>();
                 wrapper.eq(StoreInfo::getId, storeImgInfoVo.getStoreId());
                 wrapper.set(StoreInfo::getImgMode, storeImgInfoVo.getImgMode());

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

@@ -23,6 +23,7 @@ import shop.alien.mapper.StoreOfficialAlbumMapper;
 import shop.alien.mapper.StoreVideoMapper;
 import shop.alien.store.service.StoreImgService;
 import shop.alien.store.service.StoreOfficialAlbumService;
+import shop.alien.store.service.StoreVideoService;
 import shop.alien.store.util.CommonConstant;
 import java.util.Collections;
 import java.util.List;
@@ -44,6 +45,7 @@ public class StoreOfficialAlbumServiceImpl extends ServiceImpl<StoreOfficialAlbu
 
     private final StoreImgService storeImgService;
 
+    private final StoreVideoService storeVideoService;
     /**
      * 创建官方相册
      *