Advertisement
Guest User

Untitled

a guest
Nov 4th, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.37 KB | None | 0 0
  1. @Service
  2. @Transactional
  3. public class UserService {
  4.  
  5.     @Autowired
  6.     private UserRepository userRepository;
  7.    
  8.     @PreAuthorize("#id eq principal or hasRole('ADMIN')")
  9.     public UserDto doStuffWithUser(UUID id) {
  10.         if (!userRepository.existsById(id)) {
  11.             throw new NotFoundException();  // 404    
  12.         }
  13.  
  14.         // do stuff...
  15.     }
  16.  
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement