Skip to content

Commit

Permalink
Merge pull request #212 from OutDecision/issue/168
Browse files Browse the repository at this point in the history
🎨 [UPDATE]: 게시글 수정-파라미터값 변경
  • Loading branch information
sye1101 authored May 26, 2024
2 parents 4d9a6c8 + eac0ed2 commit 19cdf42
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public ApiResponse<PostDTO> viewPost(@PathVariable Long postId) {
public ApiResponse<Object> updatePost(@PathVariable Long postId,
@RequestPart UploadPostDTO request,
@RequestPart List<String> optionNames,
@RequestPart List<MultipartFile> newImages,
@RequestPart List<MultipartFile> optionImages,
@RequestPart List<String> originImages) {
return ApiResponse.onSuccess(postServiceImpl.updatePost(postId, request, optionNames, newImages, originImages));
return ApiResponse.onSuccess(postServiceImpl.updatePost(postId, request, optionNames, optionImages, originImages));
}

/* 삭제 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public PostDTO viewPost(Long postId) {
/* 수정 */
@Override
public boolean updatePost(Long postId, UploadPostDTO request, List<String> optionNames,
List<MultipartFile> newImages, List<String> originImages) {
List<MultipartFile> optionImages, List<String> originImages) {
Long memberId = 2024L;
Post post = postRepository.findById(postId)
.orElseThrow(() -> new PostHandler(ErrorStatus.POST_NOT_FOUND));
Expand All @@ -187,14 +187,14 @@ public boolean updatePost(Long postId, UploadPostDTO request, List<String> optio

// 새로운 옵션 추가
List<Options> 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);
}
Expand Down

0 comments on commit 19cdf42

Please sign in to comment.