I am trying to implement the scrolling API from Spring.
// Controller
@GetMapping("/api/v1/orders/{id}", produces = [MediaType.APPLICATION_JSON_VALUE])
fun readData(
@PathVariable id: Long
): List<DataDto> orderService.getOrdersid)
// Service
fun getOrders(customerId: Long): List<OrderDto> {
val customer = customerRepository.findById(customerId).getOrElse { return emptyList() }
val orders: WindowIterator<Order> = WindowIterator.of<Order> { position ->
orderRepsitory.findAllByCustomerOrderByCreated(customer, position as KeysetScrollPosition?)
}
.startingAt(ScrollPosition.keyset())
val ordersResult: MutableList<Orders> = ArrayList<Orders>()
orders.forEachRemaining { ordersResult.add(it) }
return ordersResult.map {
OrderDto(...)
}
}
// Order Respository
interface OrderRepository : JpaRepository<Order, Long> {
fun findAllByCustomerOrderByCreated(customer: Customer, position: KeysetScrollPosition?): Window<Order?>?
}
But when I send a GET
to /api/v1/orders/{id}
it returns
{
"timestamp": 1720698734440,
"status": 404,
"error": "Not Found",
"message": "No static resource api/v1/orders/api/v1/orders/0.",
"path": "/api/v1/orders/0"
}
I tried to query the entity Order
without the scrolling Api, so this
interface OrderRepository : JpaRepository<Order, Long> {
fun findAllByCustomerOrderByCreated(customer: Customer): List<Order>
works. Why doesn’t it work with the Window
?