Skip to content

Conversation

@sangyunpark99
Copy link
Collaborator

작업 내용

  • UserSignupRequestDto, UserSignupResponseDto 구현
  • UserController에 회원가입 API(/api/v1/users) 추가
  • UserService에 회원 저장 로직 구현
  • UserMapper에서 DTO → Entity 변환 및 비밀번호 암호화 처리
  • 회원가입 성공 시 응답 메시지와 사용자 ID 반환

추가 사항

  • 유효성 검증 메시지를 ValidationMessages로 상수화
  • 통합 테스트(UserIntegrationTest) 작성 및 성공 검증
  • 단위 테스트 작성 및 성공 검증
  • POSTMAN API 테스트 성공 검증

관련 이슈

대부분의 엔티티에 공통으로 사용되는 createdAt, updatedAt 필드를 추상 클래스 BaseEntity로 분리하여재사용할 수 있도록 구성했습니다.
회원의 주소 정보를 나타내는 엔티티입니다.

@Transactional
public Long signup(UserSignupRequestDto userSignupRequestDto) {
User user = userMapper.toEntity(userSignupRequestDto);
Copy link
Collaborator

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()); });
Copy link
Collaborator

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("이미 존재하는 회원입니다.");
Copy link
Collaborator

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);
Copy link
Collaborator

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;
}

Copy link
Collaborator

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) {
Copy link
Collaborator

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) {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

모든 엔티티가 전부 사용하지 않기때문에, 필드 값으로 따로 명시
@sangyunpark99 sangyunpark99 merged commit 3a570c5 into develop Apr 4, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants