From 9d8b9fabbea813e980d7f8e67ee633a55d205955 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期四, 16 一月 2025 11:50:19 +0800
Subject: [PATCH] update 优化 ws模块替换session的时候关闭session连接
---
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDataScopeServiceImpl.java | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDataScopeServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDataScopeServiceImpl.java
index a31c426..12a5072 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDataScopeServiceImpl.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDataScopeServiceImpl.java
@@ -2,15 +2,17 @@
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
+import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
+import org.dromara.common.core.constant.CacheNames;
import org.dromara.common.core.utils.StreamUtils;
-import org.dromara.common.mybatis.helper.DataBaseHelper;
import org.dromara.system.domain.SysDept;
import org.dromara.system.domain.SysRoleDept;
import org.dromara.system.mapper.SysDeptMapper;
import org.dromara.system.mapper.SysRoleDeptMapper;
import org.dromara.system.service.ISysDataScopeService;
+import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import java.util.List;
@@ -36,8 +38,12 @@
* @param roleId 瑙掕壊Id
* @return 閮ㄩ棬Id缁�
*/
+ @Cacheable(cacheNames = CacheNames.SYS_ROLE_CUSTOM, key = "#roleId", condition = "#roleId != null")
@Override
public String getRoleCustom(Long roleId) {
+ if (ObjectUtil.isNull(roleId)) {
+ return "-1";
+ }
List<SysRoleDept> list = roleDeptMapper.selectList(
new LambdaQueryWrapper<SysRoleDept>()
.select(SysRoleDept::getDeptId)
@@ -45,7 +51,7 @@
if (CollUtil.isNotEmpty(list)) {
return StreamUtils.join(list, rd -> Convert.toStr(rd.getDeptId()));
}
- return null;
+ return "-1";
}
/**
@@ -54,17 +60,19 @@
* @param deptId 閮ㄩ棬Id
* @return 閮ㄩ棬Id缁�
*/
+ @Cacheable(cacheNames = CacheNames.SYS_DEPT_AND_CHILD, key = "#deptId", condition = "#deptId != null")
@Override
public String getDeptAndChild(Long deptId) {
- List<SysDept> deptList = deptMapper.selectList(new LambdaQueryWrapper<SysDept>()
- .select(SysDept::getDeptId)
- .apply(DataBaseHelper.findInSet(deptId, "ancestors")));
+ if (ObjectUtil.isNull(deptId)) {
+ return "-1";
+ }
+ List<SysDept> deptList = deptMapper.selectListByParentId(deptId);
List<Long> ids = StreamUtils.toList(deptList, SysDept::getDeptId);
ids.add(deptId);
if (CollUtil.isNotEmpty(ids)) {
return StreamUtils.join(ids, Convert::toStr);
}
- return null;
+ return "-1";
}
}
--
Gitblit v1.9.3