mirror of
https://github.com/gotson/komga.git
synced 2025-12-21 16:03:03 +01:00
feat(api): filter collection's series
This commit is contained in:
parent
d7fd296492
commit
cfa06a9d2b
3 changed files with 29 additions and 6 deletions
|
|
@ -72,11 +72,12 @@ class SeriesDtoDao(
|
|||
return findAll(conditions, having, userId, pageable, search.toJoinConditions())
|
||||
}
|
||||
|
||||
override fun findByCollectionId(collectionId: String, userId: String, pageable: Pageable): Page<SeriesDto> {
|
||||
val conditions = cs.COLLECTION_ID.eq(collectionId)
|
||||
val having = DSL.trueCondition()
|
||||
override fun findByCollectionId(collectionId: String, search: SeriesSearchWithReadProgress, userId: String, pageable: Pageable): Page<SeriesDto> {
|
||||
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<SeriesDto> {
|
||||
|
|
|
|||
|
|
@ -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<String>?,
|
||||
@RequestParam(name = "status", required = false) metadataStatus: List<SeriesMetadata.Status>?,
|
||||
@RequestParam(name = "read_status", required = false) readStatus: List<ReadStatus>?,
|
||||
@RequestParam(name = "publisher", required = false) publishers: List<String>?,
|
||||
@RequestParam(name = "language", required = false) languages: List<String>?,
|
||||
@RequestParam(name = "genre", required = false) genres: List<String>?,
|
||||
@RequestParam(name = "tag", required = false) tags: List<String>?,
|
||||
@RequestParam(name = "age_rating", required = false) ageRatings: List<String>?,
|
||||
@RequestParam(name = "unpaged", required = false) unpaged: Boolean = false,
|
||||
@Parameter(hidden = true) page: Pageable
|
||||
): Page<SeriesDto> =
|
||||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import org.springframework.data.domain.Pageable
|
|||
|
||||
interface SeriesDtoRepository {
|
||||
fun findAll(search: SeriesSearchWithReadProgress, userId: String, pageable: Pageable): Page<SeriesDto>
|
||||
fun findByCollectionId(collectionId: String, userId: String, pageable: Pageable): Page<SeriesDto>
|
||||
fun findByCollectionId(collectionId: String, search: SeriesSearchWithReadProgress, userId: String, pageable: Pageable): Page<SeriesDto>
|
||||
fun findRecentlyUpdated(search: SeriesSearchWithReadProgress, userId: String, pageable: Pageable): Page<SeriesDto>
|
||||
fun findByIdOrNull(seriesId: String, userId: String): SeriesDto?
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue