@Override
public Role update(Role role) {
List<RoleResourcePermission> localResourcePermissions = role.getResourcePermissions();
for (int i = 0, l = localResourcePermissions.size(); i < l; i++) {
RoleResourcePermission localResourcePermission = localResourcePermissions.get(i);
localResourcePermission.setRole(role);
RoleResourcePermission dbResourcePermission = findRoleResourcePermission(localResourcePermission);
if (dbResourcePermission != null) {//出现在先删除再添加的情况
dbResourcePermission.setRole(localResourcePermission.getRole());
dbResourcePermission.setResourceId(localResourcePermission.getResourceId());
dbResourcePermission.setPermissionIds(localResourcePermission.getPermissionIds());
localResourcePermissions.set(i, dbResourcePermission);
}
}
return super.update(role);
}