-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug fixes after 634 #623
Bug fixes after 634 #623
Changes from 35 commits
4d8526a
d31171d
7c207cb
ed3dc02
0e6b784
43a0fd1
231a738
d0ff06e
0ebcae8
5684d57
b456b00
b031d12
c094763
90e229f
fd1d97c
20966d0
799671c
f70ed1d
a0ed96f
f9598a8
3a1b13a
c9742ca
837a7a2
bd2622c
5da6460
89611fa
07fa868
026c6a0
a52eac6
45fc87a
90b15eb
7a77292
7489eb9
938ccf8
626fccf
83a6064
4c4d363
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -97,7 +97,11 @@ public Page<UserEntity> findAll(Pageable pageable) { | |||||
*/ | ||||||
@Override | ||||||
public UserDTO findExpertById(Integer userId) { | ||||||
return userMapper.toUserDTO(userRepository.findById(userId).orElse(null)); | ||||||
AuthorEntity author = authorRepository.findById(userId).orElse(null); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
And you can remove if-statement. |
||||||
if (author == null) { | ||||||
throw new EntityNotFoundException("Author not found"); | ||||||
} | ||||||
return userMapper.toUserDTO(userRepository.findById(author.getProfile().getId()).orElse(null)); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not a good practice to return null value. Try to avoid such cases if possible. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it good to also throw EntityNotFoundException in this case like in previous one to avoid null returning? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's definitely better than returning null. |
||||||
|
||||||
} | ||||||
|
||||||
|
@@ -116,7 +120,7 @@ public UserDTO findExpertById(Integer userId) { | |||||
public Page<UserDTO> findAllExperts(UserSearchCriteria userSearchCriteria, Pageable pageable) { | ||||||
|
||||||
if (validateParameters(userSearchCriteria, HAS_NO_DIRECTIONS, HAS_NO_REGIONS, HAS_NO_USERNAME)) { | ||||||
return userRepository.findAllWithAuthor(pageable).map(userMapper::toUserDTO); | ||||||
return userRepository.findAll(pageable).map(userMapper::toUserDTO); | ||||||
} | ||||||
|
||||||
final String name = userSearchCriteria.getUserName(); | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.