@PreAuthorize("hasAnyRole('ROLE_ADMIN', 'ROLE_BUILT_IN_ADMIN')") @Transactional @Override public void delete(UserDto userDto) { User userEntity = Converter.getEntity(userDto); OfficeDto office = officeService.getOffice(userDto.getOfficeDto().getId()); if (office.getManager() != null && office.getManager().getId() == userDto.getId()) { office.setManager(null); officeService.editOffice(office); } userDao.delete(userEntity); }
@PreAuthorize("isAuthenticated()") @Transactional @Override public void edit(UserDto userDto) { if (userDto == null) { throw new IllegalArgumentException("User is null"); } User userEntity = Converter.getEntity(userDto); UserDto persistedUser = get(userDto.getId()); if (userDto.getBirthNumber().equals(persistedUser.getBirthNumber())) { userDao.edit(userEntity); } else { throwExceptionIfBirthNumberExists(userEntity.getBirthNumber()); userDao.edit(userEntity); } }