Skip to content

Commit

Permalink
FEATURE : add search criteria in controller #4
Browse files Browse the repository at this point in the history
  • Loading branch information
stephano-tri committed Aug 22, 2024
1 parent 27ebbb5 commit 83aac1d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package eom.improve.kafkaboot.common

// change SearchCriteria to data class
data class SearchCriteria(
var name: String? = null,
var from: Int? = null,
var to: Int? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import reactor.core.publisher.Mono
interface FilmController {

@GetMapping("/list/all")
fun getAllFilms() : Mono<List<Film>>
fun getAllFilms(@RequestParam name : String?,
@RequestParam from : Int?,
@RequestParam to : Int?) : Mono<List<Film>>

@GetMapping("/list/{page}/{limit}")
fun getFilms(@PathVariable page: Long, @PathVariable limit: Long) : Mono<PaginatedResponse<Film>>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package eom.improve.kafkaboot.service

import eom.improve.kafkaboot.common.PaginatedResponse
import eom.improve.kafkaboot.common.SearchCriteria
import eom.improve.kafkaboot.controller.FilmController
import eom.improve.kafkaboot.dto.Film
import org.springframework.data.domain.PageRequest
Expand All @@ -13,7 +14,7 @@ class FilmControllerImpl(
private val filmService: FilmService
) : FilmController{

override fun getAllFilms(): Mono<List<Film>> {
override fun getAllFilms(searchCriteria : SearchCriteria): Mono<List<Film>> {
return filmService.findAll().map { it.convert2Pojo() }
.collectSortedList((Comparator<Film> { o1, o2 -> o1.filmId.compareTo(o2.filmId) }))
}
Expand Down

0 comments on commit 83aac1d

Please sign in to comment.