-
Notifications
You must be signed in to change notification settings - Fork 0
Feature comments #5
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
Conversation
| @Transactional | ||
| public CommentResponseDto updateComment(Long userId, Long commentId, NewCommentDto newCommentDto) { | ||
| log.info("Update comment with ID = " + commentId + " from user with ID = " + userId + ": " + newCommentDto); | ||
| userRepository.findById(userId).orElseThrow(() -> new UserNotFoundException(userId)); |
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.
лучше использовать existsById, чтобы не тащить всю сущность из БД
| @Transactional | ||
| public void deleteComment(Long userId, Long commentId) { | ||
| log.info("Delete comment with ID = " + commentId + " from user with ID = " + userId); | ||
| userRepository.findById(userId).orElseThrow(() -> new UserNotFoundException(userId)); |
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.
лучше использовать existsById, чтобы не тащить всю сущность из БД
| UserNotFoundException.class, | ||
| CategoryNotFoundException.class, | ||
| EventNotFoundException.class, | ||
| RequestNotFoundException.class}) |
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.
CommentNotFoundException, видимо, тоже нужно в обработчик добавить (вообще проще было всего 1 класс исключения сделать NotFoundException и везде его использовать)
No description provided.