Skip to content
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

[FEAT] 본인 프로필 수정 기능 구현 #131

Merged
merged 19 commits into from
Aug 8, 2024
Merged

[FEAT] 본인 프로필 수정 기능 구현 #131

merged 19 commits into from
Aug 8, 2024

Conversation

Kim-TaeUk
Copy link
Contributor

Related Issue

Key Changes

  • 본인 프로필을 수정하는 API입니다.
  • avatarId, nickname, intro, genrePreferences를 프로퍼티로 받는데, 스펙이 PATCH이기 때문에 List 타입인 genrePreferences 제외하고는 null을 허용하도록 했습니다.
    • avatarId, nickname, intro
      • 기존에 설정되어 있는 값과 동일한지 검증합니다.
      • 제네릭을 사용하여 검증 메서드로 분리했습니다. (checkIfAlreadySetOrThrow())
      • nickname을 검증하는 NicknameConstraint는 null check를 하기 때문에 NullAllowedNicknameConstraint를 정의했습니다.
      • -> null인 경우(변경하지 않으니 프로퍼티를 보내지 않을 때)는 valid하도록, null이 아닌 경우(변경하기 위해 프로퍼티를 보낼 때)는 NicknameConstraint의 validator인 NicknameValidator에 validation을 위임합니다.
    • genrePreferences
      • 기존에 설정되어 있는 값과 동일한지 검증하지 않고, 변경하고자 하는 genre들을 모두 받습니다.
      • 기존 값 deleteAll, 변경하고자 하는 값 saveAll로 작동합니다.

Patch이기 때문에 Null check 후 set
avatarId
nickname - @NicknameConstraint로 validate
intro - @SiZe로 최대 제한 길이 validate
avatarId - 이미 설정된 값인지 체크
nickname - 중복 체크, 이미 설정된 값인지 체크
intro - 이미 설정된 값인지 체크
from validateNickname to checkNicknameIfAlreadyExist
isNicknameAvailable() 메서드에서 구현으로 사용하고 있던 로직 checkNicknameIfAlreadyExist()로 대체
제네릭 이용,
null이 아니고 기존 값과 동일하다면 exception throw
isNicknameAvailable(), editProfileStatus() 메서드에서 구현으로 사용하고 있던 로직 checkIfAlreadySetOrThrow()로 대체
: ALREADY_SET_NICKNAME, ALREADY_SET_AVATAR, ALREADY_SET_INTRO
PATCH일 때는 null을 허용하기 때문에 null을 허용하는 NicknameConstraint 정의,
null일 때는 valid하다고 판단,
null이 아닐 때는 NicknameValidator로 validation을 위임
이미 설정한 닉네임인지 확인 후, 다른 유저가 사용 중인 닉네임인지 확인
Copy link
Member

@ChaeAg ChaeAg left a comment

Choose a reason for hiding this comment

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

수고하셨어요!
제네릭을 사용하신 것이 신기하네요~
코멘트 남겼습니다! 확인부탁드려요!

영속성 컨텍스트의 dirty check로 save하지 않아도 db에 반영되므로
from: 조회 후 삭제
to: 조회+삭제 한 번에 수행
@Kim-TaeUk Kim-TaeUk requested a review from ChaeAg August 7, 2024 17:44
Copy link
Member

@ChaeAg ChaeAg left a comment

Choose a reason for hiding this comment

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

굿입니다~~!!

Copy link
Contributor

@rinarina0429 rinarina0429 left a comment

Choose a reason for hiding this comment

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

수고하셨습니다! 리뷰 한번만 확인해주세요~

@Kim-TaeUk Kim-TaeUk merged commit 8b3ffd0 into dev Aug 8, 2024
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.

[FEAT] 본인 프로필 수정 기능 구현
3 participants