非超管获取菜单权限没有机构限制问题修复

This commit is contained in:
gaoqr
2024-06-24 11:58:44 +08:00
parent 51a7144d21
commit e568392eee
3 changed files with 15 additions and 7 deletions
@@ -8,7 +8,6 @@ import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.framework.operatelog.core.annotations.OperateLog; import com.cf.imes.framework.operatelog.core.annotations.OperateLog;
import com.cf.imes.framework.security.config.SecurityProperties; import com.cf.imes.framework.security.config.SecurityProperties;
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils; import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
import com.cf.imes.module.system.controller.admin.auth.vo.*;
import com.cf.imes.module.system.controller.admin.auth.vo.AuthLoginReqVO; import com.cf.imes.module.system.controller.admin.auth.vo.AuthLoginReqVO;
import com.cf.imes.module.system.controller.admin.auth.vo.AuthPermissionInfoRespVO; import com.cf.imes.module.system.controller.admin.auth.vo.AuthPermissionInfoRespVO;
import com.cf.imes.module.system.controller.admin.auth.vo.AuthSocialLoginReqVO; import com.cf.imes.module.system.controller.admin.auth.vo.AuthSocialLoginReqVO;
@@ -118,9 +117,7 @@ public class AuthController {
roles.removeIf(role -> !CommonStatusEnum.ENABLE.getStatus().equals(role.getStatus())); // 移除禁用的角色 roles.removeIf(role -> !CommonStatusEnum.ENABLE.getStatus().equals(role.getStatus())); // 移除禁用的角色
// 1.3 获得菜单列表 // 1.3 获得菜单列表
//Set<Long> menuIds = permissionService.getRoleMenuListByRoleId(convertSet(roles, RoleDO::getId));
Set<Long> menuIds = permissionService.getRoleMenuListByRoleId2(convertSet(roles, RoleDO::getId)); Set<Long> menuIds = permissionService.getRoleMenuListByRoleId2(convertSet(roles, RoleDO::getId));
//List<MenuDO> menuList = menuService.getMenuList(menuIds);
List<MenuDO> menuList = menuService.getMenuList1(menuIds); List<MenuDO> menuList = menuService.getMenuList1(menuIds);
menuList.removeIf(menu -> !CommonStatusEnum.ENABLE.getStatus().equals(menu.getStatus())); // 移除禁用的菜单 menuList.removeIf(menu -> !CommonStatusEnum.ENABLE.getStatus().equals(menu.getStatus())); // 移除禁用的菜单
@@ -23,6 +23,19 @@ public interface RoleMenuMapper extends BaseMapperX<RoleMenuDO> {
return selectList(RoleMenuDO::getRoleId, roleIds); return selectList(RoleMenuDO::getRoleId, roleIds);
} }
/**
* 基于角色id列表和组织id查询角色菜单列表
*
* @param roleIds
* @param organId
* @return
*/
default List<RoleMenuDO> selectListByRoleIdsAndOrganId(Collection<Long> roleIds, Long organId) {
return selectList(new LambdaQueryWrapperX<RoleMenuDO>()
.eq(RoleMenuDO::getOrganId, organId)
.in(RoleMenuDO::getRoleId, roleIds));
}
default List<RoleMenuDO> selectListByMenuId(Long menuId) { default List<RoleMenuDO> selectListByMenuId(Long menuId) {
return selectList(RoleMenuDO::getMenuId, menuId); return selectList(RoleMenuDO::getMenuId, menuId);
} }
@@ -43,8 +56,6 @@ public interface RoleMenuMapper extends BaseMapperX<RoleMenuDO> {
@OrganIgnore @OrganIgnore
default List<RoleMenuDO> selectListByRoleIdWithOrganAdmin(Collection<Long> roleIds) { default List<RoleMenuDO> selectListByRoleIdWithOrganAdmin(Collection<Long> roleIds) {
return selectList(new LambdaQueryWrapperX<RoleMenuDO>() return selectListByRoleIdsAndOrganId(roleIds, InternalRoleConstants.INTERNAL_ROLE_ORGAN_ID);
.eq(RoleMenuDO::getOrganId, InternalRoleConstants.INTERNAL_ROLE_ORGAN_ID)
.in(RoleMenuDO::getRoleId, roleIds));
} }
} }
@@ -265,7 +265,7 @@ public class PermissionServiceImpl implements PermissionService {
return convertSet(menuService.getMenuList(), MenuDO::getId); return convertSet(menuService.getMenuList(), MenuDO::getId);
} }
// 如果是非管理员的情况下,获得拥有的菜单编号 // 如果是非管理员的情况下,获得拥有的菜单编号
List<RoleMenuDO> from = roleMenuMapper.selectListByRoleId(roleIds); List<RoleMenuDO> from = roleMenuMapper.selectListByRoleIdsAndOrganId(roleIds, OrganContextHolder.getOrganId());
return convertSet(from, RoleMenuDO::getMenuId); return convertSet(from, RoleMenuDO::getMenuId);
} }