Skip to content

Commit

Permalink
[api-server-v1] fix: 페이지 프로필 이미지 교체시 기존 디폴트 이미지 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
gdtknight committed Oct 6, 2023
1 parent b4ed976 commit 1f692a4
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public SharePageTreeResponseDTO.PageTreeNode getPageTree(UUID spaceId) {
return rootNode;
}

@Transactional
public UUID createDefaultPage(Long userId) {
User user =
userRepository
Expand Down Expand Up @@ -274,6 +275,7 @@ public void moveBlocks(MoveBlockDTO moveBlockDTO) {
});
}

@Transactional
public SharePageDetailResponseDTO modify(UUID pageId, SharePageModifyDTO sharePageModifyDTO) {
SharePage currentPage =
sharePageRepository
Expand All @@ -286,7 +288,15 @@ public SharePageDetailResponseDTO modify(UUID pageId, SharePageModifyDTO sharePa
currentPage.setDescription(sharePageModifyDTO.description());

if (sharePageModifyDTO.profileImage() != null) {
s3StorageService.delete(currentPage.getProfileImageLink());
String profileImageLink = currentPage.getProfileImageLink();
String fileName =
profileImageLink.substring(
profileImageLink.lastIndexOf("/") + 1, profileImageLink.lastIndexOf("."));

// 페이지 프로필 이미지가 디폴트 이미지가 아닌 경우 해당 프로필 이미지 삭제
if (!fileName.contains("default")) {
s3StorageService.delete(currentPage.getProfileImageLink());
}
currentPage.setProfileImageLink(s3StorageService.store(sharePageModifyDTO.profileImage()));
}

Expand Down

0 comments on commit 1f692a4

Please sign in to comment.