فهرست منبع

相册、封面、视频相关接口

ldz 3 ماه پیش
والد
کامیت
58a3d1ebc9

+ 4 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/StoreOfficialAlbumImgVo.java

@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import shop.alien.entity.store.StoreImg;
+import shop.alien.entity.store.StoreVideo;
 
 import java.util.List;
 
@@ -25,5 +26,8 @@ public class StoreOfficialAlbumImgVo {
     @ApiModelProperty(value = "图片总数")
     private Integer totalCount;
 
+    @ApiModelProperty(value = "视频列表")
+    private List<StoreVideo> videoList;
+
 }
 

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

@@ -269,7 +269,7 @@ public class StoreImgController {
     }
 
     /**
-     * 获取封面图片
+     * 获取封面图片/环境
      *storeId 商家id
      * @param imgType 图片类型
      *                0:其他, 1:入口图, 2:相册, 3:菜品, 4:环境, 5:价目表, 6:推荐菜, 7:菜单, 8:用户评论, 9:商家申诉, 10:商家头像, 11:店铺轮播图,20单图,21多图

+ 11 - 4
alien-store/src/main/java/shop/alien/store/controller/StoreOfficialAlbumController.java

@@ -74,14 +74,21 @@ public class StoreOfficialAlbumController {
     @ApiOperationSupport(order = 4)
     @ApiImplicitParams({
             @ApiImplicitParam(name = "storeId", value = "门店ID", dataType = "Integer", paramType = "query", required = true),
-            @ApiImplicitParam(name = "albumName", value = "相册名称,例如:酒水、餐食、环境、全部等。不传或传空字符串时查询全部", dataType = "String", paramType = "query")
+            @ApiImplicitParam(name = "albumName", value = "相册名称,例如:酒水、餐食、环境、全部等。不传或传空字符串时查询全部", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "type", value = "1:视频 ,2相册,3环境", dataType = "Integer", paramType = "query",required = true),
+            @ApiImplicitParam(name = "pageNum", value = "页码,默认1", dataType = "Integer", paramType = "query"),
+            @ApiImplicitParam(name = "pageSize", value = "每页数量,默认10", dataType = "Integer", paramType = "query")
     })
     @GetMapping("/getOfficialAlbumImgList")
     public R<StoreOfficialAlbumImgVo> getOfficialAlbumImgList(
             @RequestParam(value = "storeId", required = true) Integer storeId,
-            @RequestParam(value = "albumName", required = false) String albumName) {
+            @RequestParam(value = "albumName", required = false) String albumName,
+            @RequestParam(value = "type", required = true) Integer type,
+            @RequestParam(value = "pageNum", required = false, defaultValue = "1") int pageNum,
+            @RequestParam(value = "pageSize", required = false, defaultValue = "10")int pageSize
+    ){
         // 记录请求入参
-        log.info("获取官方相册图片列表,入参:storeId={}, albumName={}", storeId, albumName);
+        log.info("获取官方相册图片列表,入参:storeId={}, albumName={} ,type={},pageNum={},pageSize={}", storeId, albumName, type, pageNum, pageSize);
 
         // 参数校验
         if (storeId == null || storeId <= 0) {
@@ -91,7 +98,7 @@ public class StoreOfficialAlbumController {
 
         try {
             // 调用服务层获取图片列表
-            StoreOfficialAlbumImgVo result = storeOfficialAlbumService.getOfficialAlbumImgList(storeId, albumName);
+            StoreOfficialAlbumImgVo result = storeOfficialAlbumService.getOfficialAlbumImgList(storeId, albumName, type, pageNum, pageSize);
 
             // 记录返回结果
             log.info("获取官方相册图片列表成功,门店ID:{},相册名称:{},返回图片数量:{}",

+ 1 - 1
alien-store/src/main/java/shop/alien/store/service/StoreOfficialAlbumService.java

@@ -27,7 +27,7 @@ public interface StoreOfficialAlbumService extends IService<StoreOfficialAlbum>
      * @param albumName 相册名称,可选。例如:酒水、餐食、环境、全部等。当为null或空字符串时,查询全部
      * @return 图片列表和总数
      */
