Skip to content

Commit 7506647

Browse files
committed
2 parents 484c733 + e41118a commit 7506647

File tree

5 files changed

+16
-0
lines changed

5 files changed

+16
-0
lines changed

src/main/java/com/back/domain/post/post/dto/request/PostCreateRequestDto.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public record PostCreateRequestDto(
1212
@NotBlank (message = "내용은 필수입니다.")
1313
String content,
1414
String imageUrl,
15+
String videoUrl,
1516
List<String> tags
1617
) {
1718
}

src/main/java/com/back/domain/post/post/dto/request/PostUpdateRequestDto.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public record PostUpdateRequestDto(
99
String title,
1010
String content,
1111
String imageUrl,
12+
String videoUrl,
1213
List<String> tags
1314
) {
1415
}

src/main/java/com/back/domain/post/post/dto/response/PostResponseDto.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public record PostResponseDto(
1515
String title,
1616
String content,
1717
String imageUrl,
18+
String videoUrl,
1819
List<String> tags,
1920
Integer likeCount,
2021
Integer commentCount,
@@ -32,6 +33,7 @@ public PostResponseDto(Post post) {
3233
post.getTitle(),
3334
post.getContent(),
3435
post.getImageUrl(),
36+
post.getVideoUrl(),
3537
post.getPostTags().stream()
3638
.map(postTag -> postTag.getTag().getName())
3739
.toList(),

src/main/java/com/back/domain/post/post/entity/Post.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ public class Post {
7979
@Column(name = "image_url")
8080
private String imageUrl;
8181

82+
// 게시글 동영상 URL
83+
@Column(name = "video_url")
84+
private String videoUrl;
85+
8286
@OneToMany(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true)
8387
private List<PostTag> postTags = new ArrayList<>();
8488

@@ -118,6 +122,10 @@ public void updateImage(String imageUrl) {
118122
this.imageUrl = imageUrl;
119123
}
120124

125+
public void updateVideo(String videoUrl) {
126+
this.videoUrl = videoUrl;
127+
}
128+
121129
public void addTag(Tag tag) {
122130
PostTag postTag = PostTag.create(this, tag);
123131
this.postTags.add(postTag);

src/main/java/com/back/domain/post/post/service/PostService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public PostResponseDto createPost(PostCreateRequestDto reqBody) {
5050
.title(reqBody.title())
5151
.content(reqBody.content())
5252
.imageUrl(reqBody.imageUrl())
53+
.videoUrl(reqBody.videoUrl())
5354
.build();
5455

5556
List<String> tagNames = reqBody.tags();
@@ -114,6 +115,9 @@ public PostResponseDto updatePost(Long postId, PostUpdateRequestDto reqBody) {
114115
if (reqBody.imageUrl() != null && !reqBody.imageUrl().isBlank()) {
115116
post.updateImage(reqBody.imageUrl());
116117
}
118+
if (reqBody.videoUrl() != null && !reqBody.videoUrl().isBlank()) {
119+
post.updateVideo(reqBody.videoUrl());
120+
}
117121
if (reqBody.tags() != null) {
118122
// 기존 태그들 삭제
119123
post.clearTags();

0 commit comments

Comments
 (0)