-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from 2024-TEAM-05/feat/signup
feat: 회원가입 비즈니스 로직 구현
- Loading branch information
Showing
29 changed files
with
528 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/team05/integrated_feed_backend/common/util/VerificationCodeGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package team05.integrated_feed_backend.common.util; | ||
|
||
import java.security.SecureRandom; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public final class VerificationCodeGenerator { | ||
private static final int CODE_LENGTH = 6; | ||
private static final SecureRandom random = new SecureRandom(); | ||
|
||
public static String generateCode() { | ||
StringBuilder codeBuilder = new StringBuilder(); | ||
for (int i = 0; i < CODE_LENGTH; i++) { | ||
int digit = random.nextInt(10); // 0부터 9까지 랜덤한 숫자 선택 | ||
codeBuilder.append(digit); | ||
} | ||
return codeBuilder.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,4 @@ public DataNotFoundException(StatusCode statusCode) { | |
super(statusCode); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,4 @@ public DuplicateResourceException(StatusCode statusCode) { | |
super(statusCode); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,4 @@ public ForbiddenException(StatusCode statusCode) { | |
super(statusCode); | ||
} | ||
|
||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/team05/integrated_feed_backend/infra/mail/MailService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package team05.integrated_feed_backend.infra.mail; | ||
|
||
public interface MailService { | ||
|
||
void sendVerificationCode(String sendTo, String code); | ||
|
||
void send(String sendTo, String subject, String content); | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/team05/integrated_feed_backend/infra/mail/SimpleMailService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package team05.integrated_feed_backend.infra.mail; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Component | ||
@Slf4j | ||
public class SimpleMailService implements MailService { | ||
private static final String VERIFICATION_EMAIL_TITLE = "Integrated Feed 회원가입 인증코드"; | ||
|
||
@Override | ||
public void sendVerificationCode(String sendTo, String code) { | ||
String content = buildVerificationEmailContent(code); | ||
send(sendTo, VERIFICATION_EMAIL_TITLE, content); | ||
} | ||
|
||
@Override | ||
public void send(String sendTo, String subject, String content) { | ||
log.info("Send mail to: {}\nSubject: {}\nContent: {}", sendTo, subject, content); | ||
} | ||
|
||
private String buildVerificationEmailContent(String code) { | ||
return "안녕하세요.\nIntegrated Feed의 이메일 등록을 위한 인증 메일입니다.\n\n인증번호는 " + code + " 입니다."; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...ava/team05/integrated_feed_backend/module/auth/repository/VerificationCodeRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package team05.integrated_feed_backend.module.auth.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import team05.integrated_feed_backend.module.auth.entity.VerificationCode; | ||
|
||
@Repository | ||
public interface VerificationCodeRepository extends JpaRepository<VerificationCode, Long> { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...user/controller/MemberControllerDocs.java → ...mber/controller/MemberControllerDocs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ule/user/dto/request/MemberSignupReq.java → ...e/member/dto/request/MemberSignupReq.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/main/java/team05/integrated_feed_backend/module/member/entity/enums/MemberStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package team05.integrated_feed_backend.module.member.entity.enums; | ||
|
||
public enum MemberStatus { | ||
UNVERIFIED, VERIFIED | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/team05/integrated_feed_backend/module/member/entity/vo/Email.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package team05.integrated_feed_backend.module.member.entity.vo; | ||
|
||
import static team05.integrated_feed_backend.common.code.StatusCode.*; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Embeddable; | ||
import lombok.AccessLevel; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import team05.integrated_feed_backend.exception.custom.BadRequestException; | ||
|
||
@Embeddable | ||
@Getter | ||
@EqualsAndHashCode | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED, force = true) | ||
public class Email { | ||
private static final Pattern EMAIL_PATTERN = Pattern.compile( | ||
"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,6}$"); | ||
|
||
@Column(name = "email", nullable = false, unique = true) | ||
private final String value; | ||
|
||
private Email(String value) { | ||
validate(value); | ||
this.value = value; | ||
} | ||
|
||
public static Email from(String email) { | ||
return new Email(email); | ||
} | ||
|
||
private void validate(String value) { | ||
if (!isValidEmail(value)) { | ||
throw new BadRequestException(INVALID_EMAIL_FORMAT); | ||
} | ||
} | ||
|
||
private boolean isValidEmail(String value) { | ||
return EMAIL_PATTERN.matcher(value).matches(); | ||
} | ||
} |
Oops, something went wrong.