This commit is contained in:
2024-01-19 10:42:50 +05:30
parent 20f6abf3b7
commit 043cddcaa0
4 changed files with 79 additions and 35 deletions

View File

@@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.JsonDeserializer
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.restapi.domain.*
import com.restapi.domain.Product
import com.restapi.domain.PurchaseOrder
import com.restapi.domain.Quotation
import com.restapi.domain.Session.currentUser
@@ -411,6 +412,33 @@ object PurchaseOrder {
}
}
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")
ctx.json(product)
}
fun create(ctx :Context){
val product = ctx.bodyAsClass<Product>()
database.save(product)
}
fun delete(ctx: Context) {
val id = ctx.pathParam("id")
val product = database.delete(Product::class.java, id)
}
fun patch(ctx: Context) {
}
fun update(ctx: Context) {
val id = ctx.pathParam("id")
}
}
object Quotation {
fun get(ctx :Context){
val id = ctx.pathParam("id")
@@ -452,36 +480,12 @@ object Quotation {
fun reqForQuote(ctx :Context){
val reqForQuoteNum = ctx.pathParam(("rfqNum"))
val rfq = database.find(ReqForQuote::class.java)
.where()
.eq("reqForQuoteNum", reqForQuoteNum)
?: throw NotFoundResponse("request for quote not found for this quotation")
.where()
.eq("reqForQuoteNum", reqForQuoteNum)
?: throw NotFoundResponse("request for quote not found for this quotation")
ctx.json(rfq)
}
}
object Product {
fun get(ctx :Context){
val id = ctx.pathParam("id")
val product = database.find(Product::class.java, id) ?: throw NotFoundResponse("product nor found for id $id")
ctx.json(product)
}
fun create(ctx :Context){
val product = ctx.bodyAsClass<Product>()
database.save(product)
ctx.result("product created")
}
fun update(ctx :Context){
}
fun delete(ctx: Context){
val id = ctx.pathParam(("id"))
val product = database.find(Product::class.java, id) ?:throw NotFoundResponse("product not found for id $id")
//product.delete()
ctx.result("product with id $id deleted")
}
fun getDoc(ctx :Context){
}
}
object Document {
fun get(ctx :Context){
val id = ctx.pathParam("id")