|
|
@@ -3368,7 +3368,7 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
@Override
|
|
|
public List<StoreDictionaryVo> getLeisureEntertainmentCategories() {
|
|
|
// 定义四种主分类名称
|
|
|
- List<String> mainCategoryNames = Arrays.asList("酒吧", "KTV", "洗浴汗蒸", "按摩足浴");
|
|
|
+ List<String> mainCategoryNames = Arrays.asList("酒吧", "KTV", "洗浴汗蒸", "按摩足疗");
|
|
|
|
|
|
// 查询所有主分类(business_section类型)
|
|
|
List<StoreDictionary> allMainCategories = storeDictionaryMapper.selectList(
|
|
|
@@ -3402,6 +3402,7 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
new LambdaQueryWrapper<StoreDictionary>()
|
|
|
.in(StoreDictionary::getParentId, mainCategoryIds)
|
|
|
.eq(StoreDictionary::getDeleteFlag, 0)
|
|
|
+ .in(StoreDictionary::getTypeName, "business_section","business_type","business_classify")
|
|
|
);
|
|
|
|
|
|
// 按parentId分组
|
|
|
@@ -3430,4 +3431,68 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<StoreDictionary> getAllBusinessSection() {
|
|
|
+ // 查询所有经营种类数据
|
|
|
+ LambdaQueryWrapper<StoreDictionary> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.in(StoreDictionary::getTypeName, "business_section","business_type","business_classify");
|
|
|
+ queryWrapper.eq(StoreDictionary::getDeleteFlag, 0);
|
|
|
+ queryWrapper.orderByAsc(StoreDictionary::getSortId);
|
|
|
+ List<StoreDictionary> storeDictionaryList = storeDictionaryMapper.selectList(queryWrapper);
|
|
|
+
|
|
|
+ // 构建三级树形结构
|
|
|
+ return buildTreeOptimized(storeDictionaryList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构建树形结构(优化版)
|
|
|
+ *
|
|
|
+ * @param flatList 扁平列表
|
|
|
+ * @return 树形结构列表
|
|
|
+ */
|
|
|
+ private List<StoreDictionary> buildTreeOptimized(List<StoreDictionary> flatList) {
|
|
|
+ if (flatList == null || flatList.isEmpty()) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 创建三个存储结构
|
|
|
+ Map<Integer, StoreDictionary> nodeMap = new HashMap<>(); // ID到节点的映射
|
|
|
+ Map<Integer, List<StoreDictionary>> parentChildMap = new HashMap<>(); // 父ID到子节点列表的映射
|
|
|
+ List<StoreDictionary> result = new ArrayList<>(); // 结果列表
|
|
|
+
|
|
|
+ // 填充nodeMap和parentChildMap
|
|
|
+ for (StoreDictionary entity : flatList) {
|
|
|
+ Integer id = entity.getId();
|
|
|
+ Integer parentId = entity.getParentId();
|
|
|
+
|
|
|
+ // 存入节点映射
|
|
|
+ nodeMap.put(id, entity);
|
|
|
+
|
|
|
+ // 初始化子节点列表
|
|
|
+ entity.setStoreDictionaryList(new ArrayList<>());
|
|
|
+
|
|
|
+ // 如果是根节点(parentId为null或0),直接添加到结果
|
|
|
+ if (parentId == null || parentId == 0) {
|
|
|
+ result.add(entity);
|
|
|
+ } else {
|
|
|
+ // 否则,记录父子关系
|
|
|
+ parentChildMap.computeIfAbsent(parentId, k -> new ArrayList<>()).add(entity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 建立父子关系
|
|
|
+ for (StoreDictionary entity : flatList) {
|
|
|
+ Integer id = entity.getId();
|
|
|
+ if (parentChildMap.containsKey(id)) {
|
|
|
+ entity.getStoreDictionaryList().addAll(parentChildMap.get(id));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|