ldz 3 ماه پیش
والد
کامیت
7977c616b7

+ 7 - 6
alien-store/src/main/java/shop/alien/store/controller/StoreOfficialAlbumController.java

@@ -67,15 +67,17 @@ public class StoreOfficialAlbumController {
      *
      * @param storeId   门店ID,必填,必须大于0
      * @param albumName 相册名称,可选。例如:酒水、餐食、环境、全部等。当为null或空字符串时,查询全部
+     * @param type      类型,必填。1:视频,2:相册,3:环境
+     * @param pageNum   页码,可选,默认1
+     * @param pageSize  每页数量,可选,默认10
      * @return 统一返回结果,包含图片列表和总数
-     * @throws IllegalArgumentException 当门店ID为空或小于等于0时抛出
      */
     @ApiOperation("获取官方相册图片列表(客户端)")
     @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 = "type", value = "1:视频 ,2相册,3环境", dataType = "Integer", paramType = "query",required = true),
+            @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")
     })
@@ -85,10 +87,9 @@ public class StoreOfficialAlbumController {
             @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={} ,type={},pageNum={},pageSize={}", storeId, albumName, type, pageNum, pageSize);
+            @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize) {
+        log.info("获取官方相册图片列表,入参:storeId={}, albumName={}, type={}, pageNum={}, pageSize={}", 
+                storeId, albumName, type, pageNum, pageSize);
 
         // 参数校验
         if (storeId == null || storeId <= 0) {

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

@@ -23,11 +23,14 @@ public interface StoreOfficialAlbumService extends IService<StoreOfficialAlbum>
      * 查询条件:imgType = 2(官方相册),通过 business_id 关联到 store_official_album 表,按 albumName 筛选
      * </p>
      *
-     * @param storeId   门店ID,必填
+     * @param storeId   门店ID,必填,必须大于0
      * @param albumName 相册名称,可选。例如:酒水、餐食、环境、全部等。当为null或空字符串时,查询全部
+     * @param type      类型,必填。1:视频,2:相册,3:环境
+     * @param pageNum   页码,可选,默认1
+     * @param pageSize  每页数量,可选,默认10
      * @return 图片列表和总数
      */
-    StoreOfficialAlbumImgVo getOfficialAlbumImgList(Integer storeId, String albumName , Integer type,Integer pageNum, Integer pageSize);
+    StoreOfficialAlbumImgVo getOfficialAlbumImgList(Integer storeId, String albumName, Integer type, Integer pageNum, Integer pageSize);
 
     /**
      * 获取官方相册名称列表(客户端)

+ 31 - 21
alien-store/src/main/java/shop/alien/store/service/impl/StoreOfficialAlbumServiceImpl.java

@@ -124,13 +124,16 @@ public class StoreOfficialAlbumServiceImpl extends ServiceImpl<StoreOfficialAlbu
      * 查询条件:imgType = 2(官方相册),通过 business_id 关联到 store_official_album 表,按 albumName 筛选
      * </p>
      *
-     * @param storeId   门店ID,必填
+     * @param storeId   门店ID,必填,必须大于0
      * @param albumName 相册名称,可选。例如:酒水、餐食、环境、全部等。当为null或空字符串时,查询全部
+     * @param type      类型,必填。1:视频,2:相册,3:环境
+     * @param pageNum   页码,可选,默认1
+     * @param pageSize  每页数量,可选,默认10
      * @return 图片列表和总数
      */
     @Override
-    public StoreOfficialAlbumImgVo getOfficialAlbumImgList(Integer storeId, String albumName,Integer type, Integer pageNum, Integer pageSize) {
-        log.info("开始获取官方相册图片列表,门店ID:{},相册名称:{}", storeId, albumName);
+    public StoreOfficialAlbumImgVo getOfficialAlbumImgList(Integer storeId, String albumName, Integer type, Integer pageNum, Integer pageSize) {
+        log.info("开始获取官方相册图片列表,门店ID:{},相册名称:{},类型:{}", storeId, albumName, type);
 
         // 参数校验
         if (storeId == null || storeId <= 0) {
@@ -143,16 +146,17 @@ public class StoreOfficialAlbumServiceImpl extends ServiceImpl<StoreOfficialAlbu
             throw new IllegalArgumentException("类型不能为空且必须大于0");
         }
 
-        if (type == 1){
-            //查询视频
+        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);
+            List<StoreVideo> videoList = storeVideoMapper.selectList(albumQueryWrapper);
             StoreOfficialAlbumImgVo result = new StoreOfficialAlbumImgVo();
             result.setVideoList(videoList);
+            return result;
         }
-        if (type == 2){
+        if (type == 2) {
             // 先查询符合条件的官方相册ID列表
             LambdaQueryWrapper<StoreOfficialAlbum> albumQueryWrapper = new LambdaQueryWrapper<>();
             albumQueryWrapper.eq(StoreOfficialAlbum::getStoreId, storeId)
@@ -200,30 +204,36 @@ public class StoreOfficialAlbumServiceImpl extends ServiceImpl<StoreOfficialAlbu
 
             return result;
         }
-        if (type == 3){
-
-            StoreInfo storeInfo=storeInfoMapper.getStoreInfo(storeId);
+        if (type == 3) {
+            StoreInfo storeInfo = storeInfoMapper.getStoreInfo(storeId);
 
-            assert storeInfo != null;
-            //单图模式
-            if (storeInfo.getImgMode()==0){
-                List<StoreImg> imgList= storeImgService.getByCover(storeId, 20);
+            if (storeInfo == null) {
+                log.warn("获取门店信息失败,门店ID:{}", storeId);
+                StoreOfficialAlbumImgVo result = new StoreOfficialAlbumImgVo();
+                result.setImgList(Collections.emptyList());
+                result.setTotalCount(0);
+                return result;
+            }
+            // 单图模式
+            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);
+            // 多图模式
+            if (storeInfo.getImgMode() == 1) {
+                List<StoreImg> imgList = storeImgService.getByCover(storeId, 21);
                 StoreOfficialAlbumImgVo result = new StoreOfficialAlbumImgVo();
                 result.setImgList(imgList);
                 return result;
             }
-
         }
-        return null;
-
-
+        // 默认返回空结果
+        StoreOfficialAlbumImgVo result = new StoreOfficialAlbumImgVo();
+        result.setImgList(Collections.emptyList());
+        result.setTotalCount(0);
+        return result;
     }
 
     /**