From 669d1b496e5c128d4b63f9e91016792bfafa8ab4 Mon Sep 17 00:00:00 2001 From: Jihun-Hwang Date: Sat, 3 Aug 2024 17:47:09 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=EC=95=84=ED=8B=B0=ED=81=B4=20?= =?UTF-8?q?=EA=B0=9C=EC=88=98=EA=B0=80=2010=EC=9D=98=20=EB=B0=B0=EC=88=98?= =?UTF-8?q?=EC=9D=BC=20=EA=B2=BD=EC=9A=B0=20=EB=A7=88=EC=A7=80=EB=A7=89=20?= =?UTF-8?q?=EC=8A=A4=ED=81=AC=EB=A1=A4=EC=97=90=EC=84=9C=20isLast=3Dfalse?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=91=EB=8B=B5=EB=90=98=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/repo/dao/article/ArticleViewCountDao.kt | 5 ++--- .../domain/article/usecase/ReadArticlesUseCase.kt | 15 +++++++++++---- 2 files changed, 13 insertions(+), 7 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 fa7eb1607..1366e9e9e 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 @@ -66,10 +66,9 @@ class ArticleViewCountDao( .where(field("row_rank_tb.${ARTICLE_VIEW_COUNT.ARTICLE_ID.name}")!!.eq(query.articleId)) .query - fun selectArticlesOrderByViews(query: SelectArticlesOrderByViewsQuery): Set { + fun selectArticlesOrderByViews(query: SelectArticlesOrderByViewsQuery): List { return selectArticlesOrderByViewsQuery(query) .fetchInto(SelectArticleViewsRecord::class.java) - .toSet() } fun selectArticlesOrderByViewsQuery(query: SelectArticlesOrderByViewsQuery) = dslContext @@ -88,6 +87,6 @@ class ArticleViewCountDao( (null) -> noCondition() else -> field("article_view_count_offset_tb.category_cd").eq(query.category.code) } - ).limit(10) + ).limit(11) .query } \ 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 60cb7ad43..00859afa4 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 @@ -35,12 +35,19 @@ class ReadArticlesUseCase( } // 이번 스크롤에서 보여줄 아티클 ID에 대한 기준 (Criterion) - val articleViewsRecords: Set = articleViewCountDao.selectArticlesOrderByViews( + val articleViewsRecords: MutableList = articleViewCountDao.selectArticlesOrderByViews( SelectArticlesOrderByViewsQuery( offset, CategoryType.fromCode(useCaseIn.categoryCd) ) - ) + ).toMutableList() + + val isLast = if (articleViewsRecords.size == 11) { + articleViewsRecords.removeAt(10) + false + } else { + true + } // 2. TODO: 조회한 10개의 아티클 아이디를 기반으로 로컬 캐시에 있는지 조회(아티클 단건조회 캐시 사용) // 3. TODO: 로컬캐시에 없으면 ARTICLE_MAIN_CARD 테이블에서 데이터가 있는지 조회 (컨텐츠는 article_ifo에서) @@ -97,12 +104,12 @@ class ReadArticlesUseCase( ) }.toList() - return ReadArticlesUseCaseOut(articleUseCaseOuts, sortedArticles.size != 10) + return ReadArticlesUseCaseOut(articleUseCaseOuts, isLast) } private fun updateAndSortArticleViews( articleRecords: Set, - articleViewsRecords: Set, + articleViewsRecords: List, ): Set { val sortedSet = TreeSet( Comparator { a1, a2 -> From 1ab5f0159ef78e2c2ce745d96cafe20bcee21e4c Mon Sep 17 00:00:00 2001 From: Jihun-Hwang Date: Sat, 3 Aug 2024 18:15:48 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=EC=95=84=ED=8B=B0=ED=81=B4=20Categ?= =?UTF-8?q?oryType=20=EC=B6=94=EA=B0=80=20-=20All(=EC=A0=84=EC=B2=B4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/src/main/kotlin/com/few/data/common/code/CategoryType.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/data/src/main/kotlin/com/few/data/common/code/CategoryType.kt b/data/src/main/kotlin/com/few/data/common/code/CategoryType.kt index 3597dbfb0..94aa4ed96 100644 --- a/data/src/main/kotlin/com/few/data/common/code/CategoryType.kt +++ b/data/src/main/kotlin/com/few/data/common/code/CategoryType.kt @@ -4,6 +4,7 @@ package com.few.data.common.code * @see com.few.batch.data.common.code.BatchCategoryType */ enum class CategoryType(val code: Byte, val displayName: String) { + All(-1, "전체"), // Should not be stored in the DB ECONOMY(0, "경제"), IT(10, "IT"), MARKETING(20, "마케팅"),