-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 사용자 회원가입 기능 구현 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
대부분의 엔티티에 공통으로 사용되는 createdAt, updatedAt 필드를 추상 클래스 BaseEntity로 분리하여재사용할 수 있도록 구성했습니다.
회원의 주소 정보를 나타내는 엔티티입니다.
|
|
||
| @Transactional | ||
| public Long signup(UserSignupRequestDto userSignupRequestDto) { | ||
| User user = userMapper.toEntity(userSignupRequestDto); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final User user = userMapper.toEntity(userSignupRequestDto);
| public Long signup(UserSignupRequestDto userSignupRequestDto) { | ||
| User user = userMapper.toEntity(userSignupRequestDto); | ||
| userJpaRepository.findUserByEmail(userSignupRequestDto.email()) | ||
| .ifPresent(u -> { throw new UserDuplicateException(EXCEPTION_USER_DUPLICATE.message()); }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return userJpaRepository.findUserByEmail(userSignupRequestDto.email())
.map(s-> throw new UserDuplicateException(EXCEPTION_USER_DUPLICATE.message()) )
.orElseGet(u -> { User savedUser = userJpaRepository.save(user);
return savedUser.getId();});
|
|
||
| public enum ExceptionMessages { | ||
|
|
||
| EXCEPTION_USER_DUPLICATE("이미 존재하는 회원입니다."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not_found_user
| User user = userMapper.toEntity(userSignupRequestDto); | ||
| userJpaRepository.findUserByEmail(userSignupRequestDto.email()) | ||
| .ifPresent(u -> { throw new UserDuplicateException(EXCEPTION_USER_DUPLICATE.message()); }); | ||
| User savedUser = userJpaRepository.save(user); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try{
User savedUser = userJpaRepository.save(user);
}catch(Exception ex){
logger.error(e.getMessage(), e)
throw e;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try{
String savedUser = json.toString(userJpaRepository.save(user));
return savedUser;
}catch(Exception ex){
logger.info(e.getMessage(), e)
return null;
}
| private final UserService userService; | ||
|
|
||
| @PostMapping | ||
| public ResponseEntity<UserSignupResponseDto> signup(@Valid @RequestBody UserSignupRequestDto request) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public UserSignupResponseDto signup(@Valid @RequestBody UserSignupRequestDto request) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@httpstatus(201)
모든 엔티티가 전부 사용하지 않기때문에, 필드 값으로 따로 명시
작업 내용
UserSignupRequestDto,UserSignupResponseDto구현UserController에 회원가입 API(/api/v1/users) 추가UserService에 회원 저장 로직 구현UserMapper에서 DTO → Entity 변환 및 비밀번호 암호화 처리추가 사항
ValidationMessages로 상수화UserIntegrationTest) 작성 및 성공 검증관련 이슈