提交 9429f09a 编写于 作者: zhouweidong's avatar zhouweidong

修复enable=0的资源导致checkKey失败,主键重复的异常

上级 b1a8b732
......@@ -73,9 +73,22 @@ public class SysPSSystemAspect
Set<SysPermission> list = system.getSysstructure().getSysPermissions(PermissionType.OPPRIV);
list.addAll(system.getSysstructure().getSysPermissions(PermissionType.APPMENU));
list.addAll(system.getSysstructure().getSysPermissions(PermissionType.UNIRES));
list.forEach(sysPermission -> delPermission.remove(sysPermission.getPermissionid()));
Set<String> newIds=new HashSet<>();
list.forEach(sysPermission -> {
delPermission.remove(sysPermission.getPermissionid());
newIds.add(sysPermission.getPermissionid());
});
//移除无效资源
sysPermissionService.removeBatch(delPermission.keySet());
//将当前系统本次资源enable设为1以避免enable=0时,导致saveOrUpdate无法检测到主键存在,最终插入数据导致主键重复
sysPermissionService.execute(String.format("update ibzpermission set enable = 1 where sys_permissionid in (%s)",getIds(newIds)),null);
//存储或更新资源saveOrUpdate
sysPermissionService.saveBatch(list);
}
private String getIds(Set<String> newIds) {
String[] strIdArr = newIds.toArray(new String[newIds.size()]);
return "'" + String.join("','", strIdArr) + "'";
}
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册