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()