Quellcode durchsuchen

feat(dictionary): 增强字典库查询与管理功能

- 为字典库查询接口增加dictDetail过滤参数支持
- 实现根据dictDetail查询包含父级或子级的树形结构
- 添加删除字典库记录的功能(支持一、二、三级)
- 添加修改字典库隐藏状态的功能(通过设置hidden字段)
- 在意见反馈和店铺标签字典中同样支持dictDetail过滤查询
- 优化树形结构构建逻辑,提高查询性能和准确性
- 增加对多同名数据及其关联节点的完整查询支持
fcw vor 21 Stunden
Ursprung
Commit
f1d8226a7b
15 geänderte Dateien mit 1622 neuen und 34 gelöschten Zeilen
  1. 4 4
      alien-store/src/main/java/shop/alien/store/controller/DictOpinionFeedbackController.java
  2. 4 4
      alien-store/src/main/java/shop/alien/store/controller/DictStoreTagController.java
  3. 62 4
      alien-store/src/main/java/shop/alien/store/controller/DictionaryLibraryController.java
  4. 4 4
      alien-store/src/main/java/shop/alien/store/controller/FilterConditionController.java
  5. 4 4
      alien-store/src/main/java/shop/alien/store/controller/PlatformBusinessSectionController.java
  6. 4 1
      alien-store/src/main/java/shop/alien/store/service/DictOpinionFeedbackService.java
  7. 4 1
      alien-store/src/main/java/shop/alien/store/service/DictStoreTagService.java
  8. 22 1
      alien-store/src/main/java/shop/alien/store/service/DictionaryLibraryService.java
  9. 5 2
      alien-store/src/main/java/shop/alien/store/service/FilterConditionService.java
  10. 4 1
      alien-store/src/main/java/shop/alien/store/service/PlatformBusinessSectionService.java
  11. 262 1
      alien-store/src/main/java/shop/alien/store/service/impl/DictOpinionFeedbackServiceImpl.java
  12. 260 1
      alien-store/src/main/java/shop/alien/store/service/impl/DictStoreTagServiceImpl.java
  13. 463 2
      alien-store/src/main/java/shop/alien/store/service/impl/DictionaryLibraryServiceImpl.java
  14. 260 2
      alien-store/src/main/java/shop/alien/store/service/impl/FilterConditionServiceImpl.java
  15. 260 2
      alien-store/src/main/java/shop/alien/store/service/impl/PlatformBusinessSectionServiceImpl.java

+ 4 - 4
alien-store/src/main/java/shop/alien/store/controller/DictOpinionFeedbackController.java

