BAEL-7540

This commit is contained in:
reza ganji 2024-04-05 13:24:42 +03:30
parent 2b1ef27527
commit 23f1b4cbf3
1 changed files with 2 additions and 4 deletions

View File

@ -19,16 +19,14 @@ public class UserService {
this.userRepository = userRepository;
}
@GetMapping("/user/{id}")
public Mono<User> getUserByIdThrowingException(@PathVariable String id) {
public Mono<User> getUserByIdThrowingException(String id) {
User user = userRepository.findById(id);
if (user == null)
throw new NotFoundException("User Not Found");
return Mono.justOrEmpty(user);
}
@GetMapping("/user/{id}")
public Mono<User> getUserByIdUsingMonoError(@PathVariable String id) {
public Mono<User> getUserByIdUsingMonoError(String id) {
User user = userRepository.findById(id);
return (user != null) ? Mono.justOrEmpty(user) : Mono.error(new NotFoundException("User Not Found"));