Skip to content

Commit

Permalink
refactor: 프로필 수정 시 null 값이 들어오면 해당 필드는 수정하지 않음
Browse files Browse the repository at this point in the history
  • Loading branch information
SJ70 committed Aug 8, 2024
1 parent a90a0e0 commit 3238d21
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ public record MemberUpdateDto (
@ImageTypeCheck
MultipartFile file,

@NotNull
@NotBlank
@Size(max = 20, message = "이름은 20자 이내로 입력해주세요.")
String name,

@NotNull
@NotBlank
@Size(max = 1000, message = "자기소개는 1000자 이내로 입력해주세요.")
String description
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/com/j9/bestmoments/service/MemberService.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,16 @@ private Member create(OAuthUserInfoDto oAuthUserInfoDto) {

@Transactional
public Member update(Member member, MemberUpdateDto memberUpdateDto) {
member.setName(memberUpdateDto.name());
member.setDescription(memberUpdateDto.description());
String profileImageUrl = googleCloudStorageService.uploadFile(memberUpdateDto.file());
member.setProfileImageUrl(profileImageUrl);
if (memberUpdateDto.name() != null) {
member.setName(memberUpdateDto.name());
}
if (memberUpdateDto.description() != null) {
member.setDescription(memberUpdateDto.description());
}
if (memberUpdateDto.file() != null) {
String profileImageUrl = googleCloudStorageService.uploadFile(memberUpdateDto.file());
member.setProfileImageUrl(profileImageUrl);
}
return memberRepository.save(member);
}

Expand Down

0 comments on commit 3238d21

Please sign in to comment.