refactor: Kotlin/JVMの制限のための変更

This commit is contained in:
usbharu 2024-01-29 18:03:48 +09:00
parent deb2d5b0b5
commit 69c8a18bd1
1 changed files with 1 additions and 15 deletions

View File

@ -1,25 +1,11 @@
package dev.usbharu.hideout.application.infrastructure.exposed
import org.jetbrains.exposed.dao.id.EntityID
import org.jetbrains.exposed.sql.ExpressionWithColumnType
import org.jetbrains.exposed.sql.Query
import org.jetbrains.exposed.sql.SortOrder
import org.jetbrains.exposed.sql.andWhere
fun Query.pagination(page: Page, exp: ExpressionWithColumnType<Long>): Query {
if (page.minId != null) {
page.maxId?.let { andWhere { exp.less(it) } }
page.minId?.let { andWhere { exp.greater(it) } }
} else {
page.maxId?.let { andWhere { exp.less(it) } }
page.sinceId?.let { andWhere { exp.greater(it) } }
this.orderBy(exp, SortOrder.DESC)
}
page.limit?.let { limit(it) }
return this
}
fun Query.pagination(page: Page, exp: ExpressionWithColumnType<EntityID<Long>>): Query {
fun <S> Query.pagination(page: Page, exp: ExpressionWithColumnType<S>): Query {
if (page.minId != null) {
page.maxId?.let { andWhere { exp.less(it) } }
page.minId?.let { andWhere { exp.greater(it) } }