Skip to content

Commit

Permalink
default sort series by name ignoring case
Browse files Browse the repository at this point in the history
  • Loading branch information
gotson committed Aug 21, 2019
1 parent 43daabd commit 0435122
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,20 @@ class SerieController(
searchTerm: String?,

page: Pageable
): Page<SerieDto> =
if (!searchTerm.isNullOrEmpty()) {
val spec = Serie::name.likeLower("%$searchTerm%")
serieRepository.findAll(spec, page)
} else {
serieRepository.findAll(page)
}.map { it.toDto() }
): Page<SerieDto> {
val pageRequest = PageRequest.of(
page.pageNumber,
page.pageSize,
if (page.sort.isSorted) page.sort
else Sort.by(Sort.Order.asc("name").ignoreCase())
)
return if (!searchTerm.isNullOrEmpty()) {
val spec = Serie::name.likeLower("%$searchTerm%")
serieRepository.findAll(spec, pageRequest)
} else {
serieRepository.findAll(pageRequest)
}.map { it.toDto() }
}

@GetMapping("/latest")
fun getLatestSeries(
Expand Down

0 comments on commit 0435122

Please sign in to comment.