From 373fa963864bedeb7231fa29cf6b17c6006c73b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A7=80=ED=9B=88?= Date: Sat, 3 Aug 2024 20:49:17 +0900 Subject: [PATCH] =?UTF-8?q?[Fix/#286]=20article=20=EC=A0=84=EC=B2=B4=20?= =?UTF-8?q?=EC=B9=B4=ED=85=8C=EA=B3=A0=EB=A6=AC=20=EB=B0=98=EC=98=81=20SQL?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=20(#287)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: article 전체 카테고리 반영 SQL 수정 --- .../com/few/api/repo/dao/article/ArticleViewCountDao.kt | 7 ++++--- .../dao/article/query/SelectArticlesOrderByViewsQuery.kt | 2 +- .../few/api/domain/article/usecase/ReadArticlesUseCase.kt | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/api-repo/src/main/kotlin/com/few/api/repo/dao/article/ArticleViewCountDao.kt b/api-repo/src/main/kotlin/com/few/api/repo/dao/article/ArticleViewCountDao.kt index 1366e9e9e..c14d503c4 100644 --- a/api-repo/src/main/kotlin/com/few/api/repo/dao/article/ArticleViewCountDao.kt +++ b/api-repo/src/main/kotlin/com/few/api/repo/dao/article/ArticleViewCountDao.kt @@ -5,6 +5,7 @@ import com.few.api.repo.dao.article.query.ArticleViewCountQuery import com.few.api.repo.dao.article.query.SelectArticlesOrderByViewsQuery import com.few.api.repo.dao.article.query.SelectRankByViewsQuery import com.few.api.repo.dao.article.record.SelectArticleViewsRecord +import com.few.data.common.code.CategoryType import jooq.jooq_dsl.tables.ArticleViewCount.ARTICLE_VIEW_COUNT import org.jooq.DSLContext import org.jooq.impl.DSL.* @@ -76,15 +77,15 @@ class ArticleViewCountDao( field("article_view_count_offset_tb.article_id").`as`(SelectArticleViewsRecord::articleId.name), field("article_view_count_offset_tb.view_count").`as`(SelectArticleViewsRecord::views.name) ).from( - select() + dslContext.select() .from(ARTICLE_VIEW_COUNT) .where(ARTICLE_VIEW_COUNT.DELETED_AT.isNull) .orderBy(ARTICLE_VIEW_COUNT.VIEW_COUNT.desc(), ARTICLE_VIEW_COUNT.ARTICLE_ID.desc()) .limit(query.offset, Long.MAX_VALUE) .asTable("article_view_count_offset_tb") ).where( - when (query.category) { - (null) -> noCondition() + when { + (query.category == CategoryType.All) -> noCondition() else -> field("article_view_count_offset_tb.category_cd").eq(query.category.code) } ).limit(11) diff --git a/api-repo/src/main/kotlin/com/few/api/repo/dao/article/query/SelectArticlesOrderByViewsQuery.kt b/api-repo/src/main/kotlin/com/few/api/repo/dao/article/query/SelectArticlesOrderByViewsQuery.kt index e61dfbe9c..4a53bb267 100644 --- a/api-repo/src/main/kotlin/com/few/api/repo/dao/article/query/SelectArticlesOrderByViewsQuery.kt +++ b/api-repo/src/main/kotlin/com/few/api/repo/dao/article/query/SelectArticlesOrderByViewsQuery.kt @@ -4,5 +4,5 @@ import com.few.data.common.code.CategoryType data class SelectArticlesOrderByViewsQuery( val offset: Long, - val category: CategoryType?, + val category: CategoryType, ) \ No newline at end of file diff --git a/api/src/main/kotlin/com/few/api/domain/article/usecase/ReadArticlesUseCase.kt b/api/src/main/kotlin/com/few/api/domain/article/usecase/ReadArticlesUseCase.kt index 00859afa4..401723eae 100644 --- a/api/src/main/kotlin/com/few/api/domain/article/usecase/ReadArticlesUseCase.kt +++ b/api/src/main/kotlin/com/few/api/domain/article/usecase/ReadArticlesUseCase.kt @@ -38,7 +38,7 @@ class ReadArticlesUseCase( val articleViewsRecords: MutableList = articleViewCountDao.selectArticlesOrderByViews( SelectArticlesOrderByViewsQuery( offset, - CategoryType.fromCode(useCaseIn.categoryCd) + CategoryType.fromCode(useCaseIn.categoryCd) ?: CategoryType.All ) ).toMutableList()