diff --git a/src/main/java/KGUcapstone/OutDecision/domain/post/controller/PostRestController.java b/src/main/java/KGUcapstone/OutDecision/domain/post/controller/PostRestController.java index 91a6f47..a75e166 100644 --- a/src/main/java/KGUcapstone/OutDecision/domain/post/controller/PostRestController.java +++ b/src/main/java/KGUcapstone/OutDecision/domain/post/controller/PostRestController.java @@ -43,9 +43,9 @@ public ApiResponse viewPost(@PathVariable Long postId) { public ApiResponse updatePost(@PathVariable Long postId, @RequestPart UploadPostDTO request, @RequestPart List optionNames, - @RequestPart List newImages, + @RequestPart List optionImages, @RequestPart List originImages) { - return ApiResponse.onSuccess(postServiceImpl.updatePost(postId, request, optionNames, newImages, originImages)); + return ApiResponse.onSuccess(postServiceImpl.updatePost(postId, request, optionNames, optionImages, originImages)); } /* 삭제 */ diff --git a/src/main/java/KGUcapstone/OutDecision/domain/post/service/PostServiceImpl.java b/src/main/java/KGUcapstone/OutDecision/domain/post/service/PostServiceImpl.java index c50e632..001141c 100644 --- a/src/main/java/KGUcapstone/OutDecision/domain/post/service/PostServiceImpl.java +++ b/src/main/java/KGUcapstone/OutDecision/domain/post/service/PostServiceImpl.java @@ -169,7 +169,7 @@ public PostDTO viewPost(Long postId) { /* 수정 */ @Override public boolean updatePost(Long postId, UploadPostDTO request, List optionNames, - List newImages, List originImages) { + List optionImages, List originImages) { Long memberId = 2024L; Post post = postRepository.findById(postId) .orElseThrow(() -> new PostHandler(ErrorStatus.POST_NOT_FOUND)); @@ -187,14 +187,14 @@ public boolean updatePost(Long postId, UploadPostDTO request, List optio // 새로운 옵션 추가 List optionsList = new ArrayList<>(); - if (optionNames != null && newImages != null && optionNames.size() == newImages.size()) { + if (optionNames != null && optionImages != null && optionNames.size() == optionImages.size()) { for (int i = 0; i < optionNames.size(); i++) { String optionName = optionNames.get(i); String photoUrl = ""; // 새로운 이미지 업로드 또는 기존 이미지 사용 - if (!newImages.get(i).isEmpty()) { - photoUrl = s3Service.uploadFile(newImages.get(i), "options"); + if (!optionImages.get(i).isEmpty()) { + photoUrl = s3Service.uploadFile(optionImages.get(i), "options"); } else if (originImages.get(i).isEmpty()) { photoUrl = originImages.get(i); }