DmPurtov

Code-review 1

Jan 19th, 2021
526
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @Entity
  2. @Getter
  3. @Setter
  4. @NoArgsConstructor
  5. public class User {
  6.    
  7.     @Id
  8.     @GeneratedValue
  9.     private Long id;
  10.  
  11.     private String name;
  12. }
  13.  
  14. @Service
  15. public class UserService {
  16.  
  17.     @Autowired
  18.     private UserRepository userRepository;
  19.  
  20.     @Transactional
  21.     public void changeName(long id, String name) {
  22.         User user = userRepository.getById(id);
  23.         user.setName(name);
  24.  
  25.         if (StringUtils.isNotEmpty(name)) {
  26.             userRepository.save(user);
  27.         }
  28.     }
  29. }
RAW Paste Data