Skip to content

Commit

Permalink
[Fix] 프로필 사진 빈 값 예외처리 삭제 (#542)
Browse files Browse the repository at this point in the history
  • Loading branch information
slimsha2dy authored Oct 21, 2024
1 parent ff555a3 commit 755c5c8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
8 changes: 7 additions & 1 deletion backend/src/main/java/kr/touroot/member/domain/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,15 @@ private void validateProfileImageUrlForm(String profileImageUrl) {
}
}

private void validateProfileImageUrlNotNull(String profileImageUrl) {
if (profileImageUrl == null) {
throw new BadRequestException("프로필 이미지는 비어 있을 수 없습니다");
}
}

public void update(String nickname, String profileImageUrl) {
validateNickname(nickname);
validateProfileImageUrl(profileImageUrl);
validateProfileImageUrlNotNull(profileImageUrl);
this.nickname = nickname;
this.profileImageUrl = profileImageUrl;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;

public record ProfileUpdateRequest(
@Schema(description = "사용자 닉네임", example = "아기뚜리")
@NotBlank(message = "닉네임은 비어있을 수 없습니다.")
String nickname,
@Schema(description = "사용자 프로필 사진 URL", example = "https://dev.touroot.kr/profile-image-ex.png")
@NotBlank(message = "프로필 사진 URL은 비어있을 수 없습니다.")
@NotNull(message = "프로필 사진 URL은 null 값일 수 없습니다.")
String profileImageUrl
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,16 @@ private void validateNicknameDuplication(String nickname) {
public ProfileResponse updateProfile(ProfileUpdateRequest request, MemberAuth memberAuth) {
Member member = getMemberById(memberAuth.memberId());
String requestProfileImageUrl = request.profileImageUrl();
if (!Objects.equals(request.profileImageUrl(), member.getProfileImageUrl())) {
if (isUpdatable(requestProfileImageUrl, member)) {
requestProfileImageUrl = s3Provider.copyImageToPermanentStorage(request.profileImageUrl());
}
member.update(request.nickname(), requestProfileImageUrl);

// Member member = getMemberById(memberAuth.memberId());
// member.changeNickname(request.nickname());

return ProfileResponse.from(member);
}

private boolean isUpdatable(String requestProfileImageUrl, Member member) {
return !requestProfileImageUrl.isEmpty() && !Objects.equals(requestProfileImageUrl,
member.getProfileImageUrl());
}
}

0 comments on commit 755c5c8

Please sign in to comment.