Skip to content

Commit

Permalink
[feat] #71 등록되지 않은 스크랩 삭제시 예외 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
RyuKwanKon committed Apr 1, 2024
1 parent b8404c5 commit ead2951
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ private void validateDuplicateScrap(Long postId, Long userId) {
throw new ConflictException(DUPLICATE_SCRAP);
}

private void validateExistScrap(Long postId, Long userId) {
if(!existPostInScrap(postId, userId))
throw new InvalidValueException();
}

private boolean existPostInScrap(Long postId, Long userId) {
return scrapRepository.existsByPostIdAndUserId(postId, userId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public enum ErrorCode {
INVALID_PASSWORD(HttpStatus.BAD_REQUEST, "비밀번호는 8~20자 대소문자 영문, 숫자, 특수문자의 조합이어야 합니다."),
INVALID_POST_TITLE(HttpStatus.BAD_REQUEST, "이미 존재하는 게시물입니다."),
INVALID_POST_DATE(HttpStatus.BAD_REQUEST, "마감시간이 지난 게시물입니다."),
INVALID_DELETE_SCRAP(HttpStatus.BAD_REQUEST, "등록되지 않은 스크랩입니다."),

/**
* 401 Unauthorized
Expand Down

0 comments on commit ead2951

Please sign in to comment.