diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/model/BookSearch.kt b/komga/src/main/kotlin/org/gotson/komga/domain/model/BookSearch.kt index 3bdcb47c6..868f21365 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/model/BookSearch.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/model/BookSearch.kt @@ -4,7 +4,8 @@ open class BookSearch( val libraryIds: Collection? = null, val seriesIds: Collection? = null, val searchTerm: String? = null, - val mediaStatus: Collection? = null + val mediaStatus: Collection? = null, + val tags: Collection? = null ) class BookSearchWithReadProgress( @@ -12,6 +13,7 @@ class BookSearchWithReadProgress( seriesIds: Collection? = null, searchTerm: String? = null, mediaStatus: Collection? = null, + tags: Collection? = null, val readStatus: Collection? = null -) : BookSearch(libraryIds, seriesIds, searchTerm, mediaStatus) +) : BookSearch(libraryIds, seriesIds, searchTerm, mediaStatus, tags) diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/BookDtoDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/BookDtoDao.kt index b63dc2f59..58b14dfff 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/BookDtoDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/BookDtoDao.kt @@ -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 { diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/BookController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/BookController.kt index a9b1eef98..eb83b70c1 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/BookController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/BookController.kt @@ -89,6 +89,7 @@ class BookController( @RequestParam(name = "library_id", required = false) libraryIds: List?, @RequestParam(name = "media_status", required = false) mediaStatus: List?, @RequestParam(name = "read_status", required = false) readStatus: List?, + @RequestParam(name = "tag", required = false) tags: List?, @RequestParam(name = "unpaged", required = false) unpaged: Boolean = false, @Parameter(hidden = true) page: Pageable ): Page { @@ -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)