Skip to content

Commit 717eefb

Browse files
authored
Merge pull request #127 from newzet-dev/Fix/issue-#125
Orch 계층 의존을 고려하여 @Transcational 적용 변경
2 parents 5f868e6 + c4e592d commit 717eefb

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

src/main/java/com/newzet/api/article/business/service/ArticleService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
@Slf4j
2626
@Service
27-
@Transactional(readOnly = true)
2827
@RequiredArgsConstructor
2928
public class ArticleService {
3029

@@ -39,6 +38,7 @@ public void saveArticleBatch(UUID userId, String fromName, String fromDomain,
3938
batchProducer.addToBatch(article);
4039
}
4140

41+
@Transactional(readOnly = true)
4242
public ArticleListResponse getMonthlyArticleList(UUID userId, int year, int month) {
4343
List<ArticleWithImageProjection> articleListAtYearAndMonth = articleRepository.getMonthlyArticleWithImage(
4444
userId, year, month);
@@ -54,7 +54,6 @@ public ArticleListResponse getMonthlyArticleList(UUID userId, int year, int mont
5454
return ArticleListResponse.from(getDailyArticleList(articleList));
5555
}
5656

57-
@Transactional
5857
public Article getArticle(UUID articleId) {
5958
Article article = articleRepository.getById(articleId).toDomain();
6059
if (article.checkIsUnRead()) { // isRead가 false이면 읽기 처리 수행
@@ -64,6 +63,7 @@ public Article getArticle(UUID articleId) {
6463
return article;
6564
}
6665

66+
@Transactional(readOnly = true)
6767
public ArticleLikeListResponse getArticleLikeList(UUID userId) {
6868
List<ArticleDetailResponse> articleList = articleRepository.findLikeArticleWithImage(userId)
6969
.stream()
@@ -106,12 +106,14 @@ public Article addArticle(UUID userId, String name, String domain, String title,
106106
return articleRepository.save(article);
107107
}
108108

109+
@Transactional
109110
public Article shareArticle(UUID articleId) {
110111
Article article = articleRepository.getById(articleId).toDomain();
111112
Article sharedArticle = article.share();
112113
return articleRepository.save(sharedArticle);
113114
}
114115

116+
@Transactional(readOnly = true)
115117
public String getSharedUrl(UUID articleId) {
116118
return String.format("%s/%s", ARTICLE_SHARE_PREFIX, articleId);
117119
}

src/main/java/com/newzet/api/article/orchestrator/ArticleOrchestrator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public ArticleContentResponse getSharedArticle(UUID articleId) {
2727
sharedArticle.isLike());
2828
}
2929

30+
@Transactional
3031
public ArticleContentResponse getArticle(UUID articleId) {
3132
Article article = articleService.getArticle(articleId);
3233
String content = s3Service.getContentAsString(article.getContentUrl());

0 commit comments

Comments
 (0)