bugfix:修复获取登录用户的权限信息接口在没有授权角色时,没有菜单列表导致报错的问题

pull/109/head
lihaiyang 2024-04-10 23:24:26 +08:00
parent 7766c82f6c
commit 39f9fc3ce9
1 changed files with 6 additions and 1 deletions

View File

@ -24,6 +24,7 @@ import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.utils.Lists;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -108,7 +109,11 @@ public class AuthController {
// 1.3 获得菜单列表
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())); // 移除禁用的菜单
// 2. 拼接结果返回