update 优化代码写法

This commit is contained in:
疯狂的狮子Li
2026-04-09 17:12:46 +08:00
parent b019a95bbe
commit 78a06c8c9f
2 changed files with 7 additions and 2 deletions

View File

@@ -55,7 +55,7 @@ public class DeptExcelConverter implements Converter<Long> {
/**
* 构建部门路径 → 树节点映射,供 Converter 和 Options 共用
*/
static Map<String, Tree<Long>> buildDeptPathMap(ISysDeptService deptService) {
private Map<String, Tree<Long>> buildDeptPathMap(ISysDeptService deptService) {
return TreeBuildUtils.buildTreeNodeMap(
deptService.selectDeptTreeList(new SysDeptBo()),
"/",

View File

@@ -1,10 +1,14 @@
package org.dromara.system.listener;
import cn.hutool.core.lang.tree.Tree;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.utils.SpringUtils;
import org.dromara.common.core.utils.TreeBuildUtils;
import org.dromara.common.excel.core.ExcelOptionsProvider;
import org.dromara.system.domain.bo.SysDeptBo;
import org.dromara.system.service.ISysDeptService;
import java.util.List;
import java.util.Set;
/**
@@ -23,7 +27,8 @@ public class DeptExcelOptions implements ExcelOptionsProvider {
@Override
public Set<String> getOptions() {
ISysDeptService deptService = SpringUtils.getBean(ISysDeptService.class);
return DeptExcelConverter.buildDeptPathMap(deptService).keySet();
List<Tree<Long>> trees = deptService.selectDeptTreeList(new SysDeptBo());
return TreeBuildUtils.buildTreeNodeMap(trees, "/", Tree::getName).keySet();
}
}