From ead2951ae30f6e42a25aef2d57f080dec439b913 Mon Sep 17 00:00:00 2001 From: RyuKwanKon Date: Mon, 1 Apr 2024 14:37:19 +0900 Subject: [PATCH] =?UTF-8?q?[feat]=20#71=20=EB=93=B1=EB=A1=9D=EB=90=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EC=9D=80=20=EC=8A=A4=ED=81=AC=EB=9E=A9=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=EC=8B=9C=20=EC=98=88=EC=99=B8=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachon/checkmate/domain/scrap/service/ScrapService.java | 5 +++++ .../java/org/gachon/checkmate/global/error/ErrorCode.java | 1 + 2 files changed, 6 insertions(+) diff --git a/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java b/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java index e161cde..8a1ba68 100644 --- a/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java +++ b/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java @@ -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); } diff --git a/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java b/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java index 25abe6c..035e5d9 100644 --- a/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java +++ b/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java @@ -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