use of com.plumdo.identity.domain.RoleMenu in project plumdo-work by wengwh.
the class RoleResource method saveRoleAndMenu.
private Role saveRoleAndMenu(Role role, ObjectMap roleRequest) {
if (role == null) {
role = new Role();
}
role.setName(roleRequest.getAsString("name"));
role.setRemark(roleRequest.getAsString("remark"));
role.setTenantId(roleRequest.getAsString("tenantId"));
roleRepository.save(role);
roleMenuRepository.deleteByRoleId(role.getId());
List<ObjectMap> menus = roleRequest.getAsList("roleMenus");
for (ObjectMap menu : menus) {
RoleMenu roleMenu = new RoleMenu();
roleMenu.setMenuId(menu.getAsInteger("id"));
roleMenu.setRoleId(role.getId());
roleMenuRepository.save(roleMenu);
}
return role;
}