Skip to content

Commit

Permalink
feat: 명소 삭제 기능 수정 #78
Browse files Browse the repository at this point in the history
  • Loading branch information
Sangyoo committed Jan 23, 2023
1 parent f36554c commit 4a195a2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ public ResponseEntity<MultiResponseDto<?>> getAllPosts(@RequestParam(defaultValu
@DeleteMapping("/delete/{post-id}/{member-id}")
public ResponseEntity<HttpStatus> deletePost(@PathVariable("post-id") long postId,
@PathVariable("member-id") @Positive long memberId) {
String dirName = "images";
Post post = postService.verifyClientId(memberId, postId);
// 포스트 이미지, 해시태그 삭제
postImageService.deletePostImages(post.getPostImages());
hashTagService.deleteHashTags(post.getHashTags());
postImageService.deleteOnlyS3Images(post.getPostImages());

postService.erasePost(post);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ public void deletePostImages(List<PostImage> postImages){
}
}

public void deletePostImage(PostImage postImage){
PostImage findPostImage = findVerifiedPostImage(postImage.getPostImageId());
String fileName = findPostImage.getPostImageFileName();
String filePath = dirName + "/" + fileName;
s3Service.delete(filePath);
postImageRepository.delete(findPostImage);
public void deleteOnlyS3Images(List<PostImage> postImages){
for(PostImage postImage : postImages) {
PostImage findPostImage = findVerifiedPostImage(postImage.getPostImageId());
String fileName = findPostImage.getPostImageFileName();
String filePath = dirName + "/" + fileName;
s3Service.delete(filePath);
}
}

public PostImage findVerifiedPostImage(long postImageId){
Expand Down

0 comments on commit 4a195a2

Please sign in to comment.