Skip to content

Commit

Permalink
[refactor] : 검증 로직 함수 추출
Browse files Browse the repository at this point in the history
  • Loading branch information
hyun2371 committed Jan 14, 2025
1 parent 281855c commit a672fd5
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,17 @@ public void rejectChatAuto(LocalDateTime now) {
}

private void validateChatAnswerer(Long questionPostId, Long inquirerId, Member answerer) {
validateIfAnswererExists(questionPostId, answerer);
validateIfNotSelfInquiry(inquirerId, answerer);
}

private void validateIfAnswererExists(Long questionPostId, Member answerer) {
if (!answerRepository.existsByQuestionPostIdAndMember(questionPostId, answerer)) {
throw new ValidationException(ChatInquiryErrorCode.NOT_EXISTS_ANSWERER);
}
}

private void validateIfNotSelfInquiry(Long inquirerId, Member answerer) {
if (Objects.equals(answerer.getId(), inquirerId)) {
throw new ValidationException(ChatInquiryErrorCode.SELF_INQUIRY_NOT_ALLOWED);
}
Expand Down

0 comments on commit a672fd5

Please sign in to comment.