Commit 2c6a1d8e by 陶光胜

Merge branch 'developer' into 'master'

查询没有权限的操作项列表接口修复

See merge request !23
parents f09b5e5c 06bfb93b
...@@ -1430,12 +1430,62 @@ public class MenuApiServiceImpl implements MenuApiService { ...@@ -1430,12 +1430,62 @@ public class MenuApiServiceImpl implements MenuApiService {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "用户不存在"); return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "用户不存在");
} }
//添加逻辑:如果是超级管理员,直接全部有效,不存在没有权限的操作项 //添加逻辑:如果是超级管理员,过滤部门权限,给出没有权限的操作项
if (tabSysUser.getSuperAdmin().intValue() == 1) { if (tabSysUser.getSuperAdmin().intValue() == 1) {
// //
MenuListQO params = new MenuListQO(); MenuListQO params = new MenuListQO();
List<TabSysMenu> adminMenuList = filterOperationUserDepartAuth(menuService.listMenu(params), tabSysUser); //操作项
return ServiceResponse.success(EntityUtil.changeEntityListNew(MenuDTO.class, adminMenuList)); params.setMenuType(2);
List<TabSysMenu> allOper = menuService.listMenu(params);
if (tabSysUser != null && tabSysUser.getLoginType().intValue() != 0) {
//运营人员的部门职位;根据手机号查询运维人员的部门职位信息
GicUserDTO gicUserDTO = gicUserService.getUserByMobile(tabSysUser.getPhoneNumber());
LOGGER.info("运维人员的部门职位数据:{}", JSON.toJSONString(gicUserDTO));
//如果是运营人员
Set<String> departPosition = new HashSet<>(2);
String departmentCode = gicUserDTO.getDepartmentCode();
if (StringUtils.isNotBlank(departmentCode)) {
if (StringUtils.isBlank(gicUserDTO.getPositionCode())) {
//如果职位code是空,则取下面全部的职位code
List<GicDepartmentDTO> gicDepartmentDTOList = gicDepartmentService.listAllGicDepartment();
if (CollectionUtils.isNotEmpty(gicDepartmentDTOList)) {
Map<String, List<GicPositionDTO>> departMap = gicDepartmentDTOList
.stream()
.collect(Collectors.toMap(e -> e.getDepartmentCode(), e -> e.getPositionList()));
List<GicPositionDTO> positionList = departMap.get(departmentCode);
if (CollectionUtils.isNotEmpty(positionList)) {
positionList.forEach(e -> {
departPosition.add(departmentCode + "-" + e.getPositionCode());
});
}
}
} else {
departPosition.add(departmentCode + "-" + gicUserDTO.getPositionCode());
}
}
//过滤运营人员的部门职位权限
Map<String, List<TabSysMenuAuthDepart>> departMap = getAuthDepartMap(null);
return ServiceResponse.success(EntityUtil.changeEntityListNew(MenuDTO.class, allOper.stream().filter(e -> {
if (e.getAuthType().intValue() == 1) {
//普通管理员的都有效,不需要判断部门职位
return false;
}
List<TabSysMenuAuthDepart> authList = departMap.get(e.getMenuCode());
if (authList == null) {
//如果是空的,说明是全部权限
return false;
}
//验证departPosition是否存在一个于authList中
if (authList.stream().anyMatch(auth -> departPosition.contains(auth.getDepartCode() + "-" + auth.getPositionCode()))) {
return false;
}
return true;
}).collect(Collectors.toList())));
} else if (tabSysUser != null && tabSysUser.getSuperAdmin().intValue() == 1) {
//超级管理员
return ServiceResponse.success(EntityUtil.changeEntityListNew(MenuDTO.class,allOper.stream().filter(e -> e.getAuthType().intValue() == 3).collect(Collectors.toList())));
}
} }
//用户拥有的菜单权限 //用户拥有的菜单权限
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment