Skip to content

Commit f38d2ed

Browse files
committed
fix : 정렬 기준 버그 수정
1 parent 1ecb97d commit f38d2ed

File tree

1 file changed

+12
-6
lines changed
  • adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/category/impl

1 file changed

+12
-6
lines changed

adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/category/impl/CategoryAdapter.kt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,18 @@ class CategoryAdapter(
5050
}
5151

5252
override fun loadAllInId(categoryIds: List<Long>, pageable: Pageable): Slice<Category> {
53-
return if (pageable.sort.equals("createdAt")) {
54-
categoryRepository.findAllByIdInAndCreatedAtSort(categoryIds, pageable, false)
55-
.map { it.toDomain() }
56-
} else {
57-
categoryRepository.findAllByIdInAndNameSort(categoryIds, pageable, false)
58-
.map { it.toDomain() }
53+
val order = pageable.sort.firstOrNull()
54+
val property = order?.property
55+
56+
return when (property) {
57+
"createdAt" -> {
58+
categoryRepository.findAllByIdInAndCreatedAtSort(categoryIds, pageable, false)
59+
.map { it.toDomain() }
60+
}
61+
else -> {
62+
categoryRepository.findAllByIdInAndNameSort(categoryIds, pageable, false)
63+
.map { it.toDomain() }
64+
}
5965
}
6066
}
6167

0 commit comments

Comments
 (0)