|
|
@@ -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;
|
|
|
}
|
|
|
|
|
|
/**
|