diff --git a/be/src/main/java/yeonba/be/login/repository/VerificationCodeQuery.java b/be/src/main/java/yeonba/be/login/repository/VerificationCodeQuery.java new file mode 100644 index 00000000..208f38e0 --- /dev/null +++ b/be/src/main/java/yeonba/be/login/repository/VerificationCodeQuery.java @@ -0,0 +1,20 @@ +package yeonba.be.login.repository; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; +import yeonba.be.exception.GeneralException; +import yeonba.be.exception.LoginException; +import yeonba.be.login.entity.VerificationCode; + +@Component +@RequiredArgsConstructor +public class VerificationCodeQuery { + + private final VerificationCodeRepository verificationCodeRepository; + + public VerificationCode findBy(String phoneNumber, String code) { + + return verificationCodeRepository.findByPhoneNumberAndCode(phoneNumber, code) + .orElseThrow(() -> new GeneralException(LoginException.VERIFICATION_CODE_NOT_FOUND)); + } +}