File tree Expand file tree Collapse file tree
src/main/java/com/davcatch/devcatch Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -159,17 +159,14 @@ public Optional<ArticleResponse> findArticleDetail(Long articleId) {
159159
160160 @ Override
161161 public List <ArticleResponse > findRelatedArticles (Long articleId , List <TagType > tagTypes ) {
162- if (tagTypes == null || tagTypes .isEmpty ())
163- return Collections .emptyList ();
164-
165162 Map <Long , ArticleResponse > transform = queryFactory
166163 .from (article )
167164 .join (article .source , source )
168165 .join (article .articleTags , articleTag )
169166 .join (articleTag .tag , tag )
170167 .where (
171168 article .id .ne (articleId ),
172- tag .tagType .in (tagTypes )
169+ tag .tagType .in (tagTypes ). isNull ()
173170 )
174171 .orderBy (article .publishedAt .desc ())
175172 .limit (RELATED_ARTICLE_SIZE )
Original file line number Diff line number Diff line change 11package com .davcatch .devcatch .web .service .article ;
22
3+ import java .util .Collections ;
34import java .util .List ;
5+ import java .util .Objects ;
46
57import org .springframework .data .domain .Page ;
68import org .springframework .data .domain .Pageable ;
@@ -65,7 +67,16 @@ public ArticleResponse getArticleDetail(Long articleId) throws CustomException {
6567 * @return 아티클 리스트
6668 */
6769 public List <ArticleResponse > getRelatedArticles (Long articleId , List <TagType > tagTypes ) {
68- return articleRepository .findRelatedArticles (articleId , tagTypes );
70+ List <TagType > filteredNullTagTypes = tagTypes == null ?
71+ Collections .emptyList () :
72+ tagTypes .stream ()
73+ .filter (Objects ::nonNull )
74+ .toList ();
75+
76+ if (filteredNullTagTypes .isEmpty ())
77+ return Collections .emptyList ();
78+
79+ return articleRepository .findRelatedArticles (articleId , filteredNullTagTypes );
6980 }
7081
7182}
You can’t perform that action at this time.
0 commit comments