Skip to content

Commit

Permalink
refactor(#30): SignUpVerification -> Verification 이름 변경
Browse files Browse the repository at this point in the history
- 객체 이름이 너무 길어서 Verification으로 바꿨어요.
  • Loading branch information
cabbage16 committed Nov 27, 2024
1 parent e958773 commit dd4f72b
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.bamdoliro.sinabro.application.user;

import com.bamdoliro.sinabro.domain.user.domain.SignUpVerification;
import com.bamdoliro.sinabro.domain.user.domain.Verification;
import com.bamdoliro.sinabro.infrastructure.mail.MailService;
import com.bamdoliro.sinabro.infrastructure.persistence.user.SignUpVerificationRepository;
import com.bamdoliro.sinabro.infrastructure.persistence.user.VerificationRepository;
import com.bamdoliro.sinabro.presentation.user.dto.request.SendVerificationRequest;
import com.bamdoliro.sinabro.shared.annotation.UseCase;
import lombok.RequiredArgsConstructor;
Expand All @@ -12,15 +12,15 @@
public class SendVerificationUseCase {

private final MailService mailService;
private final SignUpVerificationRepository signUpVerificationRepository;
private final VerificationRepository verificationRepository;

public void execute(SendVerificationRequest request) {
SignUpVerification signUpVerification = new SignUpVerification(request.getEmail());
Verification verification = new Verification(request.getEmail());

String subject = "시나브로 회원가입 인증번호";
String text = String.format(
"[시나브로] 회원가입 인증번호는 [%s]입니다.",
signUpVerification.getCode()
verification.getCode()
);

mailService.execute(
Expand All @@ -29,6 +29,6 @@ public void execute(SendVerificationRequest request) {
text
);

signUpVerificationRepository.save(signUpVerification);
verificationRepository.save(verification);
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.bamdoliro.sinabro.application.user;

import com.bamdoliro.sinabro.domain.user.domain.SignUpVerification;
import com.bamdoliro.sinabro.domain.user.domain.User;
import com.bamdoliro.sinabro.domain.user.domain.Verification;
import com.bamdoliro.sinabro.domain.user.domain.type.Authority;
import com.bamdoliro.sinabro.infrastructure.persistence.user.SignUpVerificationRepository;
import com.bamdoliro.sinabro.infrastructure.persistence.user.UserRepository;
import com.bamdoliro.sinabro.infrastructure.persistence.user.VerificationRepository;
import com.bamdoliro.sinabro.presentation.user.dto.request.SignUpRequest;
import com.bamdoliro.sinabro.shared.annotation.UseCase;
import lombok.RequiredArgsConstructor;
Expand All @@ -15,7 +15,7 @@
public class SignUpUseCase {

private final UserRepository userRepository;
private final SignUpVerificationRepository signUpVerificationRepository;
private final VerificationRepository verificationRepository;

@Transactional
public void execute(SignUpRequest request) {
Expand All @@ -32,17 +32,17 @@ public void execute(SignUpRequest request) {
}

private void validate(SignUpRequest request) {
SignUpVerification signUpVerification = signUpVerificationRepository.findById(request.getEmail())
Verification verification = verificationRepository.findById(request.getEmail())
.orElseThrow(RuntimeException::new);

if (!signUpVerification.getIsVerified()) {
if (!verification.getIsVerified()) {
throw new RuntimeException();
}

if (userRepository.existsByEmail(request.getEmail())) {
throw new RuntimeException();
}

signUpVerificationRepository.delete(signUpVerification);
verificationRepository.delete(verification);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.bamdoliro.sinabro.application.user;

import com.bamdoliro.sinabro.domain.user.domain.SignUpVerification;
import com.bamdoliro.sinabro.domain.user.domain.Verification;
import com.bamdoliro.sinabro.domain.user.exception.VerificationCodeMismatchException;
import com.bamdoliro.sinabro.domain.user.service.VerificationFacade;
import com.bamdoliro.sinabro.infrastructure.persistence.user.SignUpVerificationRepository;
import com.bamdoliro.sinabro.infrastructure.persistence.user.VerificationRepository;
import com.bamdoliro.sinabro.presentation.user.dto.request.VerifyRequest;
import com.bamdoliro.sinabro.shared.annotation.UseCase;
import lombok.RequiredArgsConstructor;
Expand All @@ -13,21 +13,21 @@
@UseCase
public class VerifyUseCase {

private final SignUpVerificationRepository signUpVerificationRepository;
private final VerificationRepository verificationRepository;
private final VerificationFacade verificationFacade;

@Transactional
public void execute(VerifyRequest request) {
SignUpVerification signUpVerification = verificationFacade.getVerification(request.getEmail());
Verification verification = verificationFacade.getVerification(request.getEmail());
System.out.println(request.getCode());
System.out.println(signUpVerification.getCode());
System.out.println(verification.getCode());

if (!signUpVerification.getCode().equals(request.getCode())) {
if (!verification.getCode().equals(request.getCode())) {
throw new VerificationCodeMismatchException();
}

signUpVerificationRepository.updateSignUpVerification(
signUpVerification.getEmail(),
verificationRepository.updateSignUpVerification(
verification.getEmail(),
true
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@RedisHash(value = "signup-verification", timeToLive = 60 * 5)
public class SignUpVerification {
public class Verification {

@Id
private String email;
Expand All @@ -19,7 +19,7 @@ public class SignUpVerification {

private Boolean isVerified;

public SignUpVerification(String email) {
public Verification(String email) {
this.email = email;
this.code = RandomCodeUtil.generate(6);
this.isVerified = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.bamdoliro.sinabro.domain.user.service;

import com.bamdoliro.sinabro.domain.user.domain.SignUpVerification;
import com.bamdoliro.sinabro.domain.user.domain.Verification;
import com.bamdoliro.sinabro.domain.user.exception.VerifyingHasFailedException;
import com.bamdoliro.sinabro.infrastructure.persistence.user.SignUpVerificationRepository;
import com.bamdoliro.sinabro.infrastructure.persistence.user.VerificationRepository;
import com.bamdoliro.sinabro.shared.annotation.UseCase;
import lombok.RequiredArgsConstructor;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -11,11 +11,11 @@
@UseCase
public class VerificationFacade {

private final SignUpVerificationRepository signUpVerificationRepository;
private final VerificationRepository verificationRepository;

@Transactional(readOnly = true)
public SignUpVerification getVerification(String id) {
return signUpVerificationRepository.findById(id)
public Verification getVerification(String id) {
return verificationRepository.findById(id)
.orElseThrow(VerifyingHasFailedException::new);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.bamdoliro.sinabro.infrastructure.persistence.user;

import com.bamdoliro.sinabro.domain.user.domain.SignUpVerification;
import com.bamdoliro.sinabro.domain.user.domain.Verification;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.PartialUpdate;
import org.springframework.data.redis.core.RedisKeyValueTemplate;
Expand All @@ -14,7 +14,7 @@ public class VerificationRedisRepositoryImpl implements VerificationRedisReposit

@Override
public void updateSignUpVerification(String email, boolean verified) {
PartialUpdate<SignUpVerification> update = new PartialUpdate<>(email, SignUpVerification.class)
PartialUpdate<Verification> update = new PartialUpdate<>(email, Verification.class)
.set("isVerified", verified)
.refreshTtl(true);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.bamdoliro.sinabro.infrastructure.persistence.user;

import com.bamdoliro.sinabro.domain.user.domain.Verification;
import org.springframework.data.repository.CrudRepository;

public interface VerificationRepository extends CrudRepository<Verification, String>, VerificationRedisRepository {
}

0 comments on commit dd4f72b

Please sign in to comment.