product
This commit is contained in:
parent
043cddcaa0
commit
cb184dee3b
6
api.http
6
api.http
@ -98,7 +98,7 @@ GET http://localhost:9001/api/vendor/product
|
||||
Authorization: {{auth-token}}
|
||||
|
||||
### get product for id
|
||||
GET http://localhost:9001/api/vendor/product/6
|
||||
GET http://localhost:9001/api/vendor/product/7
|
||||
Authorization: {{auth-token}}
|
||||
|
||||
### get row
|
||||
@ -112,8 +112,8 @@ Authorization: {{auth-token}}
|
||||
|
||||
{
|
||||
"name": "Shirt",
|
||||
"description": "White Shirt",
|
||||
"hsnCode": "WSM1XL"
|
||||
"description": "Black Shirt",
|
||||
"hsnCode": "BSM1XL"
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +23,6 @@ import io.javalin.http.UnauthorizedResponse
|
||||
import io.javalin.http.util.NaiveRateLimit
|
||||
import io.javalin.http.util.RateLimitUtil
|
||||
import io.javalin.json.JavalinJackson
|
||||
import org.checkerframework.dataflow.qual.Pure
|
||||
import org.jose4j.jwt.consumer.InvalidJwtException
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.security.MessageDigest
|
||||
@ -137,11 +136,11 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
path("/product"){
|
||||
post("", ProductCtrl::create, Roles(Role.Explicit(listOf("ROLE_PRODUCT_CREATE", "ROLE_ADMIN"))))
|
||||
get("/{id}", ProductCtrl::get, Roles(Role.Explicit(listOf("ROLE_PRODUCT_VIEW", "ROLE_ADMIN"))))
|
||||
//get("/{hsnCode}", ProductCtrl::get, Roles(Role.Explicit(listOf("ROLE_PRODUCT_VIEW", "ROLE_ADMIN"))))
|
||||
put("/{id}", ProductCtrl::update, Roles(Role.Explicit(listOf("ROLE_PRODUCT_UPDATE", "ROLE_ADMIN"))))
|
||||
patch("/{id}", ProductCtrl::patch, Roles(Role.Explicit(listOf("ROLE_PRODUCT_UPDATE", "ROLE_ADMIN"))))
|
||||
//patch("/{id}", ProductCtrl::patch, Roles(Role.Explicit(listOf("ROLE_PRODUCT_UPDATE", "ROLE_ADMIN"))))
|
||||
delete("/{id}", ProductCtrl::delete, Roles(Role.Explicit(listOf("ROLE_PRODUCT_DELETE", "ROLE_ADMIN"))))
|
||||
get("") {ctx -> ctx.json(Session.database.find(Product::class.java).findList())}
|
||||
get("", ProductCtrl::getAll, Roles(Role.Explicit(listOf("ROLE_PRODUCT_VIEW", "ROLE_ADMIN"))))
|
||||
}
|
||||
path("/doc"){
|
||||
post("", Document::create, Roles(Role.Explicit(listOf("ROLE_DOC_CREATE", "ROLE_ADMIN"))))
|
||||
@ -152,9 +151,9 @@ fun main(args: Array<String>) {
|
||||
delete("/{id}", Document::delete, Roles(Role.Explicit(listOf("ROLE_DOC_CREATE"))))
|
||||
}
|
||||
path("/reqForQuote"){
|
||||
post("", ReqForQuote::create, Roles(Role.Explicit(listOf("ROLE_RFQ_CREATE"))))
|
||||
get("/{id}", ReqForQuote::get, Roles(Role.Explicit(listOf("ROLE_RFQ_CREATE", "ROLE_RFQ_VIEW"))))
|
||||
put("/{id}", ReqForQuote::update, Roles(Role.Explicit(listOf("ROLE_RFQ_CREATE"))))
|
||||
post("", RequestForQuote::create, Roles(Role.Explicit(listOf("ROLE_RFQ_CREATE"))))
|
||||
get("/{id}", RequestForQuote::get, Roles(Role.Explicit(listOf("ROLE_RFQ_CREATE", "ROLE_RFQ_VIEW"))))
|
||||
put("/{id}", RequestForQuote::update, Roles(Role.Explicit(listOf("ROLE_RFQ_CREATE"))))
|
||||
}
|
||||
}
|
||||
post("/script/database/{name}", Entities::executeStoredProcedure, Roles(adminRole, Role.DbOps))
|
||||
|
||||
@ -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){
|
||||
|
||||
@ -324,8 +324,8 @@ open class ReqForQuote :BaseTenantModel() {
|
||||
var potentialVendors :List<Long>? = null
|
||||
@Enumerated(EnumType.STRING)
|
||||
var status :RFQStatus? = null
|
||||
@DbArray
|
||||
var docs :List<Document>? = null
|
||||
// @DbArray
|
||||
// var docs :List<Document>? = null
|
||||
@DbJsonB
|
||||
var products :List<POProducts>? = null
|
||||
var reqForQuoteNum: String? = null
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user