This commit is contained in:
2024-01-19 14:54:17 +05:30
parent 043cddcaa0
commit cb184dee3b
4 changed files with 29 additions and 18 deletions

View File

@@ -412,13 +412,25 @@ object PurchaseOrder {
}
}
data class ProductSearch(
var isSort: String? = null
)
object ProductCtrl {
fun get(ctx :Context){
val id = ctx.pathParam("id")
val product = database.find(Product::class.java, id) ?: throw NotFoundResponse("Product not found for $id")
val hsnCode = ctx.pathParam("hsnCode")
val product = database.find(Product::class.java, hsnCode) ?: throw NotFoundResponse("Product not found for $hsnCode")
ctx.json(product)
}
fun getAll(ctx: Context){
val productList = Session.database.find(Product::class.java)
.findList()
.sortedBy { it.hsnCode }
ctx.json(productList)
}
fun create(ctx :Context){
val product = ctx.bodyAsClass<Product>()
database.save(product)
@@ -479,7 +491,7 @@ object Quotation {
}
fun reqForQuote(ctx :Context){
val reqForQuoteNum = ctx.pathParam(("rfqNum"))
val rfq = database.find(ReqForQuote::class.java)
val rfq = database.find(RequestForQuote::class.java)
.where()
.eq("reqForQuoteNum", reqForQuoteNum)
?: throw NotFoundResponse("request for quote not found for this quotation")
@@ -560,9 +572,9 @@ object Vendor {
ctx.result("rating changed")
}
}
object ReqForQuote {
object RequestForQuote {
fun create(ctx :Context) {
val rfq = ctx.bodyAsClass<com.restapi.domain.ReqForQuote>()
val rfq = ctx.bodyAsClass<ReqForQuote>()
database.save(rfq)
//ctx.result("request for quote created")
//ctx.json(rfq)
@@ -571,7 +583,7 @@ object ReqForQuote {
}
fun get(ctx :Context){
val id = ctx.pathParam("id")
val rfq = database.find(com.restapi.domain.ReqForQuote::class.java, id) ?: throw NotFoundResponse("request for quote not found for id $id")
val rfq = database.find(ReqForQuote::class.java, id) ?: throw NotFoundResponse("request for quote not found for id $id")
ctx.json(rfq)
}
fun update(ctx :Context){