-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feature: 글 내용 조회 api 추가 * fix: spring transactional로 교체
- Loading branch information
1 parent
6820c2a
commit 74b8035
Showing
5 changed files
with
62 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/com/goldbalance/dive/domain/article/dto/ArticleDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.goldbalance.dive.domain.article.dto; | ||
|
||
import com.goldbalance.dive.domain.article.domain.ArticleContent; | ||
import java.util.List; | ||
|
||
public record ArticleDto(String nickname, String title, int totalContents, List<Content> contents) { | ||
|
||
public static ArticleDto of(String nickname, List<ArticleContent> contents) { | ||
List<Content> contentList = contents.stream() | ||
.map(articleContent -> new Content(articleContent.getSubTitle(), articleContent.getContent())) | ||
.toList(); | ||
|
||
return new ArticleDto(nickname, contents.get(0).getArticle().getTitle(), contents.size(), contentList); | ||
} | ||
|
||
static class Content { | ||
private String subtitle; | ||
private String content; | ||
|
||
public Content(String subtitle, String content) { | ||
this.subtitle = subtitle; | ||
this.content = content; | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/goldbalance/dive/domain/article/repository/ArticleContentRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.goldbalance.dive.domain.article.repository; | ||
|
||
import com.goldbalance.dive.domain.article.domain.ArticleContent; | ||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface ArticleContentRepository extends JpaRepository<ArticleContent, Long> { | ||
|
||
List<ArticleContent> findAllByArticleId(Long articleId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters