diff --git a/src/main/kotlin/com/restapi/controllers/Entities.kt b/src/main/kotlin/com/restapi/controllers/Entities.kt index 49b072d..84388b2 100644 --- a/src/main/kotlin/com/restapi/controllers/Entities.kt +++ b/src/main/kotlin/com/restapi/controllers/Entities.kt @@ -496,19 +496,18 @@ object ProductCtrl { ?: throw NotFoundResponse("Product not found for $id") ctx.json(product).status(HttpStatus.OK) } - +data class PF(val common: CommonFilters, val productFilters: ProductFilters) fun getAll(ctx: Context) { - val productList = database.find(Product::class.java) - .findList() - .sortedBy { it.name } + val filters = ctx.bodyAsClass() + val prods = searchProducts(filters.common, filters.productFilters) val excel = ctx.queryParam("excel") if(excel != null){ - exportProds(productList) + exportProds(prods) val inputStream = FileInputStream("./excel/Products.xls") ctx.result(inputStream).status(HttpStatus.OK) }else{ - ctx.json(productList).status(HttpStatus.OK) + ctx.json(prods).status(HttpStatus.OK) } }