Skip to content

Commit

Permalink
#280 [feat] null로 올 경우는 수정 안했다는 의미이기 때문에 기존의 이미지 삭제안함
Browse files Browse the repository at this point in the history
  • Loading branch information
hellozo0 committed Apr 24, 2024
1 parent 519cc99 commit 63ddc9a
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,14 @@ public UserCreateResponse createDesigner(final Long designerId, final DesignerCr
@Transactional
public void updateDesigner(final Long designerId, final MultipartFile profileImg, final DesignerUpdateRequest designerUpdateRequest) {
Designer designer = designerJpaRepository.findById(designerId).orElseThrow(() -> new NotFoundException(DESIGNER_NOT_FOUND_EXCEPTION));
s3Service.deleteS3Image(designer.getProfileImgUrl());
String updatedProfileImgUrl = s3Service.uploadProfileImage(profileImg, Role.HAIR_DESIGNER);

updateUserInfos(designerId, new UserUpdateDto(designerUpdateRequest.name(), designerUpdateRequest.gender(), designer.getPhoneNumber(), designer.getIsMarketingAgree()), updatedProfileImgUrl);
String profileImgUrl = designer.getProfileImgUrl();
if (profileImg != null) {
s3Service.deleteS3Image(profileImgUrl);
profileImgUrl = s3Service.uploadProfileImage(profileImg, Role.HAIR_DESIGNER);
}

updateUserInfos(designerId, new UserUpdateDto(designerUpdateRequest.name(), designerUpdateRequest.gender(), designer.getPhoneNumber(), designer.getIsMarketingAgree()), profileImgUrl);
designer.update(new HairShop(designerUpdateRequest.hairShop().name(), designerUpdateRequest.hairShop().address(), designerUpdateRequest.hairShop().detailAddress()), new Portfolio(designerUpdateRequest.portfolio().instagramUrl(), designer.getPortfolio().getNaverPlaceUrl()), designerUpdateRequest.introduction(), designerUpdateRequest.kakaoOpenChatUrl());
designerJpaRepository.save(designer);
deleteDesignerDayoffs(designerId);
Expand Down

0 comments on commit 63ddc9a

Please sign in to comment.