Skip to content

Commit

Permalink
fix: #29 게시글 및 이미지 동시 업로드 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
ehs208 committed Nov 13, 2024
1 parent b277564 commit 31f2f61
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

Expand Down Expand Up @@ -55,8 +55,8 @@ public ResponseEntity<GlobalResponseDto<List<ArticlesResponseDto>>> getMediaArti
@Operation(summary = "게시글 작성", description = "새 게시글을 작성합니다.")
public ResponseEntity<GlobalResponseDto<ArticleCreateResponseDto>> createArticle(
HttpServletRequest request,
@RequestBody ArticleCreateRequestDto articleCreateRequestDto,
@RequestParam(value = "mediaFiles", required = false) List<MultipartFile> mediaFiles) {
@RequestPart("content") ArticleCreateRequestDto articleCreateRequestDto,
@RequestPart(value = "mediaFiles", required = false) List<MultipartFile> mediaFiles) {
if (mediaFiles == null) {
mediaFiles = Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.leets.xcellentbe.domain.shared.BaseTimeEntity;
import com.leets.xcellentbe.domain.shared.DeletedStatus;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
Expand Down Expand Up @@ -36,7 +37,7 @@ public class ArticleMedia extends BaseTimeEntity {
private String filePath;

@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
@JoinColumn(name = "article_id")
private Article article;

Expand All @@ -52,7 +53,7 @@ private ArticleMedia(Article article, String filePath, DeletedStatus deletedStat
this.deletedStatus = DeletedStatus.NOT_DELETED;
}

public static ArticleMedia createArticleMedia (Article article, String filePath) {
public static ArticleMedia createArticleMedia(Article article, String filePath) {
return ArticleMedia.builder()
.article(article)
.filePath(filePath)
Expand Down

0 comments on commit 31f2f61

Please sign in to comment.