Skip to content

Conversation

@DmK67
Copy link
Owner

@DmK67 DmK67 commented Aug 29, 2023

No description provided.

@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));

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));

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})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CommentNotFoundException, видимо, тоже нужно в обработчик добавить (вообще проще было всего 1 класс исключения сделать NotFoundException и везде его использовать)

@DmK67 DmK67 merged commit 72b8a5a into main Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants