Skip to content

Commit

Permalink
fix: 이미지 미첨부시 500 오류 해결 (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
toychip committed Jan 15, 2024
1 parent ad21690 commit 306ff2d
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ public Long register(final PostCreateRequest request) {
Post post = PostConverter.createDtoToEntity(request, getCurrentMember());
postRepository.save(post);

registerImages(request.getAttachmentFile(), post);
List<MultipartFile> attachmentFile = request.getAttachmentFile();
if (!attachmentFile.isEmpty()) {
registerImages(request.getAttachmentFile(), post);
}

return post.getId();
}

Expand Down Expand Up @@ -125,8 +129,7 @@ public PostResponse getSinglePost(final Long postId) {
}

private Post getPostFetchJoin(final Long postId) {
return postRepository.findPostFetchJoin(postId)
.orElseThrow(() -> new ApiException(ErrorType._POST_NOT_FOUND));
return postRepository.findPostFetchJoin(postId);
}

private void addViewCount(Post post) {
Expand Down

0 comments on commit 306ff2d

Please sign in to comment.