From 789f0873a7d0c9ca0d0d05bc5a81d76a74cfc4df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=9D=B8=EC=A4=80?= <54973090+dlswns2480@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:39:43 +0900 Subject: [PATCH] =?UTF-8?q?[feat=20#175]=20=EB=A7=81=ED=81=AC=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=EC=A6=90=EA=B2=A8?= =?UTF-8?q?=EC=B0=BE=EA=B8=B0=20=ED=95=84=EB=93=9C=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?(#176)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat : 링크 목록 조회 시 북마크 left join 추가 * feat : 링크 목록 응답 dto 즐겨찾기 필드 추가 --- .../content/dto/response/ContentsResponse.kt | 4 +++- .../content/impl/ContentAdapter.kt | 19 ++++++++++++------- .../content/dto/response/ContentsResult.kt | 8 +++++--- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/adapters/in-web/src/main/kotlin/com/pokit/content/dto/response/ContentsResponse.kt b/adapters/in-web/src/main/kotlin/com/pokit/content/dto/response/ContentsResponse.kt index 5ccb8afa..2c965558 100644 --- a/adapters/in-web/src/main/kotlin/com/pokit/content/dto/response/ContentsResponse.kt +++ b/adapters/in-web/src/main/kotlin/com/pokit/content/dto/response/ContentsResponse.kt @@ -15,6 +15,7 @@ data class ContentsResponse( val createdAt: String, val isRead: Boolean, val thumbNail: String, + val isFavorite: Boolean ) fun ContentsResult.toResponse(): ContentsResponse { @@ -30,6 +31,7 @@ fun ContentsResult.toResponse(): ContentsResponse { alertYn = this.alertYn, createdAt = this.createdAt.format(formatter), isRead = this.isRead, - thumbNail = this.thumbNail + thumbNail = this.thumbNail, + isFavorite = this.isFavorite ) } diff --git a/adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/content/impl/ContentAdapter.kt b/adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/content/impl/ContentAdapter.kt index d2ab7a3f..b4691db3 100644 --- a/adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/content/impl/ContentAdapter.kt +++ b/adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/content/impl/ContentAdapter.kt @@ -61,10 +61,11 @@ class ContentAdapter( condition: ContentSearchCondition, pageable: Pageable, ): Slice { - val query = queryFactory.select(contentEntity, categoryEntity.name, userLogEntity.count()) + val query = queryFactory.select(contentEntity, categoryEntity.name, userLogEntity.count(), bookmarkEntity.count()) .from(contentEntity) .leftJoin(userLogEntity).on(userLogEntity.contentId.eq(contentEntity.id)) .join(categoryEntity).on(categoryEntity.id.eq(contentEntity.categoryId)) + .leftJoin(bookmarkEntity).on(bookmarkEntity.contentId.eq(contentEntity.id)) FavoriteOrNot(condition.favorites, query) // 북마크 조인 여부 @@ -90,7 +91,8 @@ class ContentAdapter( ContentsResult.of( it[contentEntity]!!.toDomain(), it[categoryEntity.name]!!, - it[userLogEntity.count()]!! + it[userLogEntity.count()]!!, + it[bookmarkEntity.count()]!! ) } @@ -98,10 +100,11 @@ class ContentAdapter( } override fun loadByUserIdAndCategoryName(userId: Long, categoryName: String, pageable: Pageable): Slice { - val contents = queryFactory.select(contentEntity, categoryEntity.name, userLogEntity.count()) + val contents = queryFactory.select(contentEntity, categoryEntity.name, userLogEntity.count(), bookmarkEntity.count()) .from(contentEntity) .leftJoin(userLogEntity).on(userLogEntity.contentId.eq(contentEntity.id)) .join(categoryEntity).on(categoryEntity.id.eq(contentEntity.categoryId)) + .leftJoin(bookmarkEntity).on(bookmarkEntity.contentId.eq(contentEntity.id)) .where( categoryEntity.userId.eq(userId), categoryEntity.name.eq(categoryName), @@ -119,7 +122,8 @@ class ContentAdapter( ContentsResult.of( it[contentEntity]!!.toDomain(), it[categoryEntity.name]!!, - it[userLogEntity.count()]!! + it[userLogEntity.count()]!!, + it[bookmarkEntity.count()]!! ) } @@ -127,11 +131,11 @@ class ContentAdapter( } override fun loadBookmarkedContentsByUserId(userId: Long, pageable: Pageable): Slice { - val contents = queryFactory.select(contentEntity, categoryEntity.name, userLogEntity.count()) + val contents = queryFactory.select(contentEntity, categoryEntity.name, userLogEntity.count(), bookmarkEntity.count()) .from(contentEntity) .leftJoin(userLogEntity).on(userLogEntity.contentId.eq(contentEntity.id)) .join(categoryEntity).on(categoryEntity.id.eq(contentEntity.categoryId)) - .join(bookmarkEntity).on(bookmarkEntity.contentId.eq(contentEntity.id)) + .leftJoin(bookmarkEntity).on(bookmarkEntity.contentId.eq(contentEntity.id)) .where( categoryEntity.userId.eq(userId), contentEntity.deleted.isFalse, @@ -149,7 +153,8 @@ class ContentAdapter( ContentsResult.of( it[contentEntity]!!.toDomain(), it[categoryEntity.name]!!, - it[userLogEntity.count()]!! + it[userLogEntity.count()]!!, + it[bookmarkEntity.count()]!! ) } diff --git a/domain/src/main/kotlin/com/pokit/content/dto/response/ContentsResult.kt b/domain/src/main/kotlin/com/pokit/content/dto/response/ContentsResult.kt index 8d92247f..a08a0e5b 100644 --- a/domain/src/main/kotlin/com/pokit/content/dto/response/ContentsResult.kt +++ b/domain/src/main/kotlin/com/pokit/content/dto/response/ContentsResult.kt @@ -15,10 +15,11 @@ data class ContentsResult( val alertYn: String, val createdAt: LocalDateTime, val isRead: Boolean, - val thumbNail: String + val thumbNail: String, + val isFavorite: Boolean ) { companion object { - fun of(content: Content, categoryName: String, isRead: Long): ContentsResult { + fun of(content: Content, categoryName: String, isRead: Long, isFavorite: Long): ContentsResult { return ContentsResult( contentId = content.id, category = RemindCategory(content.categoryId, categoryName), @@ -29,7 +30,8 @@ data class ContentsResult( alertYn = content.alertYn, createdAt = content.createdAt, isRead = isRead > 0, - thumbNail = content.thumbNail ?: ContentDefault.THUMB_NAIL + thumbNail = content.thumbNail ?: ContentDefault.THUMB_NAIL, + isFavorite = isFavorite > 0 ) } }