From f7c33856f02bc2c1de7b5f0c579336578ac2a536 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: Sun, 12 Jan 2025 13:54:00 +0100 Subject: [PATCH] =?UTF-8?q?feat=20:=20=EC=B9=B4=ED=85=8C=EA=B3=A0=EB=A6=AC?= =?UTF-8?q?=20=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20=EC=BF=BC=EB=A6=AC?= =?UTF-8?q?=20=EC=A0=95=EB=A0=AC=20=EC=A1=B0=EA=B1=B4=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=20(#220)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../category/persist/CategoryRepository.kt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/category/persist/CategoryRepository.kt b/adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/category/persist/CategoryRepository.kt index 4d36ff8..70884ac 100644 --- a/adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/category/persist/CategoryRepository.kt +++ b/adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/category/persist/CategoryRepository.kt @@ -4,6 +4,8 @@ import com.pokit.category.model.OpenType import org.springframework.data.domain.Pageable import org.springframework.data.domain.Slice import org.springframework.data.jpa.repository.JpaRepository +import org.springframework.data.jpa.repository.Query +import org.springframework.data.repository.query.Param interface CategoryRepository : JpaRepository { fun existsByNameAndUserIdAndDeleted(name: String, userId: Long, deleted: Boolean): Boolean @@ -12,9 +14,19 @@ interface CategoryRepository : JpaRepository { fun countByUserIdAndDeleted(userId: Long, deleted: Boolean): Int fun findByIdAndOpenTypeAndDeleted(id: Long, openType: OpenType, deleted: Boolean): CategoryEntity? fun findByNameAndUserId(name: String, userId: Long): CategoryEntity? + + @Query( + """ + select ca from CategoryEntity ca + join ContentEntity co on co.categoryId = ca.id + where ca.id in :categoryIds and ca.deleted = :isDeleted + group by ca.id + order by max(co.createdAt) desc + """ + ) fun findAllByIdInAndDeleted( - categoryIds: List, + @Param("categoryIds") categoryIds: List, pageable: Pageable, - isDeleted: Boolean + @Param("isDeleted") isDeleted: Boolean ): Slice }