diff --git a/backend/src/main/java/org/donggle/backend/application/service/blog/PublishService.java b/backend/src/main/java/org/donggle/backend/application/service/blog/PublishService.java index ef13999c1..010245140 100644 --- a/backend/src/main/java/org/donggle/backend/application/service/blog/PublishService.java +++ b/backend/src/main/java/org/donggle/backend/application/service/blog/PublishService.java @@ -52,7 +52,7 @@ public PublishWritingRequest findPublishWriting(final Long memberId, final Long } public void saveProperties(final Blog blog, final Writing writing, final PublishResponse response) { - blogWritingRepository.save(new BlogWriting(blog, writing, response.dateTime(), response.tags())); + blogWritingRepository.save(new BlogWriting(blog, writing, response.dateTime(), response.tags(), response.url())); } diff --git a/backend/src/main/java/org/donggle/backend/application/service/writing/WritingService.java b/backend/src/main/java/org/donggle/backend/application/service/writing/WritingService.java index 3b2ee2bdc..c878bdac6 100644 --- a/backend/src/main/java/org/donggle/backend/application/service/writing/WritingService.java +++ b/backend/src/main/java/org/donggle/backend/application/service/writing/WritingService.java @@ -18,6 +18,8 @@ import org.donggle.backend.exception.notfound.CategoryNotFoundException; import org.donggle.backend.exception.notfound.MemberNotFoundException; import org.donggle.backend.exception.notfound.WritingNotFoundException; +import org.donggle.backend.infrastructure.client.notion.NotionApiClient; +import org.donggle.backend.infrastructure.client.notion.dto.response.NotionBlockNodeResponse; import org.donggle.backend.ui.response.PublishedDetailResponse; import org.donggle.backend.ui.response.WritingDetailResponse; import org.donggle.backend.ui.response.WritingListWithCategoryResponse; @@ -197,10 +199,7 @@ private void changeCategory(final Long memberId, final Long categoryId, final Wr private List convertToPublishedDetailResponses(final Long findWriting) { final List blogWritings = blogWritingRepository.findByWritingId(findWriting); return blogWritings.stream() - .map(blogWriting -> new PublishedDetailResponse( - blogWriting.getBlogTypeValue(), - blogWriting.getPublishedAt(), - blogWriting.getTags())) + .map(PublishedDetailResponse::of) .toList(); } diff --git a/backend/src/main/java/org/donggle/backend/domain/blog/BlogWriting.java b/backend/src/main/java/org/donggle/backend/domain/blog/BlogWriting.java index 9607c90b2..86391dace 100644 --- a/backend/src/main/java/org/donggle/backend/domain/blog/BlogWriting.java +++ b/backend/src/main/java/org/donggle/backend/domain/blog/BlogWriting.java @@ -34,12 +34,14 @@ public class BlogWriting extends BaseEntity { private LocalDateTime publishedAt; @ElementCollection private List tags; + private String url; - public BlogWriting(final Blog blog, final Writing writing, final LocalDateTime publishedAt, final List tags) { + public BlogWriting(final Blog blog, final Writing writing, final LocalDateTime publishedAt, final List tags, final String url) { this.blog = blog; this.writing = writing; this.publishedAt = publishedAt; this.tags = tags; + this.url = url; } public String getBlogTypeValue() { diff --git a/backend/src/main/java/org/donggle/backend/infrastructure/client/medium/dto/response/MediumPublishResponse.java b/backend/src/main/java/org/donggle/backend/infrastructure/client/medium/dto/response/MediumPublishResponse.java index 860d78d28..d4ede4047 100644 --- a/backend/src/main/java/org/donggle/backend/infrastructure/client/medium/dto/response/MediumPublishResponse.java +++ b/backend/src/main/java/org/donggle/backend/infrastructure/client/medium/dto/response/MediumPublishResponse.java @@ -26,6 +26,7 @@ public PublishResponse toPublishResponse() { return PublishResponse.builder() .dateTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(publishedAt), ZoneId.systemDefault())) .tags(tags) + .url(url) .build(); } } diff --git a/backend/src/main/java/org/donggle/backend/infrastructure/client/tistory/dto/response/TistoryGetWritingResponseWrapper.java b/backend/src/main/java/org/donggle/backend/infrastructure/client/tistory/dto/response/TistoryGetWritingResponseWrapper.java index 48e1b1b90..582b93127 100644 --- a/backend/src/main/java/org/donggle/backend/infrastructure/client/tistory/dto/response/TistoryGetWritingResponseWrapper.java +++ b/backend/src/main/java/org/donggle/backend/infrastructure/client/tistory/dto/response/TistoryGetWritingResponseWrapper.java @@ -1,8 +1,8 @@ package org.donggle.backend.infrastructure.client.tistory.dto.response; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import org.donggle.backend.ui.response.PublishResponse; import org.donggle.backend.infrastructure.client.tistory.util.TistoryTagsDeserializer; +import org.donggle.backend.ui.response.PublishResponse; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -36,6 +36,7 @@ public PublishResponse toPublishResponse() { return PublishResponse.builder() .dateTime(LocalDateTime.parse(tistory.item().date, formatter)) .tags(tistory.item().tags.tags()) + .url(tistory.item().postUrl) .build(); } } diff --git a/backend/src/main/java/org/donggle/backend/ui/response/PublishResponse.java b/backend/src/main/java/org/donggle/backend/ui/response/PublishResponse.java index 44a8af9ab..b7bbc62d7 100644 --- a/backend/src/main/java/org/donggle/backend/ui/response/PublishResponse.java +++ b/backend/src/main/java/org/donggle/backend/ui/response/PublishResponse.java @@ -8,6 +8,7 @@ @Builder public record PublishResponse( LocalDateTime dateTime, - List tags + List tags, + String url ) { } diff --git a/backend/src/main/java/org/donggle/backend/ui/response/PublishedDetailResponse.java b/backend/src/main/java/org/donggle/backend/ui/response/PublishedDetailResponse.java index d16cd412f..5afaecadb 100644 --- a/backend/src/main/java/org/donggle/backend/ui/response/PublishedDetailResponse.java +++ b/backend/src/main/java/org/donggle/backend/ui/response/PublishedDetailResponse.java @@ -8,9 +8,10 @@ public record PublishedDetailResponse( String blogName, LocalDateTime publishedAt, - List tags + List tags, + String url ) { public static PublishedDetailResponse of(final BlogWriting blogWriting) { - return new PublishedDetailResponse(blogWriting.getBlogTypeValue(), blogWriting.getPublishedAt(), blogWriting.getTags()); + return new PublishedDetailResponse(blogWriting.getBlogTypeValue(), blogWriting.getPublishedAt(), blogWriting.getTags(), blogWriting.getUrl()); } } diff --git a/backend/src/test/java/org/donggle/backend/application/service/PublishServiceTest.java b/backend/src/test/java/org/donggle/backend/application/service/PublishServiceTest.java index c15e0c0d8..d672c4dac 100644 --- a/backend/src/test/java/org/donggle/backend/application/service/PublishServiceTest.java +++ b/backend/src/test/java/org/donggle/backend/application/service/PublishServiceTest.java @@ -39,7 +39,7 @@ void alreadyPublishedException() { final PublishRequest medium = new PublishRequest("MEDIUM", null); final Blog blog = blogRepository.findByBlogType(BlogType.MEDIUM).orElseThrow(); final Writing writing = writingRepository.findById(1L).orElseThrow(); - blogWritingRepository.save(new BlogWriting(blog, writing, LocalDateTime.now(), null)); + blogWritingRepository.save(new BlogWriting(blog, writing, LocalDateTime.now(), null, null)); //when