fix prod api
This commit is contained in:
parent
9633983dec
commit
bd46d5ae52
@ -496,19 +496,18 @@ object ProductCtrl {
|
|||||||
?: throw NotFoundResponse("Product not found for $id")
|
?: throw NotFoundResponse("Product not found for $id")
|
||||||
ctx.json(product).status(HttpStatus.OK)
|
ctx.json(product).status(HttpStatus.OK)
|
||||||
}
|
}
|
||||||
|
data class PF(val common: CommonFilters, val productFilters: ProductFilters)
|
||||||
fun getAll(ctx: Context) {
|
fun getAll(ctx: Context) {
|
||||||
val productList = database.find(Product::class.java)
|
val filters = ctx.bodyAsClass<PF>()
|
||||||
.findList()
|
val prods = searchProducts(filters.common, filters.productFilters)
|
||||||
.sortedBy { it.name }
|
|
||||||
val excel = ctx.queryParam("excel")
|
val excel = ctx.queryParam("excel")
|
||||||
if(excel != null){
|
if(excel != null){
|
||||||
exportProds(productList)
|
exportProds(prods)
|
||||||
val inputStream = FileInputStream("./excel/Products.xls")
|
val inputStream = FileInputStream("./excel/Products.xls")
|
||||||
ctx.result(inputStream).status(HttpStatus.OK)
|
ctx.result(inputStream).status(HttpStatus.OK)
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
ctx.json(productList).status(HttpStatus.OK)
|
ctx.json(prods).status(HttpStatus.OK)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user