Skip to content

Commit

Permalink
Merge pull request #158 from STEPPER-UMC-6th/fix/157
Browse files Browse the repository at this point in the history
[FIX] 커뮤니티 게시글 작성 API 이미지 null값 허용
  • Loading branch information
hyojin425 authored Aug 20, 2024
2 parents 3db019b + 6f6d37f commit 1c5dd5e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ public static Post toEntity(PostDto.PostRequestDto dto, Member member, WeeklyMis
.build();
}

public static PostDto.PostResponseDto toDto(Post post, List<Image> imageList) {
List<ImageDto.ImageResponseDto> imageDtoList = imageList.stream()
.map(ImageConverter::toDto).collect(Collectors.toList());

public static PostDto.PostResponseDto toDto(Post post) {
return PostDto.PostResponseDto.builder()
.id(post.getId())
//.imageUrl(post.getImageUrl())
Expand All @@ -41,7 +38,6 @@ public static PostDto.PostResponseDto toDto(Post post, List<Image> imageList) {
.weeklyMissionTitle(post.getWeeklyMission() != null ? post.getWeeklyMission().getMissionTitle() : null)
.createdAt(post.getCreatedAt())
.updatedAt(post.getUpdatedAt())
.imageList(imageDtoList)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,23 @@ public PostDto.PostResponseDto createPost(List<MultipartFile> images, PostDto.Po
postRepository.save(post);

//이미지 저장
List<Image> imageList = imageUrlList.stream()
.map(imageUrl -> {
Image image = ImageConverter.toEntity(imageUrl, post);
return imageRepository.save(image);
})
.collect(Collectors.toList());
post.setImageList(imageList);
List<Image> imageList = null;
if (imageUrlList != null) {
imageList = imageUrlList.stream()
.map(imageUrl -> {
Image image = ImageConverter.toEntity(imageUrl, post);
return imageRepository.save(image);
})
.collect(Collectors.toList());
post.setImageList(imageList);
}

// 첫 커뮤니티 게시글 작성 완료
if (postRepository.getCountByMember(member) == 1) {
badgeService.putFirstBadge("첫 게시글 작성 완료", member);
}

return PostConverter.toDto(post, imageList);
return PostConverter.toDto(post);
}

@Override
Expand Down

0 comments on commit 1c5dd5e

Please sign in to comment.