diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDtoDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDtoDao.kt index 73196ba7f..0c9a6b13c 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDtoDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDtoDao.kt @@ -72,11 +72,12 @@ class SeriesDtoDao( return findAll(conditions, having, userId, pageable, search.toJoinConditions()) } - override fun findByCollectionId(collectionId: String, userId: String, pageable: Pageable): Page { - val conditions = cs.COLLECTION_ID.eq(collectionId) - val having = DSL.trueCondition() + override fun findByCollectionId(collectionId: String, search: SeriesSearchWithReadProgress, userId: String, pageable: Pageable): Page { + val conditions = search.toCondition().and(cs.COLLECTION_ID.eq(collectionId)) + val having = search.readStatus?.toCondition() ?: DSL.trueCondition() + val joinConditions = search.toJoinConditions().copy(selectCollectionNumber = true, collection = true) - return findAll(conditions, having, userId, pageable, JoinConditions(selectCollectionNumber = true, collection = true)) + return findAll(conditions, having, userId, pageable, joinConditions) } override fun findRecentlyUpdated(search: SeriesSearchWithReadProgress, userId: String, pageable: Pageable): Page { diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/SeriesCollectionController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/SeriesCollectionController.kt index a2d873a2a..389831e85 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/SeriesCollectionController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/SeriesCollectionController.kt @@ -7,7 +7,10 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse import mu.KotlinLogging import org.gotson.komga.domain.model.DuplicateNameException import org.gotson.komga.domain.model.ROLE_ADMIN +import org.gotson.komga.domain.model.ReadStatus import org.gotson.komga.domain.model.SeriesCollection +import org.gotson.komga.domain.model.SeriesMetadata +import org.gotson.komga.domain.model.SeriesSearchWithReadProgress import org.gotson.komga.domain.persistence.SeriesCollectionRepository import org.gotson.komga.domain.service.SeriesCollectionLifecycle import org.gotson.komga.infrastructure.jooq.UnpagedSorted @@ -153,6 +156,14 @@ class SeriesCollectionController( fun getSeriesForCollection( @PathVariable id: String, @AuthenticationPrincipal principal: KomgaPrincipal, + @RequestParam(name = "library_id", required = false) libraryIds: List?, + @RequestParam(name = "status", required = false) metadataStatus: List?, + @RequestParam(name = "read_status", required = false) readStatus: List?, + @RequestParam(name = "publisher", required = false) publishers: List?, + @RequestParam(name = "language", required = false) languages: List?, + @RequestParam(name = "genre", required = false) genres: List?, + @RequestParam(name = "tag", required = false) tags: List?, + @RequestParam(name = "age_rating", required = false) ageRatings: List?, @RequestParam(name = "unpaged", required = false) unpaged: Boolean = false, @Parameter(hidden = true) page: Pageable ): Page = @@ -169,7 +180,18 @@ class SeriesCollectionController( sort ) - seriesDtoRepository.findByCollectionId(collection.id, principal.user.id, pageRequest) + val seriesSearch = SeriesSearchWithReadProgress( + libraryIds = principal.user.getAuthorizedLibraryIds(libraryIds), + metadataStatus = metadataStatus, + readStatus = readStatus, + publishers = publishers, + languages = languages, + genres = genres, + tags = tags, + ageRatings = ageRatings?.map { it.toIntOrNull() } + ) + + seriesDtoRepository.findByCollectionId(collection.id, seriesSearch, principal.user.id, pageRequest) .map { it.restrictUrl(!principal.user.roleAdmin) } } ?: throw ResponseStatusException(HttpStatus.NOT_FOUND) } diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/persistence/SeriesDtoRepository.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/persistence/SeriesDtoRepository.kt index 6dbcd110b..06fe6ad68 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/persistence/SeriesDtoRepository.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/persistence/SeriesDtoRepository.kt @@ -7,7 +7,7 @@ import org.springframework.data.domain.Pageable interface SeriesDtoRepository { fun findAll(search: SeriesSearchWithReadProgress, userId: String, pageable: Pageable): Page - fun findByCollectionId(collectionId: String, userId: String, pageable: Pageable): Page + fun findByCollectionId(collectionId: String, search: SeriesSearchWithReadProgress, userId: String, pageable: Pageable): Page fun findRecentlyUpdated(search: SeriesSearchWithReadProgress, userId: String, pageable: Pageable): Page fun findByIdOrNull(seriesId: String, userId: String): SeriesDto? }