From c99eb98001e22f671ce514268231edcd27fc73ef Mon Sep 17 00:00:00 2001
From: 稚屿 <1491182878@qq.com>
Date: Wed, 09 Feb 2022 09:10:50 +0800
Subject: [PATCH] 代码优化
---
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java | 15 ++++++---------
1 files changed, 6 insertions(+), 9 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 a2c3b5b..70e794a 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
@@ -63,12 +63,9 @@
{
tempList.add(dept.getDeptId());
}
- for (Iterator<SysDept> iterator = depts.iterator(); iterator.hasNext();)
- {
- SysDept dept = (SysDept) iterator.next();
+ for (SysDept dept : depts) {
// 如果是顶级节点, 遍历该父节点的所有子节点
- if (!tempList.contains(dept.getParentId()))
- {
+ if (!tempList.contains(dept.getParentId())) {
recursionFn(depts, dept);
returnList.add(dept);
}
@@ -100,7 +97,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());
@@ -140,7 +137,7 @@
public boolean hasChildByDeptId(Long deptId)
{
int result = deptMapper.hasChildByDeptId(deptId);
- return result > 0 ? true : false;
+ return result > 0;
}
/**
@@ -153,7 +150,7 @@
public boolean checkDeptExistUser(Long deptId)
{
int result = deptMapper.checkDeptExistUser(deptId);
- return result > 0 ? true : false;
+ return result > 0;
}
/**
@@ -325,6 +322,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.2