|
@@ -1,7 +1,6 @@
|
|
package shop.alien.store.service.impl;
|
|
package shop.alien.store.service.impl;
|
|
|
|
|
|
import com.alibaba.excel.util.CollectionUtils;
|
|
import com.alibaba.excel.util.CollectionUtils;
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
@@ -27,10 +26,15 @@ public class StoreOfficialAlbumServiceImpl extends ServiceImpl<StoreOfficialAlbu
|
|
private final StoreOfficialAlbumMapper storeOfficialAlbumMapper;
|
|
private final StoreOfficialAlbumMapper storeOfficialAlbumMapper;
|
|
private final StoreImgMapper storeImgMapper;
|
|
private final StoreImgMapper storeImgMapper;
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 创建官方相册
|
|
|
|
+ *
|
|
|
|
+ * @param storeOfficialAlbum 官方相册信息
|
|
|
|
+ * @return storeOfficialAlbum 官方相册信息
|
|
|
|
+ */
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public StoreOfficialAlbum createOrUpdateOfficialAlbum(StoreOfficialAlbum storeOfficialAlbum) {
|
|
public StoreOfficialAlbum createOrUpdateOfficialAlbum(StoreOfficialAlbum storeOfficialAlbum) {
|
|
-
|
|
|
|
Integer id= storeOfficialAlbum.getId();
|
|
Integer id= storeOfficialAlbum.getId();
|
|
if (id!=null && id > 0) {
|
|
if (id!=null && id > 0) {
|
|
boolean updateSuccess = storeOfficialAlbumMapper.updateById(storeOfficialAlbum) > 0;
|
|
boolean updateSuccess = storeOfficialAlbumMapper.updateById(storeOfficialAlbum) > 0;
|
|
@@ -46,26 +50,42 @@ public class StoreOfficialAlbumServiceImpl extends ServiceImpl<StoreOfficialAlbu
|
|
return storeOfficialAlbum;
|
|
return storeOfficialAlbum;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 根据storeId查询官方相册列表
|
|
|
|
+ *
|
|
|
|
+ * @param storeId 店铺ID
|
|
|
|
+ * @return List<StoreOfficialAlbumVo> 官方相册列表
|
|
|
|
+ */
|
|
@Override
|
|
@Override
|
|
public List<StoreOfficialAlbumVo> getOfficialAlbumList(String storeId) {
|
|
public List<StoreOfficialAlbumVo> getOfficialAlbumList(String storeId) {
|
|
if(StringUtils.isNotBlank(storeId)) {
|
|
if(StringUtils.isNotBlank(storeId)) {
|
|
//查询出店铺官方相册img数量并更新
|
|
//查询出店铺官方相册img数量并更新
|
|
List<StoreOfficialAlbum> storeOfficialAlbumList = storeOfficialAlbumMapper.getStoreOfficialAlbumImgCount(Integer.parseInt(storeId));
|
|
List<StoreOfficialAlbum> storeOfficialAlbumList = storeOfficialAlbumMapper.getStoreOfficialAlbumImgCount(Integer.parseInt(storeId));
|
|
this.updateBatchById(storeOfficialAlbumList);
|
|
this.updateBatchById(storeOfficialAlbumList);
|
|
|
|
+
|
|
|
|
+ // 查询官方相册列表
|
|
return storeOfficialAlbumMapper.getStoreOfficialAlbumList(Integer.parseInt(storeId));
|
|
return storeOfficialAlbumMapper.getStoreOfficialAlbumList(Integer.parseInt(storeId));
|
|
}
|
|
}
|
|
return Collections.emptyList();
|
|
return Collections.emptyList();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 根据storeId查询官方相册列表
|
|
|
|
+ *
|
|
|
|
+ * @param storeOfficialAlbumList 根据官方相册信息删除官方相册及图片
|
|
|
|
+ * @return result 删除结果
|
|
|
|
+ */
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public int deleteOfficialAlbum(List<StoreOfficialAlbum> storeOfficialAlbumList) {
|
|
public int deleteOfficialAlbum(List<StoreOfficialAlbum> storeOfficialAlbumList) {
|
|
|
|
+
|
|
|
|
+ // 校验官方相册列表
|
|
if (storeOfficialAlbumList == null || storeOfficialAlbumList.isEmpty()) {
|
|
if (storeOfficialAlbumList == null || storeOfficialAlbumList.isEmpty()) {
|
|
- return 0;
|
|
|
|
|
|
+ return CommonConstant.ERROR_CODE_INVALID_PARAMS;
|
|
}
|
|
}
|
|
List<Integer> albumIds =storeOfficialAlbumList.stream().map(StoreOfficialAlbum::getId).collect(Collectors.toList());
|
|
List<Integer> albumIds =storeOfficialAlbumList.stream().map(StoreOfficialAlbum::getId).collect(Collectors.toList());
|
|
if (CollectionUtils.isEmpty(albumIds)) {
|
|
if (CollectionUtils.isEmpty(albumIds)) {
|
|
- return 0;
|
|
|
|
|
|
+ return CommonConstant.ERROR_CODE_INVALID_PARAMS;
|
|
}
|
|
}
|
|
|
|
|
|
// 删除相册
|
|
// 删除相册
|
|
@@ -75,6 +95,6 @@ public class StoreOfficialAlbumServiceImpl extends ServiceImpl<StoreOfficialAlbu
|
|
.in(StoreImg::getBusinessId, albumIds)
|
|
.in(StoreImg::getBusinessId, albumIds)
|
|
.eq(StoreImg::getImgType, CommonConstant.STORE_IMG_ALBUM);
|
|
.eq(StoreImg::getImgType, CommonConstant.STORE_IMG_ALBUM);
|
|
storeImgMapper.delete(wrapper);
|
|
storeImgMapper.delete(wrapper);
|
|
- return 1;
|
|
|
|
|
|
+ return CommonConstant.ERROR_CODE_VALID_PARAMS;
|
|
}
|
|
}
|
|
}
|
|
}
|