use of com.plumdo.identity.domain.Role 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;
}
use of com.plumdo.identity.domain.Role in project plumdo-work by wengwh.
the class RoleResource method deleteRole.
@DeleteMapping(value = "/roles/{id}")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
@Transactional
public void deleteRole(@PathVariable Integer id) {
Role role = getRoleFromRequest(id);
roleRepository.delete(role);
roleMenuRepository.deleteByRoleId(role.getId());
}
Aggregations