@@ -41,12 +41,12 @@ public class DictOpinionFeedbackController {
 
     private final DictOpinionFeedbackService dictOpinionFeedbackService;
 
-    @ApiOperation("查询意见反馈字典(三级树形结构)")
+    @ApiOperation("查询意见反馈字典(三级树形结构),支持根据dictDetail过滤")
     @ApiOperationSupport(order = 1)
     @GetMapping("/queryDictOpinionFeedbackTree")
-    public R<List<StoreDictionary>> queryDictOpinionFeedbackTree() {
-        log.info("dictOpinionFeedback.queryDictOpinionFeedbackTree");
-        List<StoreDictionary> result = dictOpinionFeedbackService.queryDictOpinionFeedbackTree();
+    public R<List<StoreDictionary>> queryDictOpinionFeedbackTree(@RequestParam(required = false) String dictDetail) {
+        log.info("dictOpinionFeedback.queryDictOpinionFeedbackTree dictDetail={}", dictDetail);
+        List<StoreDictionary> result = dictOpinionFeedbackService.queryDictOpinionFeedbackTree(dictDetail);
         return R.data(result);
     }
 

+ 4 - 4
alien-store/src/main/java/shop/alien/store/controller/DictStoreTagController.java

@@ -41,12 +41,12 @@ public class DictStoreTagController {
 
     private final DictStoreTagService dictStoreTagService;
 
-    @ApiOperation("查询店铺标签字典(三级树形结构)")
+    @ApiOperation("查询店铺标签字典(三级树形结构),支持根据dictDetail过滤")
     @ApiOperationSupport(order = 1)
     @GetMapping("/queryDictStoreTagTree")
-    public R<List<StoreDictionary>> queryDictStoreTagTree() {
-        log.info("dictStoreTag.queryDictStoreTagTree");
-        List<StoreDictionary> result = dictStoreTagService.queryDictStoreTagTree();
+    public R<List<StoreDictionary>> queryDictStoreTagTree(@RequestParam(required = false) String dictDetail) {
+        log.info("dictStoreTag.queryDictStoreTagTree dictDetail={}", dictDetail);
+        List<StoreDictionary> result = dictStoreTagService.queryDictStoreTagTree(dictDetail);
         return R.data(result);
     }
 

+ 62 - 4
alien-store/src/main/java/shop/alien/store/controller/DictionaryLibraryController.java

@@ -32,12 +32,12 @@ public class DictionaryLibraryController {
 
     private final DictionaryLibraryService dictionaryLibraryService;
 
-    @ApiOperation("查询字典库(三级树形结构)")
+    @ApiOperation("查询字典库(三级树形结构),支持根据dictDetail过滤")
     @ApiOperationSupport(order = 1)
     @GetMapping("/queryDictionaryLibraryTree")
-    public R<List<StoreDictionary>> queryDictionaryLibraryTree() {
-        log.info("dictionaryLibrary.queryDictionaryLibraryTree");
-        List<StoreDictionary> result = dictionaryLibraryService.queryDictionaryLibraryTree();
+    public R<List<StoreDictionary>> queryDictionaryLibraryTree(@RequestParam(required = false) String dictDetail) {
+        log.info("dictionaryLibrary.queryDictionaryLibraryTree dictDetail={}", dictDetail);
+        List<StoreDictionary> result = dictionaryLibraryService.queryDictionaryLibraryTree(dictDetail);
         return R.data(result);
     }
 
@@ -154,4 +154,62 @@ public class DictionaryLibraryController {
         }
     }
 
+
+    @ApiOperation("删除字典库(支持一级、二级、三级)")
+    @ApiOperationSupport(order = 6)
+    @DeleteMapping("/deleteDictionaryLibrary/{id}")
+    public R<Boolean> deleteDictionaryLibrary(@PathVariable Long id) {
+        log.info("dictionaryLibrary.deleteDictionaryLibrary id={}", id);
+        try {
+            int result = dictionaryLibraryService.deleteDictionaryLibrary(id);
+            if (result > 0) {
+                return R.success("删除成功");
+            } else {
+                return R.fail("删除失败");
+            }
+        } catch (IllegalArgumentException e) {
+            log.error("dictionaryLibrary.deleteDictionaryLibrary error: {}", e.getMessage());
+            return R.fail(e.getMessage());
+        } catch (Exception e) {
+            log.error("dictionaryLibrary.deleteDictionaryLibrary error", e);
+            return R.fail("删除失败:" + e.getMessage());
+        }
+    }
+
+    @ApiOperation("修改字典库状态(通过id修改hidden为1)")
+    @ApiOperationSupport(order = 7)
+    @PutMapping("/updateHiddenStatus/{id}")
+    public R<Boolean> updateHiddenStatus(@PathVariable Long id) {
+        log.info("dictionaryLibrary.updateHiddenStatus id={}", id);
+        try {
+            int result = dictionaryLibraryService.updateHiddenStatus(id);
+            if (result > 0) {
+                return R.success("删除成功");
+            } else {
+                return R.fail("删除失败");
+            }
+        } catch (IllegalArgumentException e) {
+            log.error("dictionaryLibrary.updateHiddenStatus error: {}", e.getMessage());
+            return R.fail(e.getMessage());
+        } catch (Exception e) {
+            log.error("dictionaryLibrary.updateHiddenStatus error", e);
+            return R.fail("修改失败:" + e.getMessage());
+        }
+    }
+
+    @ApiOperation("根据dictDetail查询字典库(包含父级或子级树形结构)")
+    @ApiOperationSupport(order = 8)
+    @GetMapping("/selectDictBydictDetail")
+    public R<List<StoreDictionary>> selectDictBydictDetail(@RequestParam String dictDetail) {
+        log.info("dictionaryLibrary.selectDictBydictDetail dictDetail={}", dictDetail);
+        try {
+            // 内部调用queryDictionaryLibraryTree方法
+            List<StoreDictionary> result = dictionaryLibraryService.queryDictionaryLibraryTree(dictDetail);
+            return R.data(result);
+        } catch (Exception e) {
+            log.error("dictionaryLibrary.selectDictBydictDetail error", e);
+            return R.fail("查询失败:" + e.getMessage());
+        }
+    }
+
 }

+ 4 - 4
alien-store/src/main/java/shop/alien/store/controller/FilterConditionController.java

@@ -32,12 +32,12 @@ public class FilterConditionController {
 
     private final FilterConditionService filterConditionService;
 
-    @ApiOperation("查询筛选条件(三级树形结构)")
+    @ApiOperation("查询筛选条件(四级树形结构),支持根据dictDetail过滤")
     @ApiOperationSupport(order = 1)
     @GetMapping("/queryFilterConditionTree")
-    public R<List<StoreDictionary>> queryFilterConditionTree() {
-        log.info("filterCondition.queryFilterConditionTree");
-        List<StoreDictionary> result = filterConditionService.queryFilterConditionTree();
+    public R<List<StoreDictionary>> queryFilterConditionTree(@RequestParam(required = false) String dictDetail) {
+        log.info("filterCondition.queryFilterConditionTree dictDetail={}", dictDetail);
+        List<StoreDictionary> result = filterConditionService.queryFilterConditionTree(dictDetail);
         return R.data(result);
     }
 

+ 4 - 4
alien-store/src/main/java/shop/alien/store/controller/PlatformBusinessSectionController.java

@@ -26,12 +26,12 @@ public class PlatformBusinessSectionController {
 
     private final PlatformBusinessSectionService platformBusinessSectionService;
 
-    @ApiOperation("查询经营种类(三级树形结构)")
+    @ApiOperation("查询经营种类(三级树形结构),支持根据dictDetail过滤")
     @ApiOperationSupport(order = 1)
     @GetMapping("/queryBusinessSectionTree")
-    public R<List<StoreDictionary>> queryBusinessSectionTree() {
-        log.info("platformBusinessSection.queryBusinessSectionTree");
-        List<StoreDictionary> result = platformBusinessSectionService.queryBusinessSectionTree();
+    public R<List<StoreDictionary>> queryBusinessSectionTree(@RequestParam(required = false) String dictDetail) {
+        log.info("platformBusinessSection.queryBusinessSectionTree dictDetail={}", dictDetail);
+        List<StoreDictionary> result = platformBusinessSectionService.queryBusinessSectionTree(dictDetail);
         return R.data(result);
     }
 

+ 4 - 1
alien-store/src/main/java/shop/alien/store/service/DictOpinionFeedbackService.java

@@ -14,10 +14,13 @@ public interface DictOpinionFeedbackService {
 
     /**
      * 查询意见反馈字典(三级树形结构)
+     * 如果传入dictDetail,则查询匹配的记录及其父级和子级树形结构
+     * 如果不传dictDetail,则返回完整的字典库树形结构
      *
+     * @param dictDetail 字典描述(可选),如果传入则根据此参数过滤
      * @return 字典树形结构列表
      */
-    List<StoreDictionary> queryDictOpinionFeedbackTree();
+    List<StoreDictionary> queryDictOpinionFeedbackTree(String dictDetail);
 
     /**
      * 新增意见反馈字典(支持一级、二级、三级)

+ 4 - 1
alien-store/src/main/java/shop/alien/store/service/DictStoreTagService.java

@@ -14,10 +14,13 @@ public interface DictStoreTagService {
 
     /**
      * 查询店铺字典标签(三级树形结构)
+     * 如果传入dictDetail,则查询匹配的记录及其父级和子级树形结构
+     * 如果不传dictDetail,则返回完整的字典库树形结构
      *
+     * @param dictDetail 字典描述(可选),如果传入则根据此参数过滤
      * @return 标签树形结构列表
      */
-    List<StoreDictionary> queryDictStoreTagTree();
+    List<StoreDictionary> queryDictStoreTagTree(String dictDetail);
 
     /**
      * 新增店铺字典标签(支持一级、二级、三级)

+ 22 - 1
alien-store/src/main/java/shop/alien/store/service/DictionaryLibraryService.java

@@ -18,10 +18,13 @@ public interface DictionaryLibraryService {
 
     /**
      * 查询字典库(三级树形结构)
+     * 如果传入dictDetail,则查询匹配的记录及其父级和子级树形结构
+     * 如果不传dictDetail,则返回完整的字典库树形结构
      *
+     * @param dictDetail 字典描述(可选),如果传入则根据此参数过滤
      * @return 字典库树形结构列表
      */
-    List<StoreDictionary> queryDictionaryLibraryTree();
+    List<StoreDictionary> queryDictionaryLibraryTree(String dictDetail);
 
     /**
      * 新增字典库(支持一级、二级、三级)
@@ -54,4 +57,22 @@ public interface DictionaryLibraryService {
      * @throws IOException IO异常
      */
     void downloadTemplate(HttpServletResponse response) throws IOException;
+
+    int deleteDictionaryLibrary(Long id);
+
+    /**
+     * 修改字典库状态(通过id修改hidden为1)
+     *
+     * @param id 字典库ID
+     * @return 修改结果
+     */
+    int updateHiddenStatus(Long id);
+
+    /**
+     * 根据dictDetail查询字典库(包含父级或子级树形结构)
+     *
+     * @param dictDetail 字典描述
+     * @return 字典库树形结构列表
+     */
+    List<StoreDictionary> selectDictBydictDetail(String dictDetail);
 }

+ 5 - 2
alien-store/src/main/java/shop/alien/store/service/FilterConditionService.java

@@ -17,11 +17,14 @@ import java.util.List;
 public interface FilterConditionService {
 
     /**
-     * 查询筛选条件(三级树形结构)
+     * 查询筛选条件(四级树形结构)
+     * 如果传入dictDetail,则查询匹配的记录及其父级和子级树形结构
+     * 如果不传dictDetail,则返回完整的字典库树形结构
      *
+     * @param dictDetail 字典描述(可选),如果传入则根据此参数过滤
      * @return 筛选条件树形结构列表
      */
-    List<StoreDictionary> queryFilterConditionTree();
+    List<StoreDictionary> queryFilterConditionTree(String dictDetail);
 
     /**
      * 新增筛选条件(支持一级、二级、三级)

+ 4 - 1
alien-store/src/main/java/shop/alien/store/service/PlatformBusinessSectionService.java

@@ -18,10 +18,13 @@ public interface PlatformBusinessSectionService {
 
     /**
      * 查询经营种类(三级树形结构)
+     * 如果传入dictDetail,则查询匹配的记录及其父级和子级树形结构
+     * 如果不传dictDetail,则返回完整的字典库树形结构
      *
+     * @param dictDetail 字典描述(可选),如果传入则根据此参数过滤
      * @return 经营种类树形结构列表
      */
-    List<StoreDictionary> queryBusinessSectionTree();
+    List<StoreDictionary> queryBusinessSectionTree(String dictDetail);
 
     /**
      * 新增经营种类(支持一级、二级、三级)

+ 262 - 1
alien-store/src/main/java/shop/alien/store/service/impl/DictOpinionFeedbackServiceImpl.java

@@ -38,8 +38,10 @@ import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * 意见反馈字典管理ServiceImpl
@@ -55,9 +57,20 @@ public class DictOpinionFeedbackServiceImpl extends ServiceImpl<StoreDictionaryM
 
     /**
      * 查询意见反馈字典(三级树形结构)
+     * 如果传入dictDetail,则查询匹配的记录及其父级和子级树形结构
+     * 如果不传dictDetail,则返回完整的字典库树形结构
+     *
+     * @param dictDetail 字典描述(可选),如果传入则根据此参数过滤
+     * @return 字典树形结构列表
      */
     @Override
-    public List<StoreDictionary> queryDictOpinionFeedbackTree() {
+    public List<StoreDictionary> queryDictOpinionFeedbackTree(String dictDetail) {
+        // 如果传入了dictDetail,使用过滤逻辑
+        if (StringUtils.isNotBlank(dictDetail)) {
+            return selectDictBydictDetail(dictDetail);
+        }
+        
+        // 否则使用原有逻辑:查询所有意见反馈字典数据
         LambdaQueryWrapper<StoreDictionary> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.in(StoreDictionary::getTypeName, "opinion_feedback", "opinion_feedback_type", "opinion_feedback_classify");
         queryWrapper.eq(StoreDictionary::getDeleteFlag, 0);
@@ -66,6 +79,254 @@ public class DictOpinionFeedbackServiceImpl extends ServiceImpl<StoreDictionaryM
 
         return buildTreeOptimized(dictList);
     }
+    
+    /**
+     * 根据dictDetail查询意见反馈字典(包含父级或子级树形结构)
+     * 支持查询多个同名数据及其父级和子级
+     *
+     * @param dictDetail 字典描述
+     * @return 意见反馈字典树形结构列表
+     */
+    private List<StoreDictionary> selectDictBydictDetail(String dictDetail) {
+        if (StringUtils.isBlank(dictDetail)) {
+            throw new IllegalArgumentException("dictDetail不能为空");
+        }
+
+        // 通过dictDetail模糊查询所有匹配的记录(可能有多个同名数据)
+        LambdaQueryWrapper<StoreDictionary> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.in(StoreDictionary::getTypeName, "opinion_feedback", "opinion_feedback_type", "opinion_feedback_classify");
+        queryWrapper.eq(StoreDictionary::getDeleteFlag, 0);
+        queryWrapper.like(StoreDictionary::getDictDetail, dictDetail);
+        
+        List<StoreDictionary> matchedDicts = storeDictionaryMapper.selectList(queryWrapper);
+        
+        if (matchedDicts == null || matchedDicts.isEmpty()) {
+            log.warn("未找到dictDetail为[{}]的记录", dictDetail);
+            return new ArrayList<>();
+        }
+
+        log.info("找到{}条dictDetail为[{}]的记录", matchedDicts.size(), dictDetail);
+
+        // 用于存储每个根节点对应的所有节点(按根节点分组)
+        Map<Integer, Set<Integer>> rootToNodeIdsMap = new HashMap<>();
+        
+        // 遍历所有匹配的记录,收集相关节点ID
+        for (StoreDictionary currentDict : matchedDicts) {
+            Integer parentId = currentDict.getParentId();
+            Integer rootId;
+            
+            if (parentId != null && parentId != 0) {
+                // 如果有父级,查找根节点
+                rootId = findRootId(currentDict.getId());
+                log.info("记录ID[{}]有父级[{}], 根节点ID[{}]", currentDict.getId(), parentId, rootId);
+                
+                // 收集从根节点到当前节点的路径上的所有节点ID
+                List<Integer> pathNodeIds = new ArrayList<>();
+                collectPathNodes(currentDict.getId(), pathNodeIds);
+                log.info("路径节点IDs: {}", pathNodeIds);
+                
+                // 收集该根节点下的所有相关节点ID(包括路径节点及其所有子节点)
+                Set<Integer> nodeIds = rootToNodeIdsMap.computeIfAbsent(rootId, k -> new HashSet<>());
+                for (Integer nodeId : pathNodeIds) {
+                    nodeIds.add(nodeId);
+                    collectChildrenIds(nodeId, nodeIds);
+                }
+            } else {
+                // 如果没有父级,以当前节点为根
+                rootId = currentDict.getId();
+                log.info("记录ID[{}]没有父级, 作为根节点", currentDict.getId());
+                
+                // 收集该根节点下的所有相关节点ID
+                Set<Integer> nodeIds = rootToNodeIdsMap.computeIfAbsent(rootId, k -> new HashSet<>());
+                nodeIds.add(currentDict.getId());
+                collectChildrenIds(currentDict.getId(), nodeIds);
+            }
+        }
+        
+        // 收集所有需要返回的节点数据
+        Map<Integer, StoreDictionary> allNodeMap = new HashMap<>();
+        for (Set<Integer> nodeIds : rootToNodeIdsMap.values()) {
+            for (Integer nodeId : nodeIds) {
+                if (!allNodeMap.containsKey(nodeId)) {
+                    StoreDictionary node = storeDictionaryMapper.selectById(nodeId);
+                    if (node != null && node.getDeleteFlag() == 0) {
+                        allNodeMap.put(nodeId, node);
+                    }
+                }
+            }
+        }
+        
+        log.info("总共收集到{}个节点", allNodeMap.size());
+        
+        // 构建树形结构,为每个唯一的根节点构建一棵树
+        List<StoreDictionary> resultList = new ArrayList<>();
+        
+        for (Map.Entry<Integer, Set<Integer>> entry : rootToNodeIdsMap.entrySet()) {
+            Integer rootId = entry.getKey();
+            Set<Integer> nodeIds = entry.getValue();
+            
+            log.info("处理根节点[{}], 包含{}个节点", rootId, nodeIds.size());
+            
+            // 从所有节点中筛选出该根节点下的相关节点
+            List<StoreDictionary> relatedNodes = new ArrayList<>();
+            for (Integer nodeId : nodeIds) {
+                StoreDictionary node = allNodeMap.get(nodeId);
+                if (node != null) {
+                    relatedNodes.add(node);
+                }
+            }
+            
+            log.info("根节点[{}]筛选出{}个相关节点", rootId, relatedNodes.size());
+            
+            // 如果找到相关节点,构建树形结构
+            if (!relatedNodes.isEmpty()) {
+                StoreDictionary root = buildTreeFromNodeList(relatedNodes, rootId);
+                if (root != null) {
+                    resultList.add(root);
+                    log.info("成功构建根节点[{}]的树形结构", rootId);
+                } else {
+                    log.warn("构建根节点[{}]的树形结构失败", rootId);
+                }
+            } else {
+                log.warn("根节点[{}]没有相关节点", rootId);
+            }
+        }
+        
+        log.info("最终返回{}棵树", resultList.size());
+        return resultList;
+    }
+    
+    /**
+     * 收集节点的所有子节点ID(递归)
+     *
+     * @param nodeId 节点ID
+     * @param childrenIds 子节点ID集合
+     */
+    private void collectChildrenIds(Integer nodeId, Set<Integer> childrenIds) {
+        LambdaQueryWrapper<StoreDictionary> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.in(StoreDictionary::getTypeName, "opinion_feedback", "opinion_feedback_type", "opinion_feedback_classify");
+        queryWrapper.eq(StoreDictionary::getDeleteFlag, 0);
+        queryWrapper.eq(StoreDictionary::getParentId, nodeId);
+        
+        List<StoreDictionary> children = storeDictionaryMapper.selectList(queryWrapper);
+        
+        if (children != null && !children.isEmpty()) {
+            for (StoreDictionary child : children) {
+                if (!childrenIds.contains(child.getId())) {
+                    childrenIds.add(child.getId());
+                    collectChildrenIds(child.getId(), childrenIds);
+                }
+            }
+        }
+    }
+
+    /**
+     * 递归查找根节点ID
+     *
+     * @param id 当前节点ID
+     * @return 根节点ID
+     */
+    private Integer findRootId(Integer id) {
+        StoreDictionary dict = storeDictionaryMapper.selectById(id);
+        if (dict == null || dict.getDeleteFlag() == 1) {
+            // 如果节点不存在或已删除,返回当前ID作为根节点
+            return id;
+        }
+        
+        Integer parentId = dict.getParentId();
+        if (parentId == null || parentId == 0) {
+            return id;
+        }
+        
+        return findRootId(parentId);
+    }
+
+    /**
+     * 收集从当前节点到根节点的路径上的所有节点ID
+     *
+     * @param nodeId 当前节点ID
+     * @param pathNodeIds 路径节点ID列表
+     */
+    private void collectPathNodes(Integer nodeId, List<Integer> pathNodeIds) {
+        StoreDictionary dict = storeDictionaryMapper.selectById(nodeId);
+        if (dict == null || dict.getDeleteFlag() == 1) {
+            return;
+        }
+        
+        // 避免重复添加
+        if (!pathNodeIds.contains(nodeId)) {
+            pathNodeIds.add(nodeId);
+        }
+        
+        Integer parentId = dict.getParentId();
+        if (parentId != null && parentId != 0) {
+            collectPathNodes(parentId, pathNodeIds);
+        }
+    }
+
+    /**
+     * 从节点列表构建树形结构
+     *
+     * @param nodeList 节点列表
+     * @param rootId 根节点ID
+     * @return 根节点
+     */
+    private StoreDictionary buildTreeFromNodeList(List<StoreDictionary> nodeList, Integer rootId) {
+        // 创建ID到节点的映射
+        Map<Integer, StoreDictionary> nodeMap = new HashMap<>();
+        for (StoreDictionary node : nodeList) {
+            nodeMap.put(node.getId(), node);
+            node.setStoreDictionaryList(new ArrayList<>());
+        }
+        
+        // 找到根节点
+        StoreDictionary root = nodeMap.get(rootId);
+        if (root == null) {
+            return null;
+        }
+        
+        // 建立父子关系
+        for (StoreDictionary node : nodeList) {
+            if (node.getId().equals(rootId)) {
+                continue; // 跳过根节点
+            }
+            
+            Integer parentId = node.getParentId();
+            if (parentId != null && parentId != 0) {
+                StoreDictionary parent = nodeMap.get(parentId);
+                if (parent != null) {
+                    parent.getStoreDictionaryList().add(node);
+                }
+            }
+        }
+        
+        // 对子节点列表按sortId排序
+        sortChildren(root);
+        
+        return root;
+    }
+
+    /**
+     * 递归排序子节点
+     *
+     * @param node 节点
+     */
+    private void sortChildren(StoreDictionary node) {
+        if (node == null || node.getStoreDictionaryList() == null) {
+            return;
+        }
+        
+        node.getStoreDictionaryList().sort((a, b) -> {
+            Integer sortIdA = a.getSortId() != null ? a.getSortId() : 0;
+            Integer sortIdB = b.getSortId() != null ? b.getSortId() : 0;
+            return sortIdA.compareTo(sortIdB);
+        });
+        
+        // 递归排序所有子节点
+        for (StoreDictionary child : node.getStoreDictionaryList()) {
+            sortChildren(child);
+        }
+    }
 
     /**
      * 构建树形结构(优化版)

+ 260 - 1
alien-store/src/main/java/shop/alien/store/service/impl/DictStoreTagServiceImpl.java

@@ -38,8 +38,10 @@ import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * 店铺字典标签管理ServiceImpl
@@ -55,11 +57,20 @@ public class DictStoreTagServiceImpl extends ServiceImpl<StoreDictionaryMapper,
 
     /**
      * 查询店铺字典标签(三级树形结构)
+     * 如果传入dictDetail,则查询匹配的记录及其父级和子级树形结构
+     * 如果不传dictDetail,则返回完整的字典库树形结构
      *
+     * @param dictDetail 字典描述(可选),如果传入则根据此参数过滤
      * @return 标签树形结构列表
      */
     @Override
-    public List<StoreDictionary> queryDictStoreTagTree() {
+    public List<StoreDictionary> queryDictStoreTagTree(String dictDetail) {
+        // 如果传入了dictDetail,使用过滤逻辑
+        if (StringUtils.isNotBlank(dictDetail)) {
+            return selectDictBydictDetail(dictDetail);
+        }
+        
+        // 否则使用原有逻辑:查询所有店铺标签字典数据
         LambdaQueryWrapper<StoreDictionary> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.in(StoreDictionary::getTypeName, "store_tag", "store_tag_type", "store_tag_classify");
         queryWrapper.eq(StoreDictionary::getDeleteFlag, 0);
@@ -68,6 +79,254 @@ public class DictStoreTagServiceImpl extends ServiceImpl<StoreDictionaryMapper,
 
         return buildTreeOptimized(dictStoreTags);
     }
+    
+    /**
+     * 根据dictDetail查询店铺标签字典(包含父级或子级树形结构)
+     * 支持查询多个同名数据及其父级和子级
+     *
+     * @param dictDetail 字典描述
+     * @return 店铺标签字典树形结构列表
+     */
+    private List<StoreDictionary> selectDictBydictDetail(String dictDetail) {
+        if (StringUtils.isBlank(dictDetail)) {
+            throw new IllegalArgumentException("dictDetail不能为空");
+        }
+
+        // 通过dictDetail模糊查询所有匹配的记录(可能有多个同名数据)
+        LambdaQueryWrapper<StoreDictionary> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.in(StoreDictionary::getTypeName, "store_tag", "store_tag_type", "store_tag_classify");
+        queryWrapper.eq(StoreDictionary::getDeleteFlag, 0);
+        queryWrapper.like(StoreDictionary::getDictDetail, dictDetail);
+        
+        List<StoreDictionary> matchedDicts = storeDictionaryMapper.selectList(queryWrapper);
+        
+        if (matchedDicts == null || matchedDicts.isEmpty()) {
+            log.warn("未找到dictDetail为[{}]的记录", dictDetail);
+            return new ArrayList<>();
+        }
+
+        log.info("找到{}条dictDetail为[{}]的记录", matchedDicts.size(), dictDetail);
+
+        // 用于存储每个根节点对应的所有节点(按根节点分组)
+        Map<Integer, Set<Integer>> rootToNodeIdsMap = new HashMap<>();
+        
+        // 遍历所有匹配的记录,收集相关节点ID
+        for (StoreDictionary currentDict : matchedDicts) {
+            Integer parentId = currentDict.getParentId();
+            Integer rootId;
+            
+            if (parentId != null && parentId != 0) {
+                // 如果有父级,查找根节点
+                rootId = findRootId(currentDict.getId());
+                log.info("记录ID[{}]有父级[{}], 根节点ID[{}]", currentDict.getId(), parentId, rootId);
+                
+                // 收集从根节点到当前节点的路径上的所有节点ID
+                List<Integer> pathNodeIds = new ArrayList<>();
+                collectPathNodes(currentDict.getId(), pathNodeIds);
+                log.info("路径节点IDs: {}", pathNodeIds);
+                
+                // 收集该根节点下的所有相关节点ID(包括路径节点及其所有子节点)
+                Set<Integer> nodeIds = rootToNodeIdsMap.computeIfAbsent(rootId, k -> new HashSet<>());
+                for (Integer nodeId : pathNodeIds) {
+                    nodeIds.add(nodeId);
+                    collectChildrenIds(nodeId, nodeIds);
+                }
+            } else {
+                // 如果没有父级,以当前节点为根
+                rootId = currentDict.getId();
+                log.info("记录ID[{}]没有父级, 作为根节点", currentDict.getId());
+                
+                // 收集该根节点下的所有相关节点ID
+                Set<Integer> nodeIds = rootToNodeIdsMap.computeIfAbsent(rootId, k -> new HashSet<>());
+                nodeIds.add(currentDict.getId());
+                collectChildrenIds(currentDict.getId(), nodeIds);
+            }
+        }
+        
+        // 收集所有需要返回的节点数据
+        Map<Integer, StoreDictionary> allNodeMap = new HashMap<>();
+        for (Set<Integer> nodeIds : rootToNodeIdsMap.values()) {
+            for (Integer nodeId : nodeIds) {
+                if (!allNodeMap.containsKey(nodeId)) {
+                    StoreDictionary node = storeDictionaryMapper.selectById(nodeId);
+                    if (node != null && node.getDeleteFlag() == 0) {
+                        allNodeMap.put(nodeId, node);
+                    }
+                }
+            }
+        }
+        
+        log.info("总共收集到{}个节点", allNodeMap.size());
+        
+        // 构建树形结构,为每个唯一的根节点构建一棵树
+        List<StoreDictionary> resultList = new ArrayList<>();
+        
+        for (Map.Entry<Integer, Set<Integer>> entry : rootToNodeIdsMap.entrySet()) {
+            Integer rootId = entry.getKey();
+            Set<Integer> nodeIds = entry.getValue();
+            
+            log.info("处理根节点[{}], 包含{}个节点", rootId, nodeIds.size());
+            
+            // 从所有节点中筛选出该根节点下的相关节点
+            List<StoreDictionary> relatedNodes = new ArrayList<>();
+            for (Integer nodeId : nodeIds) {
+                StoreDictionary node = allNodeMap.get(nodeId);
+                if (node != null) {
+                    relatedNodes.add(node);
+                }
+            }
+            
+            log.info("根节点[{}]筛选出{}个相关节点", rootId, relatedNodes.size());
+            
+            // 如果找到相关节点,构建树形结构
+            if (!relatedNodes.isEmpty()) {
+                StoreDictionary root = buildTreeFromNodeList(relatedNodes, rootId);
+                if (root != null) {
+                    resultList.add(root);
+                    log.info("成功构建根节点[{}]的树形结构", rootId);
+                } else {
+                    log.warn("构建根节点[{}]的树形结构失败", rootId);
+                }
+            } else {
+                log.warn("根节点[{}]没有相关节点", rootId);
+            }
+        }
+        
+        log.info("最终返回{}棵树", resultList.size());
+        return resultList;
+    }
+    
+    /**
+     * 收集节点的所有子节点ID(递归)
+     *
+     * @param nodeId 节点ID
+     * @param childrenIds 子节点ID集合
+     */
+    private void collectChildrenIds(Integer nodeId, Set<Integer> childrenIds) {
+        LambdaQueryWrapper<StoreDictionary> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.in(StoreDictionary::getTypeName, "store_tag", "store_tag_type", "store_tag_classify");
+        queryWrapper.eq(StoreDictionary::getDeleteFlag, 0);
+        queryWrapper.eq(StoreDictionary::getParentId, nodeId);
+        
+        List<StoreDictionary> children = storeDictionaryMapper.selectList(queryWrapper);
+        
+        if (children != null && !children.isEmpty()) {
+            for (StoreDictionary child : children) {
+                if (!childrenIds.contains(child.getId())) {
+                    childrenIds.add(child.getId());
+                    collectChildrenIds(child.getId(), childrenIds);
+                }
+            }
+        }
+    }
+
+    /**
+     * 递归查找根节点ID
+     *
+     * @param id 当前节点ID
+     * @return 根节点ID
+     */
+    private Integer findRootId(Integer id) {
+        StoreDictionary dict = storeDictionaryMapper.selectById(id);
+        if (dict == null || dict.getDeleteFlag() == 1) {
+            // 如果节点不存在或已删除,返回当前ID作为根节点
+            return id;
+        }
+        
+        Integer parentId = dict.getParentId();
+        if (parentId == null || parentId == 0) {
+            return id;
+        }
+        
+        return findRootId(parentId);
+    }
+
+    /**
+     * 收集从当前节点到根节点的路径上的所有节点ID
+     *
+     * @param nodeId 当前节点ID
+     * @param pathNodeIds 路径节点ID列表
+     */
+    private void collectPathNodes(Integer nodeId, List<Integer> pathNodeIds) {
+        StoreDictionary dict = storeDictionaryMapper.selectById(nodeId);
+        if (dict == null || dict.getDeleteFlag() == 1) {
+            return;
+        }
+        
+        // 避免重复添加
+        if (!pathNodeIds.contains(nodeId)) {
+            pathNodeIds.add(nodeId);
+        }
+        
+        Integer parentId = dict.getParentId();
+        if (parentId != null && parentId != 0) {
+            collectPathNodes(parentId, pathNodeIds);
+        }
+    }
+
+    /**
+     * 从节点列表构建树形结构
+     *
+     * @param nodeList 节点列表
+     * @param rootId 根节点ID
+     * @return 根节点
+     */
+    private StoreDictionary buildTreeFromNodeList(List<StoreDictionary> nodeList, Integer rootId) {
+        // 创建ID到节点的映射
+        Map<Integer, StoreDictionary> nodeMap = new HashMap<>();
+        for (StoreDictionary node : nodeList) {
+            nodeMap.put(node.getId(), node);
+            node.setStoreDictionaryList(new ArrayList<>());
+        }
+        
+        // 找到根节点
+        StoreDictionary root = nodeMap.get(rootId);
+        if (root == null) {
+            return null;
+        }
+        
+        // 建立父子关系
+        for (StoreDictionary node : nodeList) {
+            if (node.getId().equals(rootId)) {
+                continue; // 跳过根节点
+            }
+            
+            Integer parentId = node.getParentId();
+            if (parentId != null && parentId != 0) {
+                StoreDictionary parent = nodeMap.get(parentId);
+                if (parent != null) {
+                    parent.getStoreDictionaryList().add(node);
+                }
+            }
+        }
+        
+        // 对子节点列表按sortId排序
+        sortChildren(root);
+        
+        return root;
+    }
+
+    /**
+     * 递归排序子节点
+     *
+     * @param node 节点
+     */
+    private void sortChildren(StoreDictionary node) {
+        if (node == null || node.getStoreDictionaryList() == null) {
+            return;
+        }
+        
+        node.getStoreDictionaryList().sort((a, b) -> {
+            Integer sortIdA = a.getSortId() != null ? a.getSortId() : 0;
+            Integer sortIdB = b.getSortId() != null ? b.getSortId() : 0;
+            return sortIdA.compareTo(sortIdB);
+        });
+        
+        // 递归排序所有子节点
+        for (StoreDictionary child : node.getStoreDictionaryList()) {
+            sortChildren(child);
+        }
+    }
 
     /**
      * 构建树形结构

+ 463 - 2
alien-store/src/main/java/shop/alien/store/service/impl/DictionaryLibraryServiceImpl.java

@@ -26,8 +26,10 @@ import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * 平台字典库管理ServiceImpl
@@ -45,12 +47,20 @@ public class DictionaryLibraryServiceImpl extends ServiceImpl<StoreDictionaryMap
 
     /**
      * 查询字典库(三级树形结构)
+     * 如果传入dictDetail,则查询匹配的记录及其父级和子级树形结构
+     * 如果不传dictDetail,则返回完整的字典库树形结构
      *
+     * @param dictDetail 字典描述(可选),如果传入则根据此参数过滤
      * @return 字典库树形结构列表
      */
     @Override
-    public List<StoreDictionary> queryDictionaryLibraryTree() {
-        // 查询所有字典库数据
+    public List<StoreDictionary> queryDictionaryLibraryTree(String dictDetail) {
+        // 如果传入了dictDetail,使用过滤逻辑
+        if (StringUtils.isNotBlank(dictDetail)) {
+            return selectDictBydictDetail(dictDetail);
+        }
+        
+        // 否则使用原有逻辑:查询所有字典库数据
         LambdaQueryWrapper<StoreDictionary> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.in(StoreDictionary::getTypeName, "report", "report_type", "report_classify");
         queryWrapper.eq(StoreDictionary::getDeleteFlag, 0);
@@ -951,5 +961,456 @@ public class DictionaryLibraryServiceImpl extends ServiceImpl<StoreDictionaryMap
             }
         }
     }
+
+    @Override
+    public int deleteDictionaryLibrary(Long id) {
+        return storeDictionaryMapper.deleteById(id);
+    }
+
+    /**
+     * 修改字典库状态(通过id修改hidden为1)
+     *
+     * @param id 字典库ID
+     * @return 修改结果
+     */
+    @Override
+    public int updateHiddenStatus(Long id) {
+        if (id == null) {
+            throw new IllegalArgumentException("ID不能为空");
+        }
+
+        // 查询原记录
+        StoreDictionary existing = storeDictionaryMapper.selectById(id);
+        if (existing == null) {
+            throw new IllegalArgumentException("记录不存在");
+        }
+        if (existing.getDeleteFlag() == 1) {
+            throw new IllegalArgumentException("该记录已删除");
+        }
+
+        // 设置hidden为1
+        existing.setHidden(1);
+        existing.setUpdatedTime(new Date());
+
+        // 更新记录
+        return storeDictionaryMapper.updateById(existing);
+    }
+
+    /**
+     * 根据dictDetail查询字典库(包含父级或子级树形结构)
+     * 支持查询多个同名数据及其父级和子级
+     *
+     * @param dictDetail 字典描述
+     * @return 字典库树形结构列表
+     */
+    @Override
+    public List<StoreDictionary> selectDictBydictDetail(String dictDetail) {
+        if (StringUtils.isBlank(dictDetail)) {
+            throw new IllegalArgumentException("dictDetail不能为空");
+        }
+
+        // 通过dictDetail模糊查询所有匹配的记录(可能有多个同名数据)
+        LambdaQueryWrapper<StoreDictionary> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.in(StoreDictionary::getTypeName, "report", "report_type", "report_classify");
+        queryWrapper.eq(StoreDictionary::getDeleteFlag, 0);
+        queryWrapper.like(StoreDictionary::getDictDetail, dictDetail);
+        
+        List<StoreDictionary> matchedDicts = storeDictionaryMapper.selectList(queryWrapper);
+        
+        if (matchedDicts == null || matchedDicts.isEmpty()) {
+            log.warn("未找到dictDetail为[{}]的记录", dictDetail);
+            return new ArrayList<>();
+        }
+
+        log.info("找到{}条dictDetail为[{}]的记录", matchedDicts.size(), dictDetail);
+
+        // 用于存储每个根节点对应的所有节点(按根节点分组)
+        Map<Integer, Set<Integer>> rootToNodeIdsMap = new HashMap<>();
+        
+        // 遍历所有匹配的记录,收集相关节点ID
+        for (StoreDictionary currentDict : matchedDicts) {
+            Integer parentId = currentDict.getParentId();
+            Integer rootId;
+            
+            if (parentId != null && parentId != 0) {
+                // 如果有父级,查找根节点
+                rootId = findRootId(currentDict.getId());
+                log.info("记录ID[{}]有父级[{}], 根节点ID[{}]", currentDict.getId(), parentId, rootId);
+                
+                // 收集从根节点到当前节点的路径上的所有节点ID
+                List<Integer> pathNodeIds = new ArrayList<>();
+                collectPathNodes(currentDict.getId(), pathNodeIds);
+                log.info("路径节点IDs: {}", pathNodeIds);
+                
+                // 收集该根节点下的所有相关节点ID(包括路径节点及其所有子节点)
+                Set<Integer> nodeIds = rootToNodeIdsMap.computeIfAbsent(rootId, k -> new HashSet<>());
+                for (Integer nodeId : pathNodeIds) {
+                    nodeIds.add(nodeId);
+                    collectChildrenIds(nodeId, nodeIds);
+                }
+            } else {
+                // 如果没有父级,以当前节点为根
+                rootId = currentDict.getId();
+                log.info("记录ID[{}]没有父级, 作为根节点", currentDict.getId());
+                
+                // 收集该根节点下的所有相关节点ID
+                Set<Integer> nodeIds = rootToNodeIdsMap.computeIfAbsent(rootId, k -> new HashSet<>());
+                nodeIds.add(currentDict.getId());
+                collectChildrenIds(currentDict.getId(), nodeIds);
+            }
+        }
+        
+        // 收集所有需要返回的节点数据
+        Map<Integer, StoreDictionary> allNodeMap = new HashMap<>();
+        for (Set<Integer> nodeIds : rootToNodeIdsMap.values()) {
+            for (Integer nodeId : nodeIds) {
+                if (!allNodeMap.containsKey(nodeId)) {
+                    StoreDictionary node = storeDictionaryMapper.selectById(nodeId);
+                    if (node != null && node.getDeleteFlag() == 0) {
+                        allNodeMap.put(nodeId, node);
+                    }
+                }
+            }
+        }
+        
+        log.info("总共收集到{}个节点", allNodeMap.size());
+        
+        // 构建树形结构,为每个唯一的根节点构建一棵树
+        List<StoreDictionary> resultList = new ArrayList<>();
+        
+        for (Map.Entry<Integer, Set<Integer>> entry : rootToNodeIdsMap.entrySet()) {
+            Integer rootId = entry.getKey();
+            Set<Integer> nodeIds = entry.getValue();
+            
+            log.info("处理根节点[{}], 包含{}个节点", rootId, nodeIds.size());
+            
+            // 从所有节点中筛选出该根节点下的相关节点
+            List<StoreDictionary> relatedNodes = new ArrayList<>();
+            for (Integer nodeId : nodeIds) {
+                StoreDictionary node = allNodeMap.get(nodeId);
+                if (node != null) {
+                    relatedNodes.add(node);
+                }
+            }
+            
+            log.info("根节点[{}]筛选出{}个相关节点", rootId, relatedNodes.size());
+            
+            // 如果找到相关节点,构建树形结构
+            if (!relatedNodes.isEmpty()) {
+                StoreDictionary root = buildTreeFromNodeList(relatedNodes, rootId);
+                if (root != null) {
+                    resultList.add(root);
+                    log.info("成功构建根节点[{}]的树形结构", rootId);
+                } else {
+                    log.warn("构建根节点[{}]的树形结构失败", rootId);
+                }
+            } else {
+                log.warn("根节点[{}]没有相关节点", rootId);
+            }
+        }
+        
+        log.info("最终返回{}棵树", resultList.size());
+        return resultList;
+    }
+    
+    /**
+     * 收集节点的所有子节点ID(递归)
+     *
+     * @param nodeId 节点ID
+     * @param childrenIds 子节点ID集合
+     */
+    private void collectChildrenIds(Integer nodeId, Set<Integer> childrenIds) {
+        LambdaQueryWrapper<StoreDictionary> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.in(StoreDictionary::getTypeName, "report", "report_type", "report_classify");
+        queryWrapper.eq(StoreDictionary::getDeleteFlag, 0);
+        queryWrapper.eq(StoreDictionary::getParentId, nodeId);
+        
+        List<StoreDictionary> children = storeDictionaryMapper.selectList(queryWrapper);
+        
+        if (children != null && !children.isEmpty()) {
+            for (StoreDictionary child : children) {
+                if (!childrenIds.contains(child.getId())) {
+                    childrenIds.add(child.getId());
+                    collectChildrenIds(child.getId(), childrenIds);
+                }
+            }
+        }
+    }
+
+    /**
+     * 递归查找根节点ID
+     *
+     * @param id 当前节点ID
+     * @return 根节点ID
+     */
+    private Integer findRootId(Integer id) {
+        StoreDictionary dict = storeDictionaryMapper.selectById(id);
+        if (dict == null || dict.getDeleteFlag() == 1) {
+            // 如果节点不存在或已删除,返回当前ID作为根节点
+            return id;
+        }
+        
+        Integer parentId = dict.getParentId();
+        if (parentId == null || parentId == 0) {
+            return id;
+        }
+        
+        return findRootId(parentId);
+    }
+
+    /**
+     * 收集从当前节点到根节点的路径上的所有节点ID
+     *
+     * @param nodeId 当前节点ID
+     * @param pathNodeIds 路径节点ID列表
+     */
+    private void collectPathNodes(Integer nodeId, List<Integer> pathNodeIds) {
+        StoreDictionary dict = storeDictionaryMapper.selectById(nodeId);
+        if (dict == null || dict.getDeleteFlag() == 1) {
+            return;
+        }
+        
+        // 避免重复添加
+        if (!pathNodeIds.contains(nodeId)) {
+            pathNodeIds.add(nodeId);
+        }
+        
+        Integer parentId = dict.getParentId();
+        if (parentId != null && parentId != 0) {
+            collectPathNodes(parentId, pathNodeIds);
+        }
+    }
+
+    /**
+     * 从树形结构中过滤出包含指定dictDetail的树
+     *
+     * @param treeList 树形结构列表
+     * @param dictDetail 字典描述
+     * @return 过滤后的树形结构列表
+     */
+    private List<StoreDictionary> filterTreeByDictDetail(List<StoreDictionary> treeList, String dictDetail) {
+        List<StoreDictionary> result = new ArrayList<>();
+        
+        for (StoreDictionary node : treeList) {
+            // 检查当前节点是否包含目标dictDetail
+            if (containsDictDetail(node, dictDetail)) {
+                // 如果包含,复制节点并保留树形结构
+                StoreDictionary filteredNode = filterNodeByDictDetail(node, dictDetail);
+                if (filteredNode != null) {
+                    result.add(filteredNode);
+                }
+            }
+        }
+        
+        return result;
+    }
+
+    /**
+     * 检查节点及其子树是否包含指定dictDetail
+     *
+     * @param node 节点
+     * @param dictDetail 字典描述
+     * @return 是否包含
+     */
+    private boolean containsDictDetail(StoreDictionary node, String dictDetail) {
+        if (node == null) {
+            return false;
+        }
+        
+        if (dictDetail.equals(node.getDictDetail())) {
+            return true;
+        }
+        
+        List<StoreDictionary> children = node.getStoreDictionaryList();
+        if (children != null && !children.isEmpty()) {
+            for (StoreDictionary child : children) {
+                if (containsDictDetail(child, dictDetail)) {
+                    return true;
+                }
+            }
+        }
+        
+        return false;
+    }
+
+    /**
+     * 过滤节点,只保留包含目标dictDetail的路径
+     *
+     * @param node 节点
+     * @param dictDetail 字典描述
+     * @return 过滤后的节点
+     */
+    private StoreDictionary filterNodeByDictDetail(StoreDictionary node, String dictDetail) {
+        if (node == null) {
+            return null;
+        }
+        
+        StoreDictionary result = new StoreDictionary();
+        result.setId(node.getId());
+        result.setTypeName(node.getTypeName());
+        result.setTypeDetail(node.getTypeDetail());
+        result.setParentId(node.getParentId());
+        result.setDictId(node.getDictId());
+        result.setDictDetail(node.getDictDetail());
+        result.setDeleteFlag(node.getDeleteFlag());
+        result.setCreatedTime(node.getCreatedTime());
+        result.setCreatedUserId(node.getCreatedUserId());
+        result.setUpdatedTime(node.getUpdatedTime());
+        result.setUpdatedUserId(node.getUpdatedUserId());
+        result.setHidden(node.getHidden());
+        result.setSortId(node.getSortId());
+        
+        List<StoreDictionary> filteredChildren = new ArrayList<>();
+        List<StoreDictionary> children = node.getStoreDictionaryList();
+        
+        if (children != null && !children.isEmpty()) {
+            for (StoreDictionary child : children) {
+                if (containsDictDetail(child, dictDetail)) {
+                    StoreDictionary filteredChild = filterNodeByDictDetail(child, dictDetail);
+                    if (filteredChild != null) {
+                        filteredChildren.add(filteredChild);
+                    }
+                }
+            }
+        }
+        
+        result.setStoreDictionaryList(filteredChildren);
+        
+        // 如果当前节点匹配,或者有子节点,则返回
+        if (dictDetail.equals(node.getDictDetail()) || !filteredChildren.isEmpty()) {
+            return result;
+        }
+        
+        return null;
+    }
+
+    /**
+     * 收集节点及其所有子节点
+     *
+     * @param nodeId 节点ID
+     * @param nodeList 节点列表
+     */
+    private void collectNodeAndChildren(Integer nodeId, List<StoreDictionary> nodeList) {
+        StoreDictionary node = storeDictionaryMapper.selectById(nodeId);
+        if (node == null || node.getDeleteFlag() == 1) {
+            return;
+        }
+        
+        // 检查是否已经添加过(避免重复)
+        boolean alreadyAdded = nodeList.stream().anyMatch(n -> n.getId().equals(nodeId));
+        if (!alreadyAdded) {
+            nodeList.add(node);
+        }
+        
+        // 查询所有子节点
+        LambdaQueryWrapper<StoreDictionary> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.in(StoreDictionary::getTypeName, "report", "report_type", "report_classify");
+        queryWrapper.eq(StoreDictionary::getDeleteFlag, 0);
+        queryWrapper.eq(StoreDictionary::getParentId, nodeId);
+        queryWrapper.orderByAsc(StoreDictionary::getSortId);
+        
+        List<StoreDictionary> children = storeDictionaryMapper.selectList(queryWrapper);
+        
+        if (children != null && !children.isEmpty()) {
+            for (StoreDictionary child : children) {
+                collectNodeAndChildren(child.getId(), nodeList);
+            }
+        }
+    }
+
+    /**
+     * 收集节点及其所有子节点(使用Map去重)
+     *
+     * @param nodeId 节点ID
+     * @param nodeMap 节点Map(用于去重)
+     */
+    private void collectNodeAndChildren(Integer nodeId, Map<Integer, StoreDictionary> nodeMap) {
+        StoreDictionary node = storeDictionaryMapper.selectById(nodeId);
+        if (node == null || node.getDeleteFlag() == 1) {
+            return;
+        }
+        
+        // 添加到Map(自动去重)
+        nodeMap.put(nodeId, node);
+        
+        // 查询所有子节点
+        LambdaQueryWrapper<StoreDictionary> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.in(StoreDictionary::getTypeName, "report", "report_type", "report_classify");
+        queryWrapper.eq(StoreDictionary::getDeleteFlag, 0);
+        queryWrapper.eq(StoreDictionary::getParentId, nodeId);
+        queryWrapper.orderByAsc(StoreDictionary::getSortId);
+        
+        List<StoreDictionary> children = storeDictionaryMapper.selectList(queryWrapper);
+        
+        if (children != null && !children.isEmpty()) {
+            for (StoreDictionary child : children) {
+                collectNodeAndChildren(child.getId(), nodeMap);
+            }
+        }
+    }
+
+    /**
+     * 从节点列表构建树形结构
+     *
+     * @param nodeList 节点列表
+     * @param rootId 根节点ID
+     * @return 根节点
+     */
+    private StoreDictionary buildTreeFromNodeList(List<StoreDictionary> nodeList, Integer rootId) {
+        // 创建ID到节点的映射
+        Map<Integer, StoreDictionary> nodeMap = new HashMap<>();
+        for (StoreDictionary node : nodeList) {
+            nodeMap.put(node.getId(), node);
+            node.setStoreDictionaryList(new ArrayList<>());
+        }
+        
+        // 找到根节点
+        StoreDictionary root = nodeMap.get(rootId);
+        if (root == null) {
+            return null;
+        }
+        
+        // 建立父子关系
+        for (StoreDictionary node : nodeList) {
+            if (node.getId().equals(rootId)) {
+                continue; // 跳过根节点
+            }
+            
+            Integer parentId = node.getParentId();
+            if (parentId != null && parentId != 0) {
+                StoreDictionary parent = nodeMap.get(parentId);
+                if (parent != null) {
+                    parent.getStoreDictionaryList().add(node);
+                }
+            }
+        }
+        
+        // 对子节点列表按sortId排序
+        sortChildren(root);
+        
+        return root;
+    }
+
+    /**
+     * 递归排序子节点
+     *
+     * @param node 节点
+     */
+    private void sortChildren(StoreDictionary node) {
+        if (node == null || node.getStoreDictionaryList() == null) {
+            return;
+        }
+        
+        node.getStoreDictionaryList().sort((a, b) -> {
+            Integer sortIdA = a.getSortId() != null ? a.getSortId() : 0;
+            Integer sortIdB = b.getSortId() != null ? b.getSortId() : 0;
+            return sortIdA.compareTo(sortIdB);
+        });
+        
+        // 递归排序所有子节点
+        for (StoreDictionary child : node.getStoreDictionaryList()) {
+            sortChildren(child);
+        }
+    }
 }
 

+ 260 - 2
alien-store/src/main/java/shop/alien/store/service/impl/FilterConditionServiceImpl.java

@@ -27,8 +27,10 @@ import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * 平台筛选条件管理ServiceImpl
@@ -46,12 +48,20 @@ public class FilterConditionServiceImpl extends ServiceImpl<StoreDictionaryMappe
 
     /**
      * 查询筛选条件(四级树形结构)
+     * 如果传入dictDetail,则查询匹配的记录及其父级和子级树形结构
+     * 如果不传dictDetail,则返回完整的字典库树形结构
      *
+     * @param dictDetail 字典描述(可选),如果传入则根据此参数过滤
      * @return 筛选条件树形结构列表
      */
     @Override
-    public List<StoreDictionary> queryFilterConditionTree() {
-        // 查询所有筛选条件数据
+    public List<StoreDictionary> queryFilterConditionTree(String dictDetail) {
+        // 如果传入了dictDetail,使用过滤逻辑
+        if (StringUtils.isNotBlank(dictDetail)) {
+            return selectDictBydictDetail(dictDetail);
+        }
+        
+        // 否则使用原有逻辑:查询所有筛选条件数据
         LambdaQueryWrapper<StoreDictionary> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.in(StoreDictionary::getTypeName, "filter_condition","filter_condition_type","filter_condition_classify", "filter_condition_timeRange");
         queryWrapper.eq(StoreDictionary::getDeleteFlag, 0);
@@ -61,6 +71,254 @@ public class FilterConditionServiceImpl extends ServiceImpl<StoreDictionaryMappe
         // 构建四级树形结构
         return buildTreeOptimized(filterConditionList);
     }
+    
+    /**
+     * 根据dictDetail查询筛选条件(包含父级或子级树形结构)
+     * 支持查询多个同名数据及其父级和子级
+     *
+     * @param dictDetail 字典描述
+     * @return 筛选条件树形结构列表
+     */
+    private List<StoreDictionary> selectDictBydictDetail(String dictDetail) {
+        if (StringUtils.isBlank(dictDetail)) {
+            throw new IllegalArgumentException("dictDetail不能为空");
+        }
+
+        // 通过dictDetail模糊查询所有匹配的记录(可能有多个同名数据)
+        LambdaQueryWrapper<StoreDictionary> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.in(StoreDictionary::getTypeName, "filter_condition","filter_condition_type","filter_condition_classify", "filter_condition_timeRange");
+        queryWrapper.eq(StoreDictionary::getDeleteFlag, 0);
+        queryWrapper.like(StoreDictionary::getDictDetail, dictDetail);
+        
+        List<StoreDictionary> matchedDicts = storeDictionaryMapper.selectList(queryWrapper);
+        
+        if (matchedDicts == null || matchedDicts.isEmpty()) {
+            log.warn("未找到dictDetail为[{}]的记录", dictDetail);
+            return new ArrayList<>();
+        }
+
+        log.info("找到{}条dictDetail为[{}]的记录", matchedDicts.size(), dictDetail);
+
+        // 用于存储每个根节点对应的所有节点(按根节点分组)
+        Map<Integer, Set<Integer>> rootToNodeIdsMap = new HashMap<>();
+        
+        // 遍历所有匹配的记录,收集相关节点ID
+        for (StoreDictionary currentDict : matchedDicts) {
+            Integer parentId = currentDict.getParentId();
+            Integer rootId;
+            
+            if (parentId != null && parentId != 0) {
+                // 如果有父级,查找根节点
+                rootId = findRootId(currentDict.getId());
+                log.info("记录ID[{}]有父级[{}], 根节点ID[{}]", currentDict.getId(), parentId, rootId);
+                
+                // 收集从根节点到当前节点的路径上的所有节点ID
+                List<Integer> pathNodeIds = new ArrayList<>();
+                collectPathNodes(currentDict.getId(), pathNodeIds);
+                log.info("路径节点IDs: {}", pathNodeIds);
+                
+                // 收集该根节点下的所有相关节点ID(包括路径节点及其所有子节点)
+                Set<Integer> nodeIds = rootToNodeIdsMap.computeIfAbsent(rootId, k -> new HashSet<>());
+                for (Integer nodeId : pathNodeIds) {
+                    nodeIds.add(nodeId);
+                    collectChildrenIds(nodeId, nodeIds);
+                }
+            } else {
+                // 如果没有父级,以当前节点为根
+                rootId = currentDict.getId();
+                log.info("记录ID[{}]没有父级, 作为根节点", currentDict.getId());
+                
+                // 收集该根节点下的所有相关节点ID
+                Set<Integer> nodeIds = rootToNodeIdsMap.computeIfAbsent(rootId, k -> new HashSet<>());
+                nodeIds.add(currentDict.getId());
+                collectChildrenIds(currentDict.getId(), nodeIds);
+            }
+        }
+        
+        // 收集所有需要返回的节点数据
+        Map<Integer, StoreDictionary> allNodeMap = new HashMap<>();
+        for (Set<Integer> nodeIds : rootToNodeIdsMap.values()) {
+            for (Integer nodeId : nodeIds) {
+                if (!allNodeMap.containsKey(nodeId)) {
+                    StoreDictionary node = storeDictionaryMapper.selectById(nodeId);
+                    if (node != null && node.getDeleteFlag() == 0) {
+                        allNodeMap.put(nodeId, node);
+                    }
+                }
+            }
+        }
+        
+        log.info("总共收集到{}个节点", allNodeMap.size());
+        
+        // 构建树形结构,为每个唯一的根节点构建一棵树
+        List<StoreDictionary> resultList = new ArrayList<>();
+        
+        for (Map.Entry<Integer, Set<Integer>> entry : rootToNodeIdsMap.entrySet()) {
+            Integer rootId = entry.getKey();
+            Set<Integer> nodeIds = entry.getValue();
+            
+            log.info("处理根节点[{}], 包含{}个节点", rootId, nodeIds.size());
+            
+            // 从所有节点中筛选出该根节点下的相关节点
+            List<StoreDictionary> relatedNodes = new ArrayList<>();
+            for (Integer nodeId : nodeIds) {
+                StoreDictionary node = allNodeMap.get(nodeId);
+                if (node != null) {
+                    relatedNodes.add(node);
+                }
+            }
+            
+            log.info("根节点[{}]筛选出{}个相关节点", rootId, relatedNodes.size());
+            
+            // 如果找到相关节点,构建树形结构
+            if (!relatedNodes.isEmpty()) {
+                StoreDictionary root = buildTreeFromNodeList(relatedNodes, rootId);
+                if (root != null) {
+                    resultList.add(root);
+                    log.info("成功构建根节点[{}]的树形结构", rootId);
+                } else {
+                    log.warn("构建根节点[{}]的树形结构失败", rootId);
+                }
+            } else {
+                log.warn("根节点[{}]没有相关节点", rootId);
+            }
+        }
+        
+        log.info("最终返回{}棵树", resultList.size());
+        return resultList;
+    }
+    
+    /**
+     * 收集节点的所有子节点ID(递归)
+     *
+     * @param nodeId 节点ID
+     * @param childrenIds 子节点ID集合
+     */
+    private void collectChildrenIds(Integer nodeId, Set<Integer> childrenIds) {
+        LambdaQueryWrapper<StoreDictionary> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.in(StoreDictionary::getTypeName, "filter_condition","filter_condition_type","filter_condition_classify", "filter_condition_timeRange");
+        queryWrapper.eq(StoreDictionary::getDeleteFlag, 0);
+        queryWrapper.eq(StoreDictionary::getParentId, nodeId);
+        
+        List<StoreDictionary> children = storeDictionaryMapper.selectList(queryWrapper);
+        
+        if (children != null && !children.isEmpty()) {
+            for (StoreDictionary child : children) {
+                if (!childrenIds.contains(child.getId())) {
+                    childrenIds.add(child.getId());
+                    collectChildrenIds(child.getId(), childrenIds);
+                }
+            }
+        }
+    }
+
+    /**
+     * 递归查找根节点ID
+     *
+     * @param id 当前节点ID
+     * @return 根节点ID
+     */
+    private Integer findRootId(Integer id) {
+        StoreDictionary dict = storeDictionaryMapper.selectById(id);
+        if (dict == null || dict.getDeleteFlag() == 1) {
+            // 如果节点不存在或已删除,返回当前ID作为根节点
+            return id;
+        }
+        
+        Integer parentId = dict.getParentId();
+        if (parentId == null || parentId == 0) {
+            return id;
+        }
+        
+        return findRootId(parentId);
+    }
+
+    /**
+     * 收集从当前节点到根节点的路径上的所有节点ID
+     *
+     * @param nodeId 当前节点ID
+     * @param pathNodeIds 路径节点ID列表
+     */
+    private void collectPathNodes(Integer nodeId, List<Integer> pathNodeIds) {
+        StoreDictionary dict = storeDictionaryMapper.selectById(nodeId);
+        if (dict == null || dict.getDeleteFlag() == 1) {
+            return;
+        }
+        
+        // 避免重复添加
+        if (!pathNodeIds.contains(nodeId)) {
+            pathNodeIds.add(nodeId);
+        }
+        
+        Integer parentId = dict.getParentId();
+        if (parentId != null && parentId != 0) {
+            collectPathNodes(parentId, pathNodeIds);
+        }
+    }
+
+    /**
+     * 从节点列表构建树形结构
+     *
+     * @param nodeList 节点列表
+     * @param rootId 根节点ID
+     * @return 根节点
+     */
+    private StoreDictionary buildTreeFromNodeList(List<StoreDictionary> nodeList, Integer rootId) {
+        // 创建ID到节点的映射
+        Map<Integer, StoreDictionary> nodeMap = new HashMap<>();
+        for (StoreDictionary node : nodeList) {
+            nodeMap.put(node.getId(), node);
+            node.setStoreDictionaryList(new ArrayList<>());
+        }
+        
+        // 找到根节点
+        StoreDictionary root = nodeMap.get(rootId);
+        if (root == null) {
+            return null;
+        }
+        
+        // 建立父子关系
+        for (StoreDictionary node : nodeList) {
+            if (node.getId().equals(rootId)) {
+                continue; // 跳过根节点
+            }
+            
+            Integer parentId = node.getParentId();
+            if (parentId != null && parentId != 0) {
+                StoreDictionary parent = nodeMap.get(parentId);
+                if (parent != null) {
+                    parent.getStoreDictionaryList().add(node);
+                }
+            }
+        }
+        
+        // 对子节点列表按sortId排序
+        sortChildren(root);
+        
+        return root;
+    }
+
+    /**
+     * 递归排序子节点
+     *
+     * @param node 节点
+     */
+    private void sortChildren(StoreDictionary node) {
+        if (node == null || node.getStoreDictionaryList() == null) {
+            return;
+        }
+        
+        node.getStoreDictionaryList().sort((a, b) -> {
+            Integer sortIdA = a.getSortId() != null ? a.getSortId() : 0;
+            Integer sortIdB = b.getSortId() != null ? b.getSortId() : 0;
+            return sortIdA.compareTo(sortIdB);
+        });
+        
+        // 递归排序所有子节点
+        for (StoreDictionary child : node.getStoreDictionaryList()) {
+            sortChildren(child);
+        }
+    }
 
     /**
      * 构建树形结构(优化版)

+ 260 - 2
alien-store/src/main/java/shop/alien/store/service/impl/PlatformBusinessSectionServiceImpl.java

@@ -26,8 +26,10 @@ import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * 平台经营版块管理ServiceImpl
@@ -45,12 +47,20 @@ public class PlatformBusinessSectionServiceImpl extends ServiceImpl<StoreDiction
 
     /**
      * 查询经营种类(三级树形结构)
+     * 如果传入dictDetail,则查询匹配的记录及其父级和子级树形结构
+     * 如果不传dictDetail,则返回完整的字典库树形结构
      *
+     * @param dictDetail 字典描述(可选),如果传入则根据此参数过滤
      * @return 经营种类树形结构列表
      */
     @Override
-    public List<StoreDictionary> queryBusinessSectionTree() {
-        // 查询所有经营种类数据
+    public List<StoreDictionary> queryBusinessSectionTree(String dictDetail) {
+        // 如果传入了dictDetail,使用过滤逻辑
+        if (StringUtils.isNotBlank(dictDetail)) {
+            return selectDictBydictDetail(dictDetail);
+        }
+        
+        // 否则使用原有逻辑:查询所有经营种类数据
         LambdaQueryWrapper<StoreDictionary> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.in(StoreDictionary::getTypeName, "business_section","business_type","business_classify");
         queryWrapper.eq(StoreDictionary::getDeleteFlag, 0);
@@ -60,6 +70,254 @@ public class PlatformBusinessSectionServiceImpl extends ServiceImpl<StoreDiction
         // 构建三级树形结构
         return buildTreeOptimized(storeDictionaryList);
     }
+    
+    /**
+     * 根据dictDetail查询经营种类(包含父级或子级树形结构)
+     * 支持查询多个同名数据及其父级和子级
+     *
+     * @param dictDetail 字典描述
+     * @return 经营种类树形结构列表
+     */
+    private List<StoreDictionary> selectDictBydictDetail(String dictDetail) {
+        if (StringUtils.isBlank(dictDetail)) {
+            throw new IllegalArgumentException("dictDetail不能为空");
+        }
+
+        // 通过dictDetail模糊查询所有匹配的记录(可能有多个同名数据)
+        LambdaQueryWrapper<StoreDictionary> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.in(StoreDictionary::getTypeName, "business_section","business_type","business_classify");
+        queryWrapper.eq(StoreDictionary::getDeleteFlag, 0);
+        queryWrapper.like(StoreDictionary::getDictDetail, dictDetail);
+        
+        List<StoreDictionary> matchedDicts = storeDictionaryMapper.selectList(queryWrapper);
+        
+        if (matchedDicts == null || matchedDicts.isEmpty()) {
+            log.warn("未找到dictDetail为[{}]的记录", dictDetail);
+            return new ArrayList<>();
+        }
+
+        log.info("找到{}条dictDetail为[{}]的记录", matchedDicts.size(), dictDetail);
+
+        // 用于存储每个根节点对应的所有节点(按根节点分组)
+        Map<Integer, Set<Integer>> rootToNodeIdsMap = new HashMap<>();
+        
+        // 遍历所有匹配的记录,收集相关节点ID
+        for (StoreDictionary currentDict : matchedDicts) {
+            Integer parentId = currentDict.getParentId();
+            Integer rootId;
+            
+            if (parentId != null && parentId != 0) {
+                // 如果有父级,查找根节点
+                rootId = findRootId(currentDict.getId());
+                log.info("记录ID[{}]有父级[{}], 根节点ID[{}]", currentDict.getId(), parentId, rootId);
+                
+                // 收集从根节点到当前节点的路径上的所有节点ID
+                List<Integer> pathNodeIds = new ArrayList<>();
+                collectPathNodes(currentDict.getId(), pathNodeIds);
+                log.info("路径节点IDs: {}", pathNodeIds);
+                
+                // 收集该根节点下的所有相关节点ID(包括路径节点及其所有子节点)
+                Set<Integer> nodeIds = rootToNodeIdsMap.computeIfAbsent(rootId, k -> new HashSet<>());
+                for (Integer nodeId : pathNodeIds) {
+                    nodeIds.add(nodeId);
+                    collectChildrenIds(nodeId, nodeIds);
+                }
+            } else {
+                // 如果没有父级,以当前节点为根
+                rootId = currentDict.getId();
+                log.info("记录ID[{}]没有父级, 作为根节点", currentDict.getId());
+                
+                // 收集该根节点下的所有相关节点ID
+                Set<Integer> nodeIds = rootToNodeIdsMap.computeIfAbsent(rootId, k -> new HashSet<>());
+                nodeIds.add(currentDict.getId());
+                collectChildrenIds(currentDict.getId(), nodeIds);
+            }
+        }
+        
+        // 收集所有需要返回的节点数据
+        Map<Integer, StoreDictionary> allNodeMap = new HashMap<>();
+        for (Set<Integer> nodeIds : rootToNodeIdsMap.values()) {
+            for (Integer nodeId : nodeIds) {
+                if (!allNodeMap.containsKey(nodeId)) {
+                    StoreDictionary node = storeDictionaryMapper.selectById(nodeId);
+                    if (node != null && node.getDeleteFlag() == 0) {
+                        allNodeMap.put(nodeId, node);
+                    }
+                }
+            }
+        }
+        
+        log.info("总共收集到{}个节点", allNodeMap.size());
+        
+        // 构建树形结构,为每个唯一的根节点构建一棵树
+        List<StoreDictionary> resultList = new ArrayList<>();
+        
+        for (Map.Entry<Integer, Set<Integer>> entry : rootToNodeIdsMap.entrySet()) {
+            Integer rootId = entry.getKey();
+            Set<Integer> nodeIds = entry.getValue();
+            
+            log.info("处理根节点[{}], 包含{}个节点", rootId, nodeIds.size());
+            
+            // 从所有节点中筛选出该根节点下的相关节点
+            List<StoreDictionary> relatedNodes = new ArrayList<>();
+            for (Integer nodeId : nodeIds) {
+                StoreDictionary node = allNodeMap.get(nodeId);
+                if (node != null) {
+                    relatedNodes.add(node);
+                }
+            }
+            
+            log.info("根节点[{}]筛选出{}个相关节点", rootId, relatedNodes.size());
+            
+            // 如果找到相关节点,构建树形结构
+            if (!relatedNodes.isEmpty()) {
+                StoreDictionary root = buildTreeFromNodeList(relatedNodes, rootId);
+                if (root != null) {
+                    resultList.add(root);
+                    log.info("成功构建根节点[{}]的树形结构", rootId);
+                } else {
+                    log.warn("构建根节点[{}]的树形结构失败", rootId);
+                }
+            } else {
+                log.warn("根节点[{}]没有相关节点", rootId);
+            }
+        }
+        
+        log.info("最终返回{}棵树", resultList.size());
+        return resultList;
+    }
+    
+    /**
+     * 收集节点的所有子节点ID(递归)
+     *
+     * @param nodeId 节点ID
+     * @param childrenIds 子节点ID集合
+     */
+    private void collectChildrenIds(Integer nodeId, Set<Integer> childrenIds) {
+        LambdaQueryWrapper<StoreDictionary> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.in(StoreDictionary::getTypeName, "business_section","business_type","business_classify");
+        queryWrapper.eq(StoreDictionary::getDeleteFlag, 0);
+        queryWrapper.eq(StoreDictionary::getParentId, nodeId);
+        
+        List<StoreDictionary> children = storeDictionaryMapper.selectList(queryWrapper);
+        
+        if (children != null && !children.isEmpty()) {
+            for (StoreDictionary child : children) {
+                if (!childrenIds.contains(child.getId())) {
+                    childrenIds.add(child.getId());
+                    collectChildrenIds(child.getId(), childrenIds);
+                }
+            }
+        }
+    }
+
+    /**
+     * 递归查找根节点ID
+     *
+     * @param id 当前节点ID
+     * @return 根节点ID
+     */
+    private Integer findRootId(Integer id) {
+        StoreDictionary dict = storeDictionaryMapper.selectById(id);
+        if (dict == null || dict.getDeleteFlag() == 1) {
+            // 如果节点不存在或已删除,返回当前ID作为根节点
+            return id;
+        }
+        
+        Integer parentId = dict.getParentId();
+        if (parentId == null || parentId == 0) {
+            return id;
+        }
+        
+        return findRootId(parentId);
+    }
+
+    /**
+     * 收集从当前节点到根节点的路径上的所有节点ID
+     *
+     * @param nodeId 当前节点ID
+     * @param pathNodeIds 路径节点ID列表
+     */
+    private void collectPathNodes(Integer nodeId, List<Integer> pathNodeIds) {
+        StoreDictionary dict = storeDictionaryMapper.selectById(nodeId);
+        if (dict == null || dict.getDeleteFlag() == 1) {
+            return;
+        }
+        
+        // 避免重复添加
+        if (!pathNodeIds.contains(nodeId)) {
+            pathNodeIds.add(nodeId);
+        }
+        
+        Integer parentId = dict.getParentId();
+        if (parentId != null && parentId != 0) {
+            collectPathNodes(parentId, pathNodeIds);
+        }
+    }
+
+    /**
+     * 从节点列表构建树形结构
+     *
+     * @param nodeList 节点列表
+     * @param rootId 根节点ID
+     * @return 根节点
+     */
+    private StoreDictionary buildTreeFromNodeList(List<StoreDictionary> nodeList, Integer rootId) {
+        // 创建ID到节点的映射
+        Map<Integer, StoreDictionary> nodeMap = new HashMap<>();
+        for (StoreDictionary node : nodeList) {
+            nodeMap.put(node.getId(), node);
+            node.setStoreDictionaryList(new ArrayList<>());
+        }
+        
+        // 找到根节点
+        StoreDictionary root = nodeMap.get(rootId);
+        if (root == null) {
+            return null;
+        }
+        
+        // 建立父子关系
+        for (StoreDictionary node : nodeList) {
+            if (node.getId().equals(rootId)) {
+                continue; // 跳过根节点
+            }
+            
+            Integer parentId = node.getParentId();
+            if (parentId != null && parentId != 0) {
+                StoreDictionary parent = nodeMap.get(parentId);
+                if (parent != null) {
+                    parent.getStoreDictionaryList().add(node);
+                }
+            }
+        }
+        
+        // 对子节点列表按sortId排序
+        sortChildren(root);
+        
+        return root;
+    }
+
+    /**
+     * 递归排序子节点
+     *
+     * @param node 节点
+     */
+    private void sortChildren(StoreDictionary node) {
+        if (node == null || node.getStoreDictionaryList() == null) {
+            return;
+        }
+        
+        node.getStoreDictionaryList().sort((a, b) -> {
+            Integer sortIdA = a.getSortId() != null ? a.getSortId() : 0;
+            Integer sortIdB = b.getSortId() != null ? b.getSortId() : 0;
+            return sortIdA.compareTo(sortIdB);
+        });
+        
+        // 递归排序所有子节点
+        for (StoreDictionary child : node.getStoreDictionaryList()) {
+            sortChildren(child);
+        }
+    }
 
     /**
      * 构建树形结构(优化版)