mirror of
https://github.com/gotson/komga.git
synced 2026-05-08 12:35:30 +02: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.`in`
|
||||||
import com.github.klinq.jpaspec.likeLower
|
import com.github.klinq.jpaspec.likeLower
|
||||||
|
import com.github.klinq.jpaspec.toJoin
|
||||||
import mu.KotlinLogging
|
import mu.KotlinLogging
|
||||||
import org.gotson.komga.application.service.AsyncOrchestrator
|
import org.gotson.komga.application.service.AsyncOrchestrator
|
||||||
import org.gotson.komga.application.service.BookLifecycle
|
import org.gotson.komga.application.service.BookLifecycle
|
||||||
|
|
@ -62,6 +63,7 @@ class BookController(
|
||||||
@AuthenticationPrincipal principal: KomgaPrincipal,
|
@AuthenticationPrincipal principal: KomgaPrincipal,
|
||||||
@RequestParam(name = "search", required = false) searchTerm: String?,
|
@RequestParam(name = "search", required = false) searchTerm: String?,
|
||||||
@RequestParam(name = "library_id", required = false) libraryIds: List<Long>?,
|
@RequestParam(name = "library_id", required = false) libraryIds: List<Long>?,
|
||||||
|
@RequestParam(name = "media_status", required = false) mediaStatus: List<Media.Status>?,
|
||||||
page: Pageable
|
page: Pageable
|
||||||
): Page<BookDto> {
|
): Page<BookDto> {
|
||||||
val pageRequest = PageRequest.of(
|
val pageRequest = PageRequest.of(
|
||||||
|
|
@ -90,6 +92,10 @@ class BookController(
|
||||||
specs.add(Book::name.likeLower("%$searchTerm%"))
|
specs.add(Book::name.likeLower("%$searchTerm%"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mediaStatus.isNullOrEmpty()) {
|
||||||
|
specs.add(Book::media.toJoin().where(Media::status).`in`(mediaStatus))
|
||||||
|
}
|
||||||
|
|
||||||
if (specs.isNotEmpty()) {
|
if (specs.isNotEmpty()) {
|
||||||
bookRepository.findAll(specs.reduce { acc, spec -> acc.and(spec)!! }, pageRequest)
|
bookRepository.findAll(specs.reduce { acc, spec -> acc.and(spec)!! }, pageRequest)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue