mirror of
https://github.com/gotson/komga.git
synced 2025-12-22 00:13:30 +01:00
feat(api): search books by tag
This commit is contained in:
parent
723d7c1fe9
commit
f46f1a0e96
3 changed files with 11 additions and 3 deletions
|
|
@ -4,7 +4,8 @@ open class BookSearch(
|
|||
val libraryIds: Collection<String>? = null,
|
||||
val seriesIds: Collection<String>? = null,
|
||||
val searchTerm: String? = null,
|
||||
val mediaStatus: Collection<Media.Status>? = null
|
||||
val mediaStatus: Collection<Media.Status>? = null,
|
||||
val tags: Collection<String>? = null
|
||||
)
|
||||
|
||||
class BookSearchWithReadProgress(
|
||||
|
|
@ -12,6 +13,7 @@ class BookSearchWithReadProgress(
|
|||
seriesIds: Collection<String>? = null,
|
||||
searchTerm: String? = null,
|
||||
mediaStatus: Collection<Media.Status>? = null,
|
||||
tags: Collection<String>? = null,
|
||||
val readStatus: Collection<ReadStatus>? = null
|
||||
) : BookSearch(libraryIds, seriesIds, searchTerm, mediaStatus)
|
||||
) : BookSearch(libraryIds, seriesIds, searchTerm, mediaStatus, tags)
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import org.jooq.Record
|
|||
import org.jooq.ResultQuery
|
||||
import org.jooq.impl.DSL
|
||||
import org.jooq.impl.DSL.inline
|
||||
import org.jooq.impl.DSL.lower
|
||||
import org.springframework.data.domain.Page
|
||||
import org.springframework.data.domain.PageImpl
|
||||
import org.springframework.data.domain.PageRequest
|
||||
|
|
@ -76,6 +77,7 @@ class BookDtoDao(
|
|||
.leftJoin(m).on(b.ID.eq(m.BOOK_ID))
|
||||
.leftJoin(d).on(b.ID.eq(d.BOOK_ID))
|
||||
.leftJoin(r).on(b.ID.eq(r.BOOK_ID))
|
||||
.leftJoin(bt).on(b.ID.eq(bt.BOOK_ID))
|
||||
.and(readProgressCondition(userId))
|
||||
.leftJoin(rlb).on(b.ID.eq(rlb.BOOK_ID))
|
||||
.where(conditions)
|
||||
|
|
@ -178,6 +180,7 @@ class BookDtoDao(
|
|||
.leftJoin(m).on(b.ID.eq(m.BOOK_ID))
|
||||
.leftJoin(d).on(b.ID.eq(d.BOOK_ID))
|
||||
.leftJoin(r).on(b.ID.eq(r.BOOK_ID))
|
||||
.leftJoin(bt).on(b.ID.eq(bt.BOOK_ID))
|
||||
.and(readProgressCondition(userId))
|
||||
.leftJoin(rlb).on(b.ID.eq(rlb.BOOK_ID))
|
||||
|
||||
|
|
@ -210,6 +213,7 @@ class BookDtoDao(
|
|||
seriesIds?.let { c = c.and(b.SERIES_ID.`in`(it)) }
|
||||
searchTerm?.let { c = c.and(d.TITLE.containsIgnoreCase(it)) }
|
||||
mediaStatus?.let { c = c.and(m.STATUS.`in`(it)) }
|
||||
tags?.let { tags -> c = c.and(lower(bt.TAG).`in`(tags.map { it.toLowerCase() })) }
|
||||
|
||||
if (readStatus != null) {
|
||||
val cr = readStatus.map {
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ class BookController(
|
|||
@RequestParam(name = "library_id", required = false) libraryIds: List<String>?,
|
||||
@RequestParam(name = "media_status", required = false) mediaStatus: List<Media.Status>?,
|
||||
@RequestParam(name = "read_status", required = false) readStatus: List<ReadStatus>?,
|
||||
@RequestParam(name = "tag", required = false) tags: List<String>?,
|
||||
@RequestParam(name = "unpaged", required = false) unpaged: Boolean = false,
|
||||
@Parameter(hidden = true) page: Pageable
|
||||
): Page<BookDto> {
|
||||
|
|
@ -108,7 +109,8 @@ class BookController(
|
|||
libraryIds = principal.user.getAuthorizedLibraryIds(libraryIds),
|
||||
searchTerm = searchTerm,
|
||||
mediaStatus = mediaStatus,
|
||||
readStatus = readStatus
|
||||
readStatus = readStatus,
|
||||
tags = tags
|
||||
)
|
||||
|
||||
return bookDtoRepository.findAll(bookSearch, principal.user.id, pageRequest)
|
||||
|
|
|
|||
Loading…
Reference in a new issue