issue # 회원 가입 로직 구현 중

This commit is contained in:
민건희
2025-11-03 22:19:00 +09:00
parent 68b7d5a23f
commit cfb0e622ea
9 changed files with 41 additions and 20 deletions

View File

@@ -1,3 +1,5 @@
package com.baekyangdan.scheduler.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import lombok.Getter;

View File

@@ -1,23 +1,42 @@
package com.baekyangdan.scheduler.controller.user;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baekyangdan.scheduler.repository.user.UserRepository;
import com.baekyangdan.scheduler.request.user.UserRequest;
import com.baekyangdan.scheduler.service.user.UserService;
import com.baekyangdan.scheduler.utils.converter.PasswordConverter;
@RestController
@RequestMapping("/user")
public class UserController {
private final UserService userService;
public UserController(UserService userService) {
this.userService = userService;
}
@PostMapping("/signup")
public ResponseEntity<String> signUp(@RequestBody UserRequest.SignUp body) {
System.out.println("test5");
return new ResponseEntity<String>("테스트", HttpStatus.OK);
try {
userService.signUp(body);
return new ResponseEntity<String> ("회원가입 완료", HttpStatus.OK);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return new ResponseEntity<String> (e.getMessage(), HttpStatus.BAD_REQUEST);
}
}
}

View File

@@ -1,12 +1,11 @@
package com.baekyangdan.scheduler.repository.user;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.query.Param;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

View File

@@ -1,5 +1,6 @@
package com.baekyangdan.scheduler.service.user;
import com.baekyangdan.scheduler.entity.user.UserEntity;
import com.baekyangdan.scheduler.repository.user.UserRepository;
import com.baekyangdan.scheduler.request.user.UserRequest;
import com.baekyangdan.scheduler.utils.converter.PasswordConverter;
@@ -14,7 +15,7 @@ public class UserService {
private final UserRepository userRepository;
private final PasswordConverter passwordConverter;
public UserService(UserRepository userRepository, passwordConverter passwordConverter) {
public UserService(UserRepository userRepository, PasswordConverter passwordConverter) {
this.userRepository = userRepository;
this.passwordConverter = passwordConverter;
}
@@ -40,6 +41,6 @@ public class UserService {
.build();
// 4. build 된 entity를 UserRepository.save 로 DB에 저장
return userRepositry.save(user);
return userRepository.save(user);
}
}

View File

@@ -30,7 +30,7 @@ public class PasswordGenerator {
Collections.shuffle(passwordCharacters, random);
StringBuilder sb = new StringBulilder(length);
StringBuilder sb = new StringBuilder(length);
for (char c : passwordCharacters) {
sb.append(c);

View File

@@ -1,24 +1,23 @@
package com.baekyangdan.scheduler.utils.validation;
import jaav.util.regex.Pattern;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class BaseValidation {
private final Pattern emailPattern = Pattern.compile("^[A-Za-z0-9+_.-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{1,}$");
private final Pattern phoneNumberPattern = Pattern.compile("^010-\d{4}-\d{4}$");
private final static Pattern emailPattern = Pattern.compile("^[A-Za-z0-9+_.-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{1,}$");
private final static Pattern phoneNumberPattern = Pattern.compile("^010-\\d{4}-\\d{4}$");
protected static boolean matchEmailPattern(String email) {
if (validateStringEmpty()) {
if (validateStringEmpty(email)) {
return false;
}
return emailPattern.matcher(email);
return emailPattern.matcher(email).matches();
}
protected static boolean matchPhoneNumberPattern(String phoneNumber) {
if (validateStringEmpty()) {
if (validateStringEmpty(phoneNumber)) {
return false;
}
return phoneNumberPattern.matcher(phoneNumber);
return phoneNumberPattern.matcher(phoneNumber).matches();
}
protected static boolean validateStringEmpty(String value) {

View File

@@ -19,15 +19,15 @@ public class UserValidation extends BaseValidation {
throw new Exception(SignUpValidationCode.EMAIL_EMPTY.getMessage());
}
if (validationStringEmpty(data.getPassword())) {
if (validateStringEmpty(data.getPassword())) {
throw new Exception(SignUpValidationCode.PASSWORD_EMPTY.getMessage());
}
if (validationStringEmpty(data.getName())) {
if (validateStringEmpty(data.getName())) {
throw new Exception(SignUpValidationCode.NAME_EMPTY.getMessage());
}
if (validationStringEmpty(data.getNickname())) {
if (validateStringEmpty(data.getNickname())) {
throw new Exception(SignUpValidationCode.NICKNAME_EMPTY.getMessage());
}

View File

@@ -3,7 +3,7 @@ spring.profiles.active=local
spring.mail.host=smtp.google.com
spring.mail.port=587
spring.mail.username=baekyangdan@gmail.com
spring.mail.username=bkd.scheduler@gmail.com
spring.mail.protocol=smtp
spring.mail.clientId=688417162908-iqvnj4ceb8t1dkbjr70dtcafo27m8kqe.apps.googleusercontent.com