refactor: remove duplicated code

This commit is contained in:
Gauthier Roebroeck 2025-01-02 14:52:11 +08:00
parent 0dd4b270ef
commit 274ac6aae1
2 changed files with 2 additions and 3 deletions

View File

@ -61,8 +61,7 @@ class BookSearchHelper(
when (searchCondition.operator) {
// for IS condition we have to do a join, so as to order the books by readList number
is SearchOperator.Is ->
Tables.READLIST_BOOK
.`as`("RLB_${searchCondition.operator.value}")
rlbAlias(searchCondition.operator.value)
.READLIST_ID
.eq(searchCondition.operator.value) to setOf(RequiredJoin.ReadList(searchCondition.operator.value))
is SearchOperator.IsNot -> {

View File

@ -134,7 +134,7 @@ class BookDtoDao(
} else {
if (it.property == "readList.number") {
val readListId = joins.filterIsInstance<RequiredJoin.ReadList>().firstOrNull()?.readListId ?: return@mapNotNull null
val f = rlb.`as`("RLB_$readListId").NUMBER
val f = rlbAlias(readListId).NUMBER
if (it.isAscending) f.asc() else f.desc()
} else {
it.toSortField(sorts)