|
|
@@ -1,6 +1,7 @@
|
|
|
package com.xunmei.system.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.alibaba.nacos.common.utils.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
@@ -18,6 +19,7 @@ import com.xunmei.system.api.domain.SysDept;
|
|
|
import com.xunmei.system.api.domain.SysOrg;
|
|
|
import com.xunmei.system.api.domain.SysRole;
|
|
|
import com.xunmei.system.api.domain.SysUser;
|
|
|
+import com.xunmei.system.api.vo.SysOrgVO;
|
|
|
import com.xunmei.system.domain.vo.TreeSelect;
|
|
|
import com.xunmei.system.mapper.SysDeptMapper;
|
|
|
import com.xunmei.system.mapper.SysOrgMapper;
|
|
|
@@ -81,12 +83,14 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|
|
return trees;
|
|
|
}
|
|
|
|
|
|
- public static List<SysOrg> handleTree(Map<Long, List<SysOrg>> map, Long parentId) {
|
|
|
- final List<SysOrg> orgList = map.get(parentId);
|
|
|
+ public static List<SysOrgVO> handleTree(Map<Long, List<SysOrgVO>> map, Long parentId) {
|
|
|
+ final List<SysOrgVO> orgList = map.get(parentId);
|
|
|
if (ObjectUtil.isNotEmpty(orgList)) {
|
|
|
orgList.forEach(org -> {
|
|
|
- final List<SysOrg> tree = handleTree(map, org.getId());
|
|
|
- org.setChildren(tree);
|
|
|
+ final List<SysOrgVO> tree = handleTree(map, org.getId());
|
|
|
+ if (CollectionUtils.isNotEmpty(tree)) {
|
|
|
+ org.setChildren(tree);
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
return orgList;
|
|
|
@@ -108,40 +112,33 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|
|
* @return 部门树信息集合
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<SysOrg> selectDeptTreeList(SysOrg dept) {
|
|
|
+ public List<SysOrgVO> selectDeptTreeList(SysOrg dept) {
|
|
|
Long s = System.currentTimeMillis();
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
SysOrg sysOrg = orgMapper.selectSysOrgByUserId(userId);
|
|
|
if (ObjectUtil.isNull(sysOrg)) {
|
|
|
throw new ServiceException("当前用户没有部门信息");
|
|
|
}
|
|
|
- List<SysOrg> cacheList = null;
|
|
|
+ List<SysOrgVO> cacheList = null;
|
|
|
Boolean isOk = RedisUtils.hasKey(CacheConstants.ORG_CACHE_LIST_KEY);
|
|
|
if (!isOk) {
|
|
|
cacheList = orgService.loadingOrgCache();
|
|
|
} else {
|
|
|
cacheList = RedisUtils.getCacheList(CacheConstants.ORG_CACHE_LIST_KEY);
|
|
|
}
|
|
|
- List<SysOrg> orgs = new ArrayList<>();
|
|
|
- for (SysOrg org : cacheList) {
|
|
|
+ List<SysOrgVO> orgs = new ArrayList<>();
|
|
|
+ for (SysOrgVO org : cacheList) {
|
|
|
String path = org.getPath();
|
|
|
if (StringUtils.isNotEmpty(path) && path.startsWith(sysOrg.getPath())) {
|
|
|
orgs.add(org);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- /*final LambdaQueryWrapper<SysOrg> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(SysOrg::getDeleted, 0);
|
|
|
- wrapper.isNotNull(SysOrg::getParentId);*/
|
|
|
Long parentId = Constants.TOP_ORG_PARENT_ID;
|
|
|
if (ObjectUtil.notEqual(Constants.TOP_ORG_PARENT_ID, sysOrg.getParentId())) {
|
|
|
parentId = sysOrg.getParentId();
|
|
|
- //wrapper.likeRight(SysOrg::getPath, sysOrg.getPath());
|
|
|
}
|
|
|
- /*List<SysOrg> depts = orgMapper.selectList(wrapper);*/
|
|
|
- final Map<Long, List<SysOrg>> collect = orgs.stream().collect(Collectors.groupingBy(SysOrg::getParentId));
|
|
|
- List<SysOrg> r = handleTree(collect, parentId);
|
|
|
- s = System.currentTimeMillis() - s;
|
|
|
+ final Map<Long, List<SysOrgVO>> collect = orgs.stream().collect(Collectors.groupingBy(SysOrgVO::getParentId));
|
|
|
+ List<SysOrgVO> r = handleTree(collect, parentId);
|
|
|
return r;
|
|
|
}
|
|
|
|