Пример #1
0
 @PreAuthorize("hasAnyRole('ROLE_ADMIN', 'ROLE_BUILT_IN_ADMIN')")
 @Transactional
 @Override
 public Long add(UserDto userDto) {
   if (userDto == null) {
     throw new IllegalArgumentException("User is null");
   }
   User userEntity = Converter.getEntity(userDto);
   throwExceptionIfBirthNumberExists(userEntity.getBirthNumber());
   return userDao.add(userEntity);
 }
Пример #2
0
 @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);
   }
 }