mirror of
https://github.com/gotson/komga.git
synced 2025-12-22 00:13:30 +01:00
feat(api): get all age ratings
This commit is contained in:
parent
93efd98f68
commit
be80d86d6c
3 changed files with 27 additions and 0 deletions
|
|
@ -15,4 +15,7 @@ interface ReferentialRepository {
|
|||
|
||||
fun findAllPublishers(): Set<String>
|
||||
fun findAllPublishersByLibrary(libraryId: String): Set<String>
|
||||
|
||||
fun findAllAgeRatings(): Set<Int?>
|
||||
fun findAllAgeRatingsByLibrary(libraryId: String): Set<Int?>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,4 +98,18 @@ class ReferentialDao(
|
|||
.and(s.LIBRARY_ID.eq(libraryId))
|
||||
.orderBy(sd.PUBLISHER)
|
||||
.fetchSet(sd.PUBLISHER)
|
||||
|
||||
override fun findAllAgeRatings(): Set<Int> =
|
||||
dsl.selectDistinct(sd.AGE_RATING)
|
||||
.from(sd)
|
||||
.orderBy(sd.AGE_RATING)
|
||||
.fetchSet(sd.AGE_RATING)
|
||||
|
||||
override fun findAllAgeRatingsByLibrary(libraryId: String): Set<Int> =
|
||||
dsl.selectDistinct(sd.AGE_RATING)
|
||||
.from(sd)
|
||||
.leftJoin(s).on(sd.SERIES_ID.eq(s.ID))
|
||||
.where(s.LIBRARY_ID.eq(libraryId))
|
||||
.orderBy(sd.AGE_RATING)
|
||||
.fetchSet(sd.AGE_RATING)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,4 +51,14 @@ class ReferentialController(
|
|||
): Set<String> =
|
||||
if (libraryId != null) referentialRepository.findAllPublishersByLibrary(libraryId)
|
||||
else referentialRepository.findAllPublishers()
|
||||
|
||||
@GetMapping("/age-ratings")
|
||||
fun getAgeRatings(
|
||||
@RequestParam(name = "library_id", required = false) libraryId: String?
|
||||
): Set<String> =
|
||||
if (libraryId != null) {
|
||||
referentialRepository.findAllAgeRatingsByLibrary(libraryId)
|
||||
} else {
|
||||
referentialRepository.findAllAgeRatings()
|
||||
}.map { it?.toString() ?: "None" }.toSet()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue