From a181b068247b5c17e20d697aca7e81835251597e Mon Sep 17 00:00:00 2001 From: Vadym Kobelskyi <90138472+VadimasikKPI@users.noreply.github.com> Date: Wed, 22 Nov 2023 10:25:16 +0200 Subject: [PATCH] bug fix (#626) Co-authored-by: VadimasikKPI --- .../softserveinc/dokazovi/controller/UserController.java | 2 +- .../java/com/softserveinc/dokazovi/service/UserService.java | 2 ++ .../softserveinc/dokazovi/service/impl/UserServiceImpl.java | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/softserveinc/dokazovi/controller/UserController.java b/src/main/java/com/softserveinc/dokazovi/controller/UserController.java index d08cdb2a..4167996d 100644 --- a/src/main/java/com/softserveinc/dokazovi/controller/UserController.java +++ b/src/main/java/com/softserveinc/dokazovi/controller/UserController.java @@ -153,7 +153,7 @@ public ResponseEntity getCurrentUser(@AuthenticationPrincipal UserPrinc if (userPrincipal == null) { return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); } - UserDTO userDTO = userService.findExpertById(userPrincipal.getId()); + UserDTO userDTO = userService.findExpertByUserId(userPrincipal.getId()); return ResponseEntity .status((userDTO != null) ? HttpStatus.OK : HttpStatus.NOT_FOUND) .body(userDTO); diff --git a/src/main/java/com/softserveinc/dokazovi/service/UserService.java b/src/main/java/com/softserveinc/dokazovi/service/UserService.java index 0361a37f..7c86c9be 100644 --- a/src/main/java/com/softserveinc/dokazovi/service/UserService.java +++ b/src/main/java/com/softserveinc/dokazovi/service/UserService.java @@ -23,6 +23,8 @@ public interface UserService { UserDTO findExpertById(Integer userId); + UserDTO findExpertByUserId(Integer userId); + Page findAllExperts(UserSearchCriteria userSearchCriteria, Pageable pageable); diff --git a/src/main/java/com/softserveinc/dokazovi/service/impl/UserServiceImpl.java b/src/main/java/com/softserveinc/dokazovi/service/impl/UserServiceImpl.java index bb003896..f7476b04 100644 --- a/src/main/java/com/softserveinc/dokazovi/service/impl/UserServiceImpl.java +++ b/src/main/java/com/softserveinc/dokazovi/service/impl/UserServiceImpl.java @@ -104,6 +104,12 @@ public UserDTO findExpertById(Integer userId) { } + @Override + public UserDTO findExpertByUserId(Integer userId) { + return userMapper.toUserDTO(userRepository.findById(userId).orElseThrow( + () -> new EntityNotFoundException("User not found"))); + } + /** * Gets doctors by search criteria. For example, if directions, regions and user name fields are empty, the * findDoctorsProfiles method without parameters is called