|
|
@@ -3358,4 +3358,70 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<StoreDictionaryVo> getLeisureEntertainmentCategories() {
|
|
|
+ // 定义四种主分类名称
|
|
|
+ List<String> mainCategoryNames = Arrays.asList("酒吧", "KTV", "洗浴汗蒸", "按摩足浴");
|
|
|
+
|
|
|
+ // 查询所有主分类(business_section类型)
|
|
|
+ List<StoreDictionary> allMainCategories = storeDictionaryMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<StoreDictionary>()
|
|
|
+ .eq(StoreDictionary::getTypeName, "business_section")
|
|
|
+ .in(StoreDictionary::getDictDetail, mainCategoryNames)
|
|
|
+ .eq(StoreDictionary::getDeleteFlag, 0)
|
|
|
+ );
|
|
|
+
|
|
|
+ // 构建主分类列表,包含"全部"选项
|
|
|
+ List<StoreDictionaryVo> result = new ArrayList<>();
|
|
|
+
|
|
|
+ // 添加"全部"选项
|
|
|
+ StoreDictionaryVo allCategory = new StoreDictionaryVo();
|
|
|
+ allCategory.setId(0);
|
|
|
+ allCategory.setDictId("0");
|
|
|
+ allCategory.setDictDetail("全部");
|
|
|
+ allCategory.setTypeName("business_section");
|
|
|
+ allCategory.setSubDataList(new ArrayList<>());
|
|
|
+ result.add(allCategory);
|
|
|
+
|
|
|
+ // 查询所有子分类(根据parent_id关联)
|
|
|
+ Map<Integer, List<StoreDictionary>> subCategoryMap = new HashMap<>();
|
|
|
+ if (!CollectionUtils.isEmpty(allMainCategories)) {
|
|
|
+ List<Integer> mainCategoryIds = allMainCategories.stream()
|
|
|
+ .map(StoreDictionary::getId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 查询所有子分类
|
|
|
+ List<StoreDictionary> allSubCategories = storeDictionaryMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<StoreDictionary>()
|
|
|
+ .in(StoreDictionary::getParentId, mainCategoryIds)
|
|
|
+ .eq(StoreDictionary::getDeleteFlag, 0)
|
|
|
+ );
|
|
|
+
|
|
|
+ // 按parentId分组
|
|
|
+ subCategoryMap = allSubCategories.stream()
|
|
|
+ .collect(Collectors.groupingBy(StoreDictionary::getParentId));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 构建主分类及其子分类
|
|
|
+ for (StoreDictionary mainCategory : allMainCategories) {
|
|
|
+ StoreDictionaryVo mainVo = new StoreDictionaryVo();
|
|
|
+ BeanUtils.copyProperties(mainCategory, mainVo);
|
|
|
+
|
|
|
+ // 获取该主分类下的子分类
|
|
|
+ List<StoreDictionary> subCategories = subCategoryMap.getOrDefault(mainCategory.getId(), new ArrayList<>());
|
|
|
+ List<StoreDictionaryVo> subVoList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (StoreDictionary subCategory : subCategories) {
|
|
|
+ StoreDictionaryVo subVo = new StoreDictionaryVo();
|
|
|
+ BeanUtils.copyProperties(subCategory, subVo);
|
|
|
+ subVoList.add(subVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ mainVo.setSubDataList(subVoList);
|
|
|
+ result.add(mainVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|