优化代码

pull/162/head
caohong 4 years ago
parent a30622b460
commit 5f62a8230f

@ -58,11 +58,7 @@ public class SysDeptServiceImpl implements ISysDeptService
public List<SysDept> buildDeptTree(List<SysDept> depts)
{
List<SysDept> returnList = new ArrayList<SysDept>();
List<Long> tempList = new ArrayList<Long>();
for (SysDept dept : depts)
{
tempList.add(dept.getDeptId());
}
List<Long> tempList = depts.stream().map(SysDept::getDeptId).collect(Collectors.toList());
for (SysDept dept : depts)
{
// 如果是顶级节点, 遍历该父节点的所有子节点
@ -139,7 +135,7 @@ public class SysDeptServiceImpl implements ISysDeptService
public boolean hasChildByDeptId(Long deptId)
{
int result = deptMapper.hasChildByDeptId(deptId);
return result > 0 ? true : false;
return result > 0;
}
/**
@ -152,7 +148,7 @@ public class SysDeptServiceImpl implements ISysDeptService
public boolean checkDeptExistUser(Long deptId)
{
int result = deptMapper.checkDeptExistUser(deptId);
return result > 0 ? true : false;
return result > 0;
}
/**
@ -324,6 +320,6 @@ public class SysDeptServiceImpl implements ISysDeptService
*/
private boolean hasChild(List<SysDept> list, SysDept t)
{
return getChildList(list, t).size() > 0 ? true : false;
return getChildList(list, t).size() > 0;
}
}

@ -202,11 +202,7 @@ public class SysMenuServiceImpl implements ISysMenuService
public List<SysMenu> buildMenuTree(List<SysMenu> menus)
{
List<SysMenu> returnList = new ArrayList<SysMenu>();
List<Long> tempList = new ArrayList<Long>();
for (SysMenu dept : menus)
{
tempList.add(dept.getMenuId());
}
List<Long> tempList = menus.stream().map(SysMenu::getMenuId).collect(Collectors.toList());
for (Iterator<SysMenu> iterator = menus.iterator(); iterator.hasNext();)
{
SysMenu menu = (SysMenu) iterator.next();
@ -259,7 +255,7 @@ public class SysMenuServiceImpl implements ISysMenuService
public boolean hasChildByMenuId(Long menuId)
{
int result = menuMapper.hasChildByMenuId(menuId);
return result > 0 ? true : false;
return result > 0;
}
/**
@ -272,7 +268,7 @@ public class SysMenuServiceImpl implements ISysMenuService
public boolean checkMenuExistRole(Long menuId)
{
int result = roleMenuMapper.checkMenuExistRole(menuId);
return result > 0 ? true : false;
return result > 0;
}
/**
@ -458,8 +454,8 @@ public class SysMenuServiceImpl implements ISysMenuService
/**
*
*
* @param list
* @param t
* @param list
* @param t
*/
private void recursionFn(List<SysMenu> list, SysMenu t)
{
@ -504,7 +500,7 @@ public class SysMenuServiceImpl implements ISysMenuService
/**
*
*
* @return
* @return
*/
public String innerLinkReplaceEach(String path)
{

Loading…
Cancel
Save