@@ -118,7 +118,7 @@ INSERT INTO sys_user_role_permission_relation(role_id, permission_id) VALUES
(3, '3'),
(3, '3.1'),
(3, '3.2'),
- (3, '3.2.1'), (1, '3.2.1.2'), (1, '3.2.2'),
+ (3, '3.2.1'), (3, '3.2.1.2'), (3, '3.2.2'),
(3, '4'),
(3, '4.1'),
(3, '4.1.1'), (3, '4.1.2'), (3, '4.1.3'), (3, '4.1.4'), (3, '4.1.5')
@@ -87,7 +87,14 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleDao, SysUserR
// 判断 modules 是否重复
List<String> permissionIds = sysUserRole.getPermission_ids();
if (CollUtil.isNotEmpty(permissionIds) && permissionIds.size() != CollUtil.distinct(permissionIds).size()) {
- throw new CustException("权限ID出现重复值");
+ // 筛选出重复值
+ Map<String, Integer> countMap = CollUtil.countMap(permissionIds);
+ // 筛选出出现次数大于1的元素
+ List<String> duplicates = new ArrayList<>();
+ for (Map.Entry<String, Integer> entry : countMap.entrySet()) {
+ if (entry.getValue() > 1) duplicates.add(entry.getKey());
+ }
+ throw new CustException("权限ID出现重复值: " + duplicates);
}
SysUserRole detail = sysUserRoleDao.selectById(sysUserRole.getRole_id());