-    StoreOfficialAlbumImgVo getOfficialAlbumImgList(Integer storeId, String albumName);
+    StoreOfficialAlbumImgVo getOfficialAlbumImgList(Integer storeId, String albumName , Integer type,Integer pageNum, Integer pageSize);
 
     /**
      * 获取官方相册名称列表(客户端)

+ 86 - 36
alien-store/src/main/java/shop/alien/store/service/impl/StoreOfficialAlbumServiceImpl.java

@@ -10,13 +10,18 @@ import org.apache.commons.lang.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import shop.alien.entity.store.StoreImg;
+import shop.alien.entity.store.StoreInfo;
 import shop.alien.entity.store.StoreOfficialAlbum;
+import shop.alien.entity.store.StoreVideo;
 import shop.alien.entity.store.vo.StoreAlbumDetailVo;
 import shop.alien.entity.store.vo.StoreAlbumNameVo;
 import shop.alien.entity.store.vo.StoreOfficialAlbumImgVo;
 import shop.alien.entity.store.vo.StoreOfficialAlbumVo;
 import shop.alien.mapper.StoreImgMapper;
+import shop.alien.mapper.StoreInfoMapper;
 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.util.CommonConstant;
 import java.util.Collections;
@@ -33,6 +38,12 @@ public class StoreOfficialAlbumServiceImpl extends ServiceImpl<StoreOfficialAlbu
     private final StoreOfficialAlbumMapper storeOfficialAlbumMapper;
     private final StoreImgMapper storeImgMapper;
 
+    private final StoreVideoMapper storeVideoMapper;
+
+    private final StoreInfoMapper storeInfoMapper;
+
+    private final StoreImgService storeImgService;
+
     /**
      * 创建官方相册
      *
@@ -118,7 +129,7 @@ public class StoreOfficialAlbumServiceImpl extends ServiceImpl<StoreOfficialAlbu
      * @return 图片列表和总数
      */
     @Override
-    public StoreOfficialAlbumImgVo getOfficialAlbumImgList(Integer storeId, String albumName) {
+    public StoreOfficialAlbumImgVo getOfficialAlbumImgList(Integer storeId, String albumName,Integer type, Integer pageNum, Integer pageSize) {
         log.info("开始获取官方相册图片列表,门店ID:{},相册名称:{}", storeId, albumName);
 
         // 参数校验
@@ -127,53 +138,92 @@ public class StoreOfficialAlbumServiceImpl extends ServiceImpl<StoreOfficialAlbu
             throw new IllegalArgumentException("门店ID不能为空且必须大于0");
         }
 
-        // 先查询符合条件的官方相册ID列表
-        LambdaQueryWrapper<StoreOfficialAlbum> albumQueryWrapper = new LambdaQueryWrapper<>();
-        albumQueryWrapper.eq(StoreOfficialAlbum::getStoreId, storeId)
-                .eq(StoreOfficialAlbum::getDeleteFlag, CommonConstant.DELETE_FLAG_UNDELETE);
+        if (type == null || type <= 0) {
+            log.warn("获取类型无效:{}", type);
+            throw new IllegalArgumentException("类型不能为空且必须大于0");
+        }
 
-        // 如果指定了相册名称,添加筛选条件
-        if (StringUtils.isNotBlank(albumName)) {
-            albumQueryWrapper.eq(StoreOfficialAlbum::getAlbumName, albumName);
+        if (type == 1){
+            //查询视频
+            LambdaQueryWrapper<StoreVideo> albumQueryWrapper = new LambdaQueryWrapper<>();
+            albumQueryWrapper.eq(StoreVideo::getStoreId, storeId)
+                    .eq(StoreVideo::getDeleteFlag, CommonConstant.DELETE_FLAG_UNDELETE);
+            List<StoreVideo> videoList=storeVideoMapper.selectList(albumQueryWrapper);
+            StoreOfficialAlbumImgVo result = new StoreOfficialAlbumImgVo();
+            result.setVideoList(videoList);
         }
+        if (type == 2){
+            // 先查询符合条件的官方相册ID列表
+            LambdaQueryWrapper<StoreOfficialAlbum> albumQueryWrapper = new LambdaQueryWrapper<>();
+            albumQueryWrapper.eq(StoreOfficialAlbum::getStoreId, storeId)
+                    .eq(StoreOfficialAlbum::getDeleteFlag, CommonConstant.DELETE_FLAG_UNDELETE);
+
+            // 如果指定了相册名称,添加筛选条件
+            if (StringUtils.isNotBlank(albumName)) {
+                albumQueryWrapper.eq(StoreOfficialAlbum::getAlbumName, albumName);
+            }
 
-        List<StoreOfficialAlbum> albumList = storeOfficialAlbumMapper.selectList(albumQueryWrapper);
+            List<StoreOfficialAlbum> albumList = storeOfficialAlbumMapper.selectList(albumQueryWrapper);
 
-        // 如果相册列表为空,直接返回空结果
-        if (CollectionUtils.isEmpty(albumList)) {
-            log.info("获取官方相册图片列表,门店ID:{},未查询到符合条件的相册", storeId);
+            // 如果相册列表为空,直接返回空结果
+            if (CollectionUtils.isEmpty(albumList)) {
+                log.info("获取官方相册图片列表,门店ID:{},未查询到符合条件的相册", storeId);
+                StoreOfficialAlbumImgVo result = new StoreOfficialAlbumImgVo();
+                result.setImgList(Collections.emptyList());
+                result.setTotalCount(0);
+                return result;
+            }
+
+            // 提取相册ID列表
+            List<Integer> albumIds = albumList.stream()
+                    .map(StoreOfficialAlbum::getId)
+                    .collect(Collectors.toList());
+
+            log.debug("查询到符合条件的相册数量:{},相册ID列表:{}", albumList.size(), albumIds);
+
+            // 查询这些相册下的所有图片(imgType = 2 表示官方相册)
+            LambdaQueryWrapper<StoreImg> imgQueryWrapper = new LambdaQueryWrapper<>();
+            imgQueryWrapper.eq(StoreImg::getStoreId, storeId)
+                    .eq(StoreImg::getImgType, CommonConstant.STORE_IMG_ALBUM) // imgType = 2 表示官方相册
+                    .in(StoreImg::getBusinessId, albumIds) // business_id 关联到相册ID
+                    .eq(StoreImg::getDeleteFlag, CommonConstant.DELETE_FLAG_UNDELETE)
+                    .orderByAsc(StoreImg::getImgSort);
+
+            List<StoreImg> imgList = storeImgMapper.selectList(imgQueryWrapper);
+            // 构建返回结果
             StoreOfficialAlbumImgVo result = new StoreOfficialAlbumImgVo();
-            result.setImgList(Collections.emptyList());
-            result.setTotalCount(0);
-            return result;
-        }
+            result.setImgList(imgList);
+            result.setTotalCount(imgList.size());
 
-        // 提取相册ID列表
-        List<Integer> albumIds = albumList.stream()
-                .map(StoreOfficialAlbum::getId)
-                .collect(Collectors.toList());
+            log.info("获取官方相册图片列表完成,门店ID:{},相册名称:{},返回图片数量:{}",
+                    storeId, albumName, result.getTotalCount());
 
-        log.debug("查询到符合条件的相册数量:{},相册ID列表:{}", albumList.size(), albumIds);
+            return result;
+        }
+        if (type == 3){
 
-        // 查询这些相册下的所有图片(imgType = 2 表示官方相册)
-        LambdaQueryWrapper<StoreImg> imgQueryWrapper = new LambdaQueryWrapper<>();
-        imgQueryWrapper.eq(StoreImg::getStoreId, storeId)
-                .eq(StoreImg::getImgType, CommonConstant.STORE_IMG_ALBUM) // imgType = 2 表示官方相册
-                .in(StoreImg::getBusinessId, albumIds) // business_id 关联到相册ID
-                .eq(StoreImg::getDeleteFlag, CommonConstant.DELETE_FLAG_UNDELETE)
-                .orderByAsc(StoreImg::getImgSort);
+            StoreInfo storeInfo=storeInfoMapper.getStoreInfo(storeId);
 
-        List<StoreImg> imgList = storeImgMapper.selectList(imgQueryWrapper);
+            assert storeInfo != null;
+            //单图模式
+            if (storeInfo.getImgMode()==0){
+                List<StoreImg> imgList= storeImgService.getByCover(storeId, 20);
+                StoreOfficialAlbumImgVo result = new StoreOfficialAlbumImgVo();
+                result.setImgList(imgList);
+                return result;
+            }
+            //多图模式
+            if (storeInfo.getImgMode()==1){
+                List<StoreImg> imgList= storeImgService.getByCover(storeId, 21);
+                StoreOfficialAlbumImgVo result = new StoreOfficialAlbumImgVo();
+                result.setImgList(imgList);
+                return result;
+            }
 
-        // 构建返回结果
-        StoreOfficialAlbumImgVo result = new StoreOfficialAlbumImgVo();
-        result.setImgList(imgList);
-        result.setTotalCount(imgList.size());
+        }
+        return null;
 
-        log.info("获取官方相册图片列表完成,门店ID:{},相册名称:{},返回图片数量:{}",
-                storeId, albumName, result.getTotalCount());
 
-        return result;
     }
 
     /**