|
@@ -17,11 +17,14 @@ import com.yonge.cooleshow.biz.dal.wrapper.TenantAlbumCategoryWrapper;
|
|
|
import com.yonge.cooleshow.common.enums.ETenantAlbumCategoryType;
|
|
|
import com.yonge.toolset.base.exception.BizException;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -70,10 +73,29 @@ public class TenantAlbumCategoryServiceImpl extends ServiceImpl<TenantAlbumCateg
|
|
|
* @return IPage<TenantAlbumCategory>
|
|
|
*/
|
|
|
@Override
|
|
|
- public IPage<TenantAlbumCategory> selectPage(IPage<TenantAlbumCategory> page,
|
|
|
- TenantAlbumCategoryWrapper.TenantAlbumCategoryQuery query) {
|
|
|
-
|
|
|
- return page.setRecords(baseMapper.selectPage(page, query));
|
|
|
+ public IPage<TenantAlbumCategoryWrapper.TenantAlbumCategory> selectPage(
|
|
|
+ IPage<TenantAlbumCategoryWrapper.TenantAlbumCategory> page,
|
|
|
+ TenantAlbumCategoryWrapper.TenantAlbumCategoryQuery query) {
|
|
|
+
|
|
|
+ List<TenantAlbumCategory> tenantAlbumCategories = baseMapper.selectPage(page, query);
|
|
|
+
|
|
|
+ List<TenantAlbumCategoryWrapper.TenantAlbumCategory> result = tenantAlbumCategories.stream().map(next -> {
|
|
|
+ TenantAlbumCategoryWrapper.TenantAlbumCategory tenantAlbumCategory =
|
|
|
+ new TenantAlbumCategoryWrapper.TenantAlbumCategory();
|
|
|
+ BeanUtils.copyProperties(next, tenantAlbumCategory);
|
|
|
+ return tenantAlbumCategory;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<Long> idList = tenantAlbumCategories.stream().map(TenantAlbumCategory::getId).collect(Collectors.toList());
|
|
|
+ if (!idList.isEmpty()) {
|
|
|
+ List<TenantAlbumCategoryDetail> detailList = tenantAlbumCategoryDetailService.lambdaQuery()
|
|
|
+ .in(TenantAlbumCategoryDetail::getTenantAlbumCategoryId, idList)
|
|
|
+ .list();
|
|
|
+ Map<Long, List<TenantAlbumCategoryDetail>> groupById = detailList.stream()
|
|
|
+ .collect(Collectors.groupingBy(TenantAlbumCategoryDetail::getTenantAlbumCategoryId));
|
|
|
+ result.forEach(next -> next.setValues(groupById.getOrDefault(next.getId(), new ArrayList<>())));
|
|
|
+ }
|
|
|
+ return page.setRecords(result);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -137,8 +159,18 @@ public class TenantAlbumCategoryServiceImpl extends ServiceImpl<TenantAlbumCateg
|
|
|
List<TenantAlbumCategoryDetail> removeDetailIdList =
|
|
|
detailList.stream().filter(next -> !newUpdateIds.contains(next.getId())).collect(Collectors.toList());
|
|
|
if (!removeDetailIdList.isEmpty()) {
|
|
|
+ // 校验删除的分类值是否被使用,如果有使用,则提示
|
|
|
TenantAlbumCategory albumCategory = this.getById(tenantAlbumCategory.getId());
|
|
|
- checkTenantAlbumCategoryDetailUsed(albumCategory.getCategoryType(), removeDetailIdList);
|
|
|
+ QueryWrapper<TenantAlbum> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .eq(ETenantAlbumCategoryType.CATEGORY_TYPE.equals(albumCategory.getCategoryType()),
|
|
|
+ TenantAlbum::getCategoryLevelId, tenantAlbumCategory.getId())
|
|
|
+ .eq(ETenantAlbumCategoryType.CATEGORY_LEVEL.equals(albumCategory.getCategoryType()),
|
|
|
+ TenantAlbum::getCategoryTypeId, tenantAlbumCategory.getId());
|
|
|
+ Integer useCount = tenantAlbumMapper.selectCount(queryWrapper);
|
|
|
+ if (useCount > 0) {
|
|
|
+ checkTenantAlbumCategoryDetailUsed(albumCategory.getCategoryType(), removeDetailIdList);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
tenantAlbumCategoryDetailService.lambdaUpdate()
|