Skip to content

Commit

Permalink
refactor: command가 Nickname객체를 가지게 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
hgo641 committed May 16, 2024
1 parent 9cd87be commit 70c3577
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/main/kotlin/com/petqua/application/member/MemberService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,16 @@ class MemberService(
val member = memberRepository.findActiveByIdOrThrow(command.memberId) {
MemberException(NOT_FOUND_MEMBER)
}
member.updateNickname(Nickname.from(command.nickname))
member.updateNickname(command.nickname)
}

private fun validateNickname(nickname: String, memberId: Long) {
validateContainingBannedWord(nickname)
private fun validateNickname(nickname: Nickname, memberId: Long) {
validateContainingBannedWord(nickname.value)
validateDuplicatedNickname(nickname, memberId)
}

private fun validateDuplicatedNickname(nickname: String, memberId: Long) {
throwExceptionWhen(memberRepository.existsMemberByNicknameAndIdNot(Nickname.from(nickname), memberId)) {
private fun validateDuplicatedNickname(nickname: Nickname, memberId: Long) {
throwExceptionWhen(memberRepository.existsMemberByNicknameAndIdNot(nickname, memberId)) {
MemberException(ALREADY_EXIST_NICKNAME)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.petqua.domain.member.PetFish
import com.petqua.domain.member.PetFishCount
import com.petqua.domain.member.PetFishSex
import com.petqua.domain.member.PetFishes
import com.petqua.domain.member.nickname.Nickname
import java.time.YearMonth

data class MemberSignUpCommand(
Expand Down Expand Up @@ -54,5 +55,8 @@ data class PetFishAddCommand(

data class UpdateProfileCommand(
val memberId: Long,
val nickname: String
)
val nickname: Nickname,
) {

constructor(memberId: Long, nickname: String) : this(memberId, Nickname.from(nickname))
}

0 comments on commit 70c3577

Please sign in to comment.