mirror of
https://github.com/gotson/komga.git
synced 2025-12-22 00:13:30 +01:00
feat(api): search books by media status
This commit is contained in:
parent
55d9bc6744
commit
07905018e5
1 changed files with 6 additions and 0 deletions
|
|
@ -2,6 +2,7 @@ package org.gotson.komga.interfaces.rest
|
|||
|
||||
import com.github.klinq.jpaspec.`in`
|
||||
import com.github.klinq.jpaspec.likeLower
|
||||
import com.github.klinq.jpaspec.toJoin
|
||||
import mu.KotlinLogging
|
||||
import org.gotson.komga.application.service.AsyncOrchestrator
|
||||
import org.gotson.komga.application.service.BookLifecycle
|
||||
|
|
@ -62,6 +63,7 @@ class BookController(
|
|||
@AuthenticationPrincipal principal: KomgaPrincipal,
|
||||
@RequestParam(name = "search", required = false) searchTerm: String?,
|
||||
@RequestParam(name = "library_id", required = false) libraryIds: List<Long>?,
|
||||
@RequestParam(name = "media_status", required = false) mediaStatus: List<Media.Status>?,
|
||||
page: Pageable
|
||||
): Page<BookDto> {
|
||||
val pageRequest = PageRequest.of(
|
||||
|
|
@ -90,6 +92,10 @@ class BookController(
|
|||
specs.add(Book::name.likeLower("%$searchTerm%"))
|
||||
}
|
||||
|
||||
if (!mediaStatus.isNullOrEmpty()) {
|
||||
specs.add(Book::media.toJoin().where(Media::status).`in`(mediaStatus))
|
||||
}
|
||||
|
||||
if (specs.isNotEmpty()) {
|
||||
bookRepository.findAll(specs.reduce { acc, spec -> acc.and(spec)!! }, pageRequest)
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue