|
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.StopWatch;
|
|
import cn.hutool.core.date.StopWatch;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Maps;
|
|
|
import com.google.common.collect.Sets;
|
|
import com.google.common.collect.Sets;
|
|
@@ -19,8 +20,7 @@ import com.hdkj.lt.core.sys.service.ISysDictService;
|
|
|
import com.hdkj.lt.core.sys.service.ISysStruService;
|
|
import com.hdkj.lt.core.sys.service.ISysStruService;
|
|
|
import com.hdkj.lt.utils.cache.RedisRepository;
|
|
import com.hdkj.lt.utils.cache.RedisRepository;
|
|
|
import com.hdkj.lt.utils.tree.TreeBuilder;
|
|
import com.hdkj.lt.utils.tree.TreeBuilder;
|
|
|
-import com.jxdinfo.hussar.authorization.organ.vo.OrganizationBo;
|
|
|
|
|
-import com.jxdinfo.hussar.support.mp.base.service.impl.HussarServiceImpl;
|
|
|
|
|
|
|
+import com.hdkj.lt.core.sys.model.po.OrganizationBo;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
@@ -40,7 +40,7 @@ import java.util.stream.Collectors;
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@Service
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
|
-public class SysStruServiceImpl extends HussarServiceImpl<SysStruMapper, SysStru> implements ISysStruService {
|
|
|
|
|
|
|
+public class SysStruServiceImpl extends ServiceImpl<SysStruMapper, SysStru> implements ISysStruService {
|
|
|
|
|
|
|
|
private final RedisRepository redisRepository;
|
|
private final RedisRepository redisRepository;
|
|
|
|
|
|
|
@@ -67,15 +67,13 @@ public class SysStruServiceImpl extends HussarServiceImpl<SysStruMapper, SysStru
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- *
|
|
|
|
|
* @author luorui
|
|
* @author luorui
|
|
|
* @date 2025/7/17 11:26
|
|
* @date 2025/7/17 11:26
|
|
|
* @discription 从缓存中取,如果缓存中没有取到则查询数据库刷新全量组织树,并返回查询结果
|
|
* @discription 从缓存中取,如果缓存中没有取到则查询数据库刷新全量组织树,并返回查询结果
|
|
|
- *
|
|
|
|
|
**/
|
|
**/
|
|
|
@Override
|
|
@Override
|
|
|
public StruTreeCacheDTO getStruTreeByCache(@Nonnull Long struId) {
|
|
public StruTreeCacheDTO getStruTreeByCache(@Nonnull Long struId) {
|
|
|
- if(!redisRepository.exists(RedisKeyConstants.CACHE_KEY_STRU_TREE_HASH)){
|
|
|
|
|
|
|
+ if (!redisRepository.exists(RedisKeyConstants.CACHE_KEY_STRU_TREE_HASH)) {
|
|
|
//如果缓存没有加载
|
|
//如果缓存没有加载
|
|
|
Map<Long, StruTreeCacheDTO> treeMap = refreshStruTreeByCache();
|
|
Map<Long, StruTreeCacheDTO> treeMap = refreshStruTreeByCache();
|
|
|
return treeMap.get(struId);
|
|
return treeMap.get(struId);
|
|
@@ -114,10 +112,10 @@ public class SysStruServiceImpl extends HussarServiceImpl<SysStruMapper, SysStru
|
|
|
public Map<Long, StruTreeCacheDTO> getStruFullTree() {
|
|
public Map<Long, StruTreeCacheDTO> getStruFullTree() {
|
|
|
List<SysStru> struList = baseMapper.getStruList();
|
|
List<SysStru> struList = baseMapper.getStruList();
|
|
|
List<StruTreeCacheDTO> struTreeVOList = new ArrayList<>();
|
|
List<StruTreeCacheDTO> struTreeVOList = new ArrayList<>();
|
|
|
- if(CollUtil.isNotEmpty(struList)){
|
|
|
|
|
- struList.forEach(e->{
|
|
|
|
|
|
|
+ if (CollUtil.isNotEmpty(struList)) {
|
|
|
|
|
+ struList.forEach(e -> {
|
|
|
StruTreeCacheDTO struTreeCacheDTO = new StruTreeCacheDTO();
|
|
StruTreeCacheDTO struTreeCacheDTO = new StruTreeCacheDTO();
|
|
|
- BeanUtil.copyProperties(e,struTreeCacheDTO);
|
|
|
|
|
|
|
+ BeanUtil.copyProperties(e, struTreeCacheDTO);
|
|
|
struTreeVOList.add(struTreeCacheDTO);
|
|
struTreeVOList.add(struTreeCacheDTO);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|