added endpoint for serie thumbnail

This commit is contained in:
Gauthier Roebroeck 2019-08-20 19:45:47 +08:00
parent cb867ff519
commit 5619661d95

View file

@ -64,6 +64,15 @@ class SerieController(
): SerieDto =
serieRepository.findByIdOrNull(id)?.toDto() ?: throw ResponseStatusException(HttpStatus.NOT_FOUND)
@GetMapping(value = ["{serieId}/thumbnail"], produces = [MediaType.IMAGE_PNG_VALUE])
fun getSerieThumbnail(
@PathVariable serieId: Long
): ByteArray {
return serieRepository.findByIdOrNull(serieId)?.let {
it.books.firstOrNull()?.metadata?.thumbnail ?: throw ResponseStatusException(HttpStatus.NO_CONTENT)
} ?: throw ResponseStatusException(HttpStatus.NOT_FOUND)
}
@GetMapping("{id}/books")
fun getAllBooksBySerie(
@PathVariable id: Long,