From 0dddb0274a966b8bf84c4ef03815da92c7555e03 Mon Sep 17 00:00:00 2001 From: dongyeon1031 Date: Fri, 16 Aug 2024 02:39:41 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EC=9E=98=EB=AA=BB=EB=90=9C=20campu?= =?UTF-8?q?sNoticeType=20=EC=9A=94=EC=B2=AD=20=EC=8B=9C=20Exception=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../campusNotice/controller/CampusNoticeController.java | 5 +++++ .../bigbrotherbe/global/exception/enums/ErrorCode.java | 1 + 2 files changed, 6 insertions(+) diff --git a/src/main/java/com/example/bigbrotherbe/domain/campusNotice/controller/CampusNoticeController.java b/src/main/java/com/example/bigbrotherbe/domain/campusNotice/controller/CampusNoticeController.java index 8dff468..4ddeaff 100644 --- a/src/main/java/com/example/bigbrotherbe/domain/campusNotice/controller/CampusNoticeController.java +++ b/src/main/java/com/example/bigbrotherbe/domain/campusNotice/controller/CampusNoticeController.java @@ -4,6 +4,7 @@ import com.example.bigbrotherbe.domain.campusNotice.entity.CampusNotice; import com.example.bigbrotherbe.domain.campusNotice.entity.CampusNoticeType; import com.example.bigbrotherbe.domain.campusNotice.service.CampusNoticeService; +import com.example.bigbrotherbe.global.exception.BusinessException; import com.example.bigbrotherbe.global.exception.response.ApiResponse; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; @@ -15,6 +16,7 @@ import static com.example.bigbrotherbe.global.constant.Constant.GetContent.PAGE_DEFAULT_VALUE; import static com.example.bigbrotherbe.global.constant.Constant.GetContent.SIZE_DEFAULT_VALUE; +import static com.example.bigbrotherbe.global.exception.enums.ErrorCode.NO_EXIST_CAMPUS_NOTICE_TYPE; import static com.example.bigbrotherbe.global.exception.enums.SuccessCode.SUCCESS; @RestController @@ -39,6 +41,9 @@ public ResponseEntity>> getCampusNoticeList(@Requ Page campusNoticePage; Pageable pageable = PageRequest.of(page, size, Sort.by(Sort.Direction.DESC, "id")); CampusNoticeType campusNoticeType = CampusNoticeType.getTypeByName(campusNoticeTypeString); + if (campusNoticeType == null){ + throw new BusinessException(NO_EXIST_CAMPUS_NOTICE_TYPE); + } if (search != null && !search.isEmpty()) { campusNoticePage = campusNoticeService.searchCampusNotice(campusNoticeType, search, pageable); } else { diff --git a/src/main/java/com/example/bigbrotherbe/global/exception/enums/ErrorCode.java b/src/main/java/com/example/bigbrotherbe/global/exception/enums/ErrorCode.java index 4160955..1a91a6e 100644 --- a/src/main/java/com/example/bigbrotherbe/global/exception/enums/ErrorCode.java +++ b/src/main/java/com/example/bigbrotherbe/global/exception/enums/ErrorCode.java @@ -59,6 +59,7 @@ public enum ErrorCode { NO_EXIST_CAMPUS_NOTICE(HttpStatus.NOT_FOUND, "CAMPUS_NOTICE-002", "존재하지 않는 학교 공지사항 입니다."), FAIL_TO_JSON_PARSING(HttpStatus.BAD_REQUEST, "CAMPUS_NOTICE-003", "공지사항 페이지의 JSON 파싱에 실패하였습니다."), LAMBDA_FUNCTION_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "CAMPUS_NOTICE-004", "AWS Lambda 함수에서 오류가 발생했습니다."), + NO_EXIST_CAMPUS_NOTICE_TYPE(HttpStatus.NOT_FOUND, "CAMPUS_NOTICE-005", "유효하지 않은 학교 공지사항 타입입니다.."), // VERIFICATION MISMATCH_VERIFIED_CODE(HttpStatus.NOT_FOUND, "VERIFICATION-001", "이메일 인증 코드가 일치하지 않습니다."),