bugfix:修复获取登录用户的权限信息接口在没有授权角色时,没有菜单列表导致报错的问题
parent
7766c82f6c
commit
39f9fc3ce9
|
|
@ -24,6 +24,7 @@ import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.Parameters;
|
import io.swagger.v3.oas.annotations.Parameters;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.compress.utils.Lists;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
@ -108,7 +109,11 @@ public class AuthController {
|
||||||
|
|
||||||
// 1.3 获得菜单列表
|
// 1.3 获得菜单列表
|
||||||
Set<Long> menuIds = permissionService.getRoleMenuListByRoleId(convertSet(roles, RoleDO::getId));
|
Set<Long> menuIds = permissionService.getRoleMenuListByRoleId(convertSet(roles, RoleDO::getId));
|
||||||
List<MenuDO> menuList = menuService.getMenuList(menuIds);
|
List<MenuDO> menuList = Lists.newArrayList();
|
||||||
|
// menuIds 为空时,会导致MyBatis Plus拼接错误,当前业务也不应该查出数据
|
||||||
|
if (CollUtil.isNotEmpty(menuIds)) {
|
||||||
|
menuList = menuService.getMenuList(menuIds);
|
||||||
|
}
|
||||||
menuList.removeIf(menu -> !CommonStatusEnum.ENABLE.getStatus().equals(menu.getStatus())); // 移除禁用的菜单
|
menuList.removeIf(menu -> !CommonStatusEnum.ENABLE.getStatus().equals(menu.getStatus())); // 移除禁用的菜单
|
||||||
|
|
||||||
// 2. 拼接结果返回
|
// 2. 拼接结果返回
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue