mirror of
https://github.com/gotson/komga.git
synced 2025-12-21 16:03:03 +01:00
feat(api): search series by age rating
This commit is contained in:
parent
be80d86d6c
commit
f51d575bda
3 changed files with 11 additions and 3 deletions
|
|
@ -16,6 +16,7 @@ class SeriesSearchWithReadProgress(
|
|||
val languages: Collection<String>? = null,
|
||||
val genres: Collection<String>? = null,
|
||||
val tags: Collection<String>? = null,
|
||||
val ageRatings: Collection<Int?>? = null,
|
||||
val readStatus: Collection<ReadStatus>? = null
|
||||
) : SeriesSearch(
|
||||
libraryIds = libraryIds,
|
||||
|
|
|
|||
|
|
@ -198,6 +198,11 @@ class SeriesDtoDao(
|
|||
if (!languages.isNullOrEmpty()) c = c.and(lower(d.LANGUAGE).`in`(languages.map { it.toLowerCase() }))
|
||||
if (!genres.isNullOrEmpty()) c = c.and(lower(g.GENRE).`in`(genres.map { it.toLowerCase() }))
|
||||
if (!tags.isNullOrEmpty()) c = c.and(lower(st.TAG).`in`(tags.map { it.toLowerCase() }))
|
||||
if (!ageRatings.isNullOrEmpty()) {
|
||||
val c1 = if (ageRatings.contains(null)) d.AGE_RATING.isNull else DSL.falseCondition()
|
||||
val c2 = if (ageRatings.filterNotNull().isNotEmpty()) d.AGE_RATING.`in`(ageRatings.filterNotNull()) else DSL.falseCondition()
|
||||
c = c.and(c1.or(c2))
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ class SeriesController(
|
|||
@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> {
|
||||
|
|
@ -105,7 +106,8 @@ class SeriesController(
|
|||
publishers = publishers,
|
||||
languages = languages,
|
||||
genres = genres,
|
||||
tags = tags
|
||||
tags = tags,
|
||||
ageRatings = ageRatings?.map { it.toIntOrNull() }
|
||||
)
|
||||
|
||||
return seriesDtoRepository.findAll(seriesSearch, principal.user.id, pageRequest)
|
||||
|
|
@ -311,8 +313,8 @@ class SeriesController(
|
|||
if (genres != null) genres!! else emptySet()
|
||||
} else existing.genres,
|
||||
genresLock = genresLock ?: existing.genresLock,
|
||||
tags = if(isSet("tags")) {
|
||||
if(tags != null) tags!! else emptySet()
|
||||
tags = if (isSet("tags")) {
|
||||
if (tags != null) tags!! else emptySet()
|
||||
} else existing.tags,
|
||||
tagsLock = tagsLock ?: existing.tagsLock
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue