Skip to content

Commit

Permalink
Merge pull request #102 from dongyeon1031/main
Browse files Browse the repository at this point in the history
refactor: 잘못된 campusNoticeType 요청 시 Exception 처리
  • Loading branch information
TaetaetaE01 authored Aug 15, 2024
2 parents 77f1cf1 + 0dddb02 commit 4796b88
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 @@ -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;
Expand All @@ -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
Expand All @@ -39,6 +41,9 @@ public ResponseEntity<ApiResponse<Page<CampusNotice>>> getCampusNoticeList(@Requ
Page<CampusNotice> 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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", "이메일 인증 코드가 일치하지 않습니다."),
Expand Down

0 comments on commit 4796b88

Please sign in to comment.