update 优化代码写法

This commit is contained in:
疯狂的狮子Li
2026-04-09 17:13:24 +08:00
parent 5483136aec
commit 33c2c1ff49
2 changed files with 7 additions and 4 deletions

View File

@@ -15,7 +15,6 @@ import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.core.utils.TreeBuildUtils;
import org.dromara.system.domain.bo.SysDeptBo;
import org.dromara.system.service.ISysDeptService;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@@ -56,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,11 +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 org.springframework.stereotype.Component;
import java.util.List;
import java.util.Set;
/**
@@ -24,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();
}
}