Skip to content

Commit

Permalink
Merge pull request #128 from PawWithU/feat/127-patch-mypage-profile-api
Browse files Browse the repository at this point in the history
[Feature] 이동봉사자 마이페이지 프로필 수정 API 로직 변경
  • Loading branch information
hojeong2747 authored Nov 19, 2023
2 parents c707127 + 28d3315 commit dac8334
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,8 @@ public void updateMyProfile(String nickname, Integer profileImageNum) {
this.nickname = nickname;
this.profileImageNum = profileImageNum;
}

public void updateProfileImage(Integer profileImageNum) {
this.profileImageNum = profileImageNum;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,18 @@ public List<VolunteerGetMyBadgeResponse> getMyBadges(String email) {

public void volunteerMyProfile(String email, VolunteerMyProfileRequest volunteerMyProfileRequest) {
Volunteer volunteer = volunteerRepository.findByEmail(email).orElseThrow(() -> new BadRequestException(VOLUNTEER_NOT_FOUND));

if (volunteerRepository.existsByNickname(volunteerMyProfileRequest.nickname())) {
throw new BadRequestException(ALREADY_EXIST_NICKNAME);
}

String curNickname = volunteer.getNickname();
String nickname = volunteerMyProfileRequest.nickname();
Integer profileImageNum = volunteerMyProfileRequest.profileImageNum();
volunteer.updateMyProfile(nickname, profileImageNum);

if (curNickname.equals(nickname)) {
volunteer.updateProfileImage(profileImageNum);
} else {
if (volunteerRepository.existsByNickname(nickname)) {
throw new BadRequestException(ALREADY_EXIST_NICKNAME);
}

volunteer.updateMyProfile(nickname, profileImageNum);
}
}
}

0 comments on commit dac8334

Please sign in to comment.