diff --git a/api-repo/src/main/kotlin/com/few/api/repo/dao/article/ArticleMainCardDao.kt b/api-repo/src/main/kotlin/com/few/api/repo/dao/article/ArticleMainCardDao.kt index b395149f7..f863d138a 100644 --- a/api-repo/src/main/kotlin/com/few/api/repo/dao/article/ArticleMainCardDao.kt +++ b/api-repo/src/main/kotlin/com/few/api/repo/dao/article/ArticleMainCardDao.kt @@ -5,6 +5,8 @@ import com.few.api.repo.dao.article.command.UpdateArticleMainCardWorkbookCommand import com.few.api.repo.dao.article.record.ArticleMainCardRecord import com.few.api.repo.dao.article.support.CommonJsonMapper import com.few.api.repo.dao.article.support.ArticleMainCardMapper +import jooq.jooq_dsl.tables.ArticleIfo +import jooq.jooq_dsl.tables.ArticleIfo.ARTICLE_IFO import jooq.jooq_dsl.tables.ArticleMainCard.ARTICLE_MAIN_CARD import org.jooq.* import org.jooq.impl.DSL.* @@ -38,8 +40,11 @@ class ArticleMainCardDao( ).`as`(ArticleMainCardRecord::writerName.name), jsonGetAttribute(ARTICLE_MAIN_CARD.WRITER_DESCRIPTION, "url").`as`(ArticleMainCardRecord::writerUrl.name), jsonGetAttribute(ARTICLE_MAIN_CARD.WRITER_DESCRIPTION, "imageUrl").`as`(ArticleMainCardRecord::writerImgUrl.name), - ARTICLE_MAIN_CARD.WORKBOOKS.`as`(ArticleMainCardRecord::workbooks.name) + ARTICLE_MAIN_CARD.WORKBOOKS.`as`(ArticleMainCardRecord::workbooks.name), + ARTICLE_IFO.CONTENT.`as`(ArticleMainCardRecord::content.name) ).from(ARTICLE_MAIN_CARD) + .join(ARTICLE_IFO) + .on(ARTICLE_MAIN_CARD.ID.eq(ArticleIfo.ARTICLE_IFO.ARTICLE_MST_ID)) .where(ARTICLE_MAIN_CARD.ID.`in`(articleIds)) .query diff --git a/api-repo/src/main/kotlin/com/few/api/repo/dao/article/record/ArticleMainCardRecord.kt b/api-repo/src/main/kotlin/com/few/api/repo/dao/article/record/ArticleMainCardRecord.kt index a3719f451..787614006 100644 --- a/api-repo/src/main/kotlin/com/few/api/repo/dao/article/record/ArticleMainCardRecord.kt +++ b/api-repo/src/main/kotlin/com/few/api/repo/dao/article/record/ArticleMainCardRecord.kt @@ -15,12 +15,8 @@ data class ArticleMainCardRecord( val writerUrl: URL, val writerImgUrl: URL, val workbooks: List = emptyList(), + val content: String = "", ) { - var content: String = "" - set(value) { - field = value - } - var views: Long = 0L set(value) { field = value diff --git a/api-repo/src/main/kotlin/com/few/api/repo/dao/article/support/ArticleMainCardMapper.kt b/api-repo/src/main/kotlin/com/few/api/repo/dao/article/support/ArticleMainCardMapper.kt index 68acf9d9d..0d0f1cf4b 100644 --- a/api-repo/src/main/kotlin/com/few/api/repo/dao/article/support/ArticleMainCardMapper.kt +++ b/api-repo/src/main/kotlin/com/few/api/repo/dao/article/support/ArticleMainCardMapper.kt @@ -37,7 +37,8 @@ class ArticleMainCardMapper( } } ?: run { emptyList() - } + }, + content = record.get(ArticleMainCardRecord::content.name, String::class.java) ) fun toJsonStr(workbooks: List) = objectMapper.writeValueAsString(workbooks) diff --git a/api/src/main/kotlin/com/few/api/domain/article/usecase/BrowseArticlesUseCase.kt b/api/src/main/kotlin/com/few/api/domain/article/usecase/BrowseArticlesUseCase.kt index 357ea7e5c..fdfd70278 100644 --- a/api/src/main/kotlin/com/few/api/domain/article/usecase/BrowseArticlesUseCase.kt +++ b/api/src/main/kotlin/com/few/api/domain/article/usecase/BrowseArticlesUseCase.kt @@ -5,7 +5,6 @@ import com.few.api.exception.common.NotFoundException import com.few.api.repo.dao.article.ArticleDao import com.few.api.repo.dao.article.ArticleMainCardDao import com.few.api.repo.dao.article.record.ArticleMainCardRecord -import com.few.api.repo.dao.article.record.SelectArticleContentsRecord import com.few.data.common.code.CategoryType import org.springframework.stereotype.Component import java.util.* @@ -24,12 +23,6 @@ class BrowseArticlesUseCase( val articleIds = limitedArticleViewsRecords.map { it.articleId }.toSet() val articleMainCardRecords: List = articleMainCardDao.selectArticleMainCardsRecord(articleIds) - val selectArticleContentsRecords: List = articleDao.selectArticleContents(articleIds) - - val contentsMap = selectArticleContentsRecords.associateBy { it.articleId } - articleMainCardRecords.forEach { record -> - record.content = contentsMap[record.articleId]?.content ?: "" - } val articleUseCaseOuts: List = articleMainCardRecords