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", "이메일 인증 코드가 일치하지 않습니다."),