diff --git a/backend/src/main/java/com/coffee/backend/domain/match/service/MatchService.java b/backend/src/main/java/com/coffee/backend/domain/match/service/MatchService.java index 8df37ecbc0..7d78ee03b3 100644 --- a/backend/src/main/java/com/coffee/backend/domain/match/service/MatchService.java +++ b/backend/src/main/java/com/coffee/backend/domain/match/service/MatchService.java @@ -216,6 +216,10 @@ public Boolean isMatching(MatchIdDto dto) { @Transactional public Review saveReview(ReviewDto dto) { + if (dto.getRating() < 1 || dto.getRating() > 5) { + throw new CustomException(ErrorCode.VALUE_ERROR); + } + User sender = userRepository.findByUserId(dto.getSenderId()).orElseThrow(); User receiver = userRepository.findByUserId(dto.getReceiverId()).orElseThrow(); diff --git a/backend/src/main/java/com/coffee/backend/exception/ErrorCode.java b/backend/src/main/java/com/coffee/backend/exception/ErrorCode.java index 03697c834b..f543222ad6 100644 --- a/backend/src/main/java/com/coffee/backend/exception/ErrorCode.java +++ b/backend/src/main/java/com/coffee/backend/exception/ErrorCode.java @@ -26,7 +26,9 @@ public enum ErrorCode { REQUEST_NOT_FOUND(HttpStatus.NOT_FOUND, "7404", "해당 요청 정보를 찾을 수 없습니다."), REQUEST_EXPIRED(HttpStatus.UNAUTHORIZED, "7401", "요청이 만료되었습니다."), - COMPANY_NOT_FOUND(HttpStatus.NOT_FOUND, "8404", "해당 COMPANY를 찾을 수 없습니다."); + COMPANY_NOT_FOUND(HttpStatus.NOT_FOUND, "8404", "해당 COMPANY를 찾을 수 없습니다."), + + VALUE_ERROR(HttpStatus.BAD_REQUEST, "9400", "잘못된 값이 입력되었습니다."); private final HttpStatus status; private final String code;