APP菜单权限

This commit is contained in:
秦鸿展
2026-06-29 17:21:09 +08:00
parent d982cc41c3
commit 4afe929020
2 changed files with 48 additions and 8 deletions
@@ -1901,14 +1901,18 @@ public class UserApplicationService {
} catch (Exception e) {
log.warn("同步商城用户失败,但不影响用户保存: {}", e.getMessage());
}
try {
// 截断avatar URLYMS的avatar列长度有限,去掉OSS签名参数)
if (userEntity.getAvatar() != null && userEntity.getAvatar().contains("?")) {
userEntity.setAvatar(userEntity.getAvatar().substring(0, userEntity.getAvatar().indexOf("?")));
// 只有组织开启园区(排队)才同步YMS
Integer isQueue = userMapper.getOrdIsQueue(userEntity.getOrganizationId());
if (isQueue != null && isQueue == 1) {
try {
// 截断avatar URLYMS的avatar列长度有限,去掉OSS签名参数)
if (userEntity.getAvatar() != null && userEntity.getAvatar().contains("?")) {
userEntity.setAvatar(userEntity.getAvatar().substring(0, userEntity.getAvatar().indexOf("?")));
}
ymsDomainService.addOrEditYmsUser(userEntity);
} catch (Exception e) {
log.warn("同步YMS平台员工信息失败,但不影响用户保存: {}", e.getMessage());
}
ymsDomainService.addOrEditYmsUser(userEntity);
} catch (Exception e) {
log.warn("同步YMS平台员工信息失败,但不影响用户保存: {}", e.getMessage());
}
//2024年3月27日16:40:15 处理用户验证码注册,首次登录redis用户数据不更新问题
//此处根据id重新查询
@@ -28,6 +28,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;
@@ -93,8 +94,10 @@ public class AppMenuApplicationService {
appMenuDO.setTopOrganizationId(SecurityUtils.getLoginUser().getUserPo().getTopOrganizationId());
}
List<MenuPo> menuPos = appMenuDomainService.queryMenuListByApp(appMenuDO);
// 车队主管显示订单调度业务主管显示订单审核
// 获取用户角色 查角色APP菜单权限 取交集去重
List<UserRoleMenuPO> userRoles = userFeignService.selectUserRoles(appMenuDO.getUserId());
menuPos = filterMenuByUserRole(menuPos, userRoles);
// 车队主管显示订单调度业务主管显示订单审核
menuPos = filterMenuByRole(menuPos, userRoles);
//判断控制推广码是否显示
if (menuPos != null){
@@ -108,6 +111,39 @@ public class AppMenuApplicationService {
return menuPos;
}
/**
* 在APP配置菜单基础上根据用户角色取集合去除重复菜单
*/
private List<MenuPo> filterMenuByUserRole(List<MenuPo> appMenus, List<UserRoleMenuPO> userRoles) {
if (appMenus == null || appMenus.isEmpty() || userRoles == null || userRoles.isEmpty()) {
return appMenus != null ? appMenus : new ArrayList<>();
}
// 获取用户所有角色ID
List<Long> roleIds = userRoles.stream()
.map(UserRoleMenuPO::getRoleId)
.filter(id -> id != null)
.distinct()
.collect(Collectors.toList());
if (roleIds.isEmpty()) {
return appMenus;
}
// 查询角色对应的APP菜单权限role_menu表中roleMenuClient=2的
R<List<UserRoleMenuPO>> roleMenuR = userServiceFeign.roleAppMenuListByRoleIds(roleIds);
if (R.FAIL == roleMenuR.getCode() || roleMenuR.getData() == null || roleMenuR.getData().isEmpty()) {
return appMenus;
}
// 取角色菜单ID集合
Set<Long> roleMenuIds = roleMenuR.getData().stream()
.map(UserRoleMenuPO::getMenuId)
.filter(id -> id != null)
.collect(Collectors.toSet());
// 过滤只保留APP配置菜单中也在角色权限中的菜单
return appMenus.stream()
.filter(menu -> menu.getMenuId() != null && roleMenuIds.contains(menu.getMenuId()))
.distinct()
.collect(Collectors.toList());
}
/**
* 按角色过滤互斥菜单
* 车队主管隐藏订单审核业务主管隐藏订单调度