From e1c7115d8c08d188f2c6a49fd07ebb8d3de11ed0 Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期二, 14 十二月 2021 12:09:57 +0800
Subject: [PATCH] 升级log4j2到安全版本,防止漏洞风险
---
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java | 35 +++++++++++++++++++++++++++++------
1 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
index 2b081f9..02288c5 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
@@ -11,9 +11,12 @@
import com.ruoyi.common.core.domain.TreeSelect;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysRole;
+import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.text.Convert;
-import com.ruoyi.common.exception.CustomException;
+import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.system.mapper.SysRoleMapper;
import com.ruoyi.system.service.ISysDeptService;
@@ -97,7 +100,7 @@
* @return 閫変腑閮ㄩ棬鍒楄〃
*/
@Override
- public List<Integer> selectDeptListByRoleId(Long roleId)
+ public List<Long> selectDeptListByRoleId(Long roleId)
{
SysRole role = roleMapper.selectRoleById(roleId);
return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly());
@@ -137,7 +140,7 @@
public boolean hasChildByDeptId(Long deptId)
{
int result = deptMapper.hasChildByDeptId(deptId);
- return result > 0 ? true : false;
+ return result > 0;
}
/**
@@ -150,7 +153,7 @@
public boolean checkDeptExistUser(Long deptId)
{
int result = deptMapper.checkDeptExistUser(deptId);
- return result > 0 ? true : false;
+ return result > 0;
}
/**
@@ -172,6 +175,26 @@
}
/**
+ * 鏍¢獙閮ㄩ棬鏄惁鏈夋暟鎹潈闄�
+ *
+ * @param deptId 閮ㄩ棬id
+ */
+ @Override
+ public void checkDeptDataScope(Long deptId)
+ {
+ if (!SysUser.isAdmin(SecurityUtils.getUserId()))
+ {
+ SysDept dept = new SysDept();
+ dept.setDeptId(deptId);
+ List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
+ if (StringUtils.isEmpty(depts))
+ {
+ throw new ServiceException("娌℃湁鏉冮檺璁块棶閮ㄩ棬鏁版嵁锛�");
+ }
+ }
+ }
+
+ /**
* 鏂板淇濆瓨閮ㄩ棬淇℃伅
*
* @param dept 閮ㄩ棬淇℃伅
@@ -184,7 +207,7 @@
// 濡傛灉鐖惰妭鐐逛笉涓烘甯哥姸鎬�,鍒欎笉鍏佽鏂板瀛愯妭鐐�
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus()))
{
- throw new CustomException("閮ㄩ棬鍋滅敤锛屼笉鍏佽鏂板");
+ throw new ServiceException("閮ㄩ棬鍋滅敤锛屼笉鍏佽鏂板");
}
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
return deptMapper.insertDept(dept);
@@ -302,6 +325,6 @@
*/
private boolean hasChild(List<SysDept> list, SysDept t)
{
- return getChildList(list, t).size() > 0 ? true : false;
+ return getChildList(list, t).size() > 0;
}
}
--
Gitblit v1.9.3