|
@@ -3,6 +3,7 @@ package com.simuwang.base.components;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.simuwang.base.common.support.dos.OnlyIdNameDO;
|
|
|
+import com.simuwang.base.mapper.system.SysMenuMapper;
|
|
|
import com.simuwang.base.mapper.system.SysRoleMapper;
|
|
|
import com.simuwang.base.mapper.system.SysUserMapper;
|
|
|
import com.simuwang.base.pojo.dos.sys.SysMenuDO;
|
|
@@ -12,6 +13,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author wangzaijun
|
|
@@ -22,10 +24,12 @@ import java.util.Objects;
|
|
|
public class UserAuthService {
|
|
|
private final SysUserMapper userMapper;
|
|
|
private final SysRoleMapper roleMapper;
|
|
|
+ private final SysMenuMapper menuMapper;
|
|
|
|
|
|
- public UserAuthService(SysUserMapper userMapper, SysRoleMapper roleMapper) {
|
|
|
+ public UserAuthService(SysUserMapper userMapper, SysRoleMapper roleMapper, SysMenuMapper menuMapper) {
|
|
|
this.userMapper = userMapper;
|
|
|
this.roleMapper = roleMapper;
|
|
|
+ this.menuMapper = menuMapper;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -102,7 +106,18 @@ public class UserAuthService {
|
|
|
if (adminByRole) {
|
|
|
return this.roleMapper.allPerms();
|
|
|
}
|
|
|
- return this.roleMapper.listAssignPerms(roleId);
|
|
|
+ List<OnlyIdNameDO> dataList = this.roleMapper.listAssignPerms(roleId);
|
|
|
+ // 找到所有父id是上述数据的
|
|
|
+ List<Integer> menuIds = dataList.stream().map(OnlyIdNameDO::getId).distinct().collect(Collectors.toList());
|
|
|
+ LambdaQueryWrapper<SysMenuDO> wrapper = Wrappers.lambdaQuery(SysMenuDO.class)
|
|
|
+ .select(SysMenuDO::getMenuId)
|
|
|
+ .in(SysMenuDO::getParentId, menuIds)
|
|
|
+ .eq(SysMenuDO::getStatus, 1);
|
|
|
+ List<SysMenuDO> tempList = this.menuMapper.selectList(wrapper);
|
|
|
+ // 过滤存在父节点引用的菜单id
|
|
|
+ List<Integer> pids = tempList.stream().map(SysMenuDO::getParentId).distinct().collect(Collectors.toList());
|
|
|
+ dataList.removeIf(e -> pids.contains(e.getId()));
|
|
|
+ return dataList;
|
|
|
}
|
|
|
|
|
|
/**
|