Compare commits

..

No commits in common. "cb184dee3bedaace7620b4ca5eb0dee5eb3285d9" and "20f6abf3b70dbe554dfcd0ed0db6a4d90eccb5c9" have entirely different histories.

4 changed files with 45 additions and 100 deletions

View File

@ -5,14 +5,14 @@ Authorization: {{auth-token}}
{ {
"data": { "data": {
"number": "KA01HD6677", "number": "KA01HD6667",
"owner": "gowthaman" "owner": "gowthaman"
}, },
"uniqueIdentifier": "" "uniqueIdentifier": ""
} }
### create row ### create row
POST http://localhost:9001/api/vendor/po POST http://localhost:9001/api/vendor
Content-Type: application/json Content-Type: application/json
Authorization: {{auth-token}} Authorization: {{auth-token}}
@ -58,7 +58,7 @@ Authorization: Bearer {{auth-token}}
### query row ### query row
POST http://localhost:9001/api/vehicle/query POST http://localhost:9001/api/vehicle/query
Content-Type: application/json Content-Type: application/json
Authorization: {{set-auth-token}} Authorization: set-auth-token
{ {
"sql": "select sys_pk, tenant_id, deleted_on, deleted_by, deleted, version, created_at, modified_at, created_by, modified_by, data, tags, comments, unique_identifier, entity_name from data_model where data ->> 'number' = :number", "sql": "select sys_pk, tenant_id, deleted_on, deleted_by, deleted, version, created_at, modified_at, created_by, modified_by, data, tags, comments, unique_identifier, entity_name from data_model where data ->> 'number' = :number",
@ -94,41 +94,5 @@ DELETE http://localhost:9001/api/vehicle/KA01HD6667
Authorization: {{auth-token}} Authorization: {{auth-token}}
### get po for id ### get po for id
GET http://localhost:9001/api/vendor/product GET http://localhost:9001/api/vendor/po/12345
Authorization: {{auth-token}}
### get product for id
GET http://localhost:9001/api/vendor/product/7
Authorization: {{auth-token}}
### get row
GET http://localhost:9001/api/vendor/product/7
Authorization: Bearer {{auth-token}}
### create product
POST http://localhost:9001/api/vendor/product
Content-Type: application/json
Authorization: {{auth-token}}
{
"name": "Shirt",
"description": "Black Shirt",
"hsnCode": "BSM1XL"
}
### update field
PATCH http://localhost:9001/api/vendor/product/11
Content-Type: application/json
Authorization: {{auth-token}}
### upate a row
PUT http://localhost:9001/api/vendor/product/11
Content-Type: application/json
Authorization: {{auth-token}}
### delete a row
DELETE http://localhost:9001/api/vendor/product/2
Authorization: {{auth-token}} Authorization: {{auth-token}}

View File

@ -6,7 +6,6 @@ import com.restapi.config.AppConfig.Companion.appConfig
import com.restapi.config.Auth.validateAuthToken import com.restapi.config.Auth.validateAuthToken
import com.restapi.controllers.* import com.restapi.controllers.*
import com.restapi.domain.DataNotFoundException import com.restapi.domain.DataNotFoundException
import com.restapi.domain.Product
import com.restapi.domain.Session import com.restapi.domain.Session
import com.restapi.domain.Session.currentTenant import com.restapi.domain.Session.currentTenant
import com.restapi.domain.Session.currentUser import com.restapi.domain.Session.currentUser
@ -23,6 +22,7 @@ import io.javalin.http.UnauthorizedResponse
import io.javalin.http.util.NaiveRateLimit import io.javalin.http.util.NaiveRateLimit
import io.javalin.http.util.RateLimitUtil import io.javalin.http.util.RateLimitUtil
import io.javalin.json.JavalinJackson import io.javalin.json.JavalinJackson
import org.checkerframework.dataflow.qual.Pure
import org.jose4j.jwt.consumer.InvalidJwtException import org.jose4j.jwt.consumer.InvalidJwtException
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import java.security.MessageDigest import java.security.MessageDigest
@ -135,12 +135,10 @@ fun main(args: Array<String>) {
delete("/{id}", Quotation::delete, Roles(Role.Explicit(listOf("ROLE_QUOTE_CREATE", "ROLE_ADMIN")))) delete("/{id}", Quotation::delete, Roles(Role.Explicit(listOf("ROLE_QUOTE_CREATE", "ROLE_ADMIN"))))
} }
path("/product"){ path("/product"){
post("", ProductCtrl::create, Roles(Role.Explicit(listOf("ROLE_PRODUCT_CREATE", "ROLE_ADMIN")))) post("", Product::create, Roles(Role.Explicit(listOf("ROLE_PRODUCT_CREATE", "ROLE_ADMIN"))))
//get("/{hsnCode}", ProductCtrl::get, Roles(Role.Explicit(listOf("ROLE_PRODUCT_VIEW", "ROLE_ADMIN")))) get("/{id}", Product::get, Roles(Role.Explicit(listOf("ROLE_DOC_VIEW", "ROLE_ADMIN", "ROLE_PRODUCT_CREATE"))))
put("/{id}", ProductCtrl::update, Roles(Role.Explicit(listOf("ROLE_PRODUCT_UPDATE", "ROLE_ADMIN")))) delete("{id}", Product::delete, Roles(Role.Explicit(listOf("ROLE_PRODUCT_CREATE", "ROLE_ADMIN"))))
//patch("/{id}", ProductCtrl::patch, Roles(Role.Explicit(listOf("ROLE_PRODUCT_UPDATE", "ROLE_ADMIN")))) get("/doc/{id}", Product::getDoc, Roles(Role.Explicit(listOf("ROLE_ADMIN", "ROLE_VIEW_DOC"))))
delete("/{id}", ProductCtrl::delete, Roles(Role.Explicit(listOf("ROLE_PRODUCT_DELETE", "ROLE_ADMIN"))))
get("", ProductCtrl::getAll, Roles(Role.Explicit(listOf("ROLE_PRODUCT_VIEW", "ROLE_ADMIN"))))
} }
path("/doc"){ path("/doc"){
post("", Document::create, Roles(Role.Explicit(listOf("ROLE_DOC_CREATE", "ROLE_ADMIN")))) post("", Document::create, Roles(Role.Explicit(listOf("ROLE_DOC_CREATE", "ROLE_ADMIN"))))
@ -151,9 +149,9 @@ fun main(args: Array<String>) {
delete("/{id}", Document::delete, Roles(Role.Explicit(listOf("ROLE_DOC_CREATE")))) delete("/{id}", Document::delete, Roles(Role.Explicit(listOf("ROLE_DOC_CREATE"))))
} }
path("/reqForQuote"){ path("/reqForQuote"){
post("", RequestForQuote::create, Roles(Role.Explicit(listOf("ROLE_RFQ_CREATE")))) post("", ReqForQuote::create, Roles(Role.Explicit(listOf("ROLE_RFQ_CREATE"))))
get("/{id}", RequestForQuote::get, Roles(Role.Explicit(listOf("ROLE_RFQ_CREATE", "ROLE_RFQ_VIEW")))) get("/{id}", ReqForQuote::get, Roles(Role.Explicit(listOf("ROLE_RFQ_CREATE", "ROLE_RFQ_VIEW"))))
put("/{id}", RequestForQuote::update, Roles(Role.Explicit(listOf("ROLE_RFQ_CREATE")))) put("/{id}", ReqForQuote::update, Roles(Role.Explicit(listOf("ROLE_RFQ_CREATE"))))
} }
} }
post("/script/database/{name}", Entities::executeStoredProcedure, Roles(adminRole, Role.DbOps)) post("/script/database/{name}", Entities::executeStoredProcedure, Roles(adminRole, Role.DbOps))

View File

@ -6,7 +6,6 @@ import com.fasterxml.jackson.databind.JsonDeserializer
import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.restapi.domain.* import com.restapi.domain.*
import com.restapi.domain.Product
import com.restapi.domain.PurchaseOrder import com.restapi.domain.PurchaseOrder
import com.restapi.domain.Quotation import com.restapi.domain.Quotation
import com.restapi.domain.Session.currentUser import com.restapi.domain.Session.currentUser
@ -412,45 +411,6 @@ object PurchaseOrder {
} }
} }
data class ProductSearch(
var isSort: String? = null
)
object ProductCtrl {
fun get(ctx :Context){
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)
}
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 { object Quotation {
fun get(ctx :Context){ fun get(ctx :Context){
val id = ctx.pathParam("id") val id = ctx.pathParam("id")
@ -491,13 +451,37 @@ object Quotation {
} }
fun reqForQuote(ctx :Context){ fun reqForQuote(ctx :Context){
val reqForQuoteNum = ctx.pathParam(("rfqNum")) val reqForQuoteNum = ctx.pathParam(("rfqNum"))
val rfq = database.find(RequestForQuote::class.java) val rfq = database.find(ReqForQuote::class.java)
.where() .where()
.eq("reqForQuoteNum", reqForQuoteNum) .eq("reqForQuoteNum", reqForQuoteNum)
?: throw NotFoundResponse("request for quote not found for this quotation") ?: throw NotFoundResponse("request for quote not found for this quotation")
ctx.json(rfq) 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 { object Document {
fun get(ctx :Context){ fun get(ctx :Context){
val id = ctx.pathParam("id") val id = ctx.pathParam("id")
@ -572,9 +556,9 @@ object Vendor {
ctx.result("rating changed") ctx.result("rating changed")
} }
} }
object RequestForQuote { object ReqForQuote {
fun create(ctx :Context) { fun create(ctx :Context) {
val rfq = ctx.bodyAsClass<ReqForQuote>() val rfq = ctx.bodyAsClass<com.restapi.domain.ReqForQuote>()
database.save(rfq) database.save(rfq)
//ctx.result("request for quote created") //ctx.result("request for quote created")
//ctx.json(rfq) //ctx.json(rfq)
@ -583,7 +567,7 @@ object RequestForQuote {
} }
fun get(ctx :Context){ fun get(ctx :Context){
val id = ctx.pathParam("id") val id = ctx.pathParam("id")
val rfq = database.find(ReqForQuote::class.java, id) ?: throw NotFoundResponse("request for quote not found for id $id") val rfq = database.find(com.restapi.domain.ReqForQuote::class.java, id) ?: throw NotFoundResponse("request for quote not found for id $id")
ctx.json(rfq) ctx.json(rfq)
} }
fun update(ctx :Context){ fun update(ctx :Context){

View File

@ -275,7 +275,6 @@ enum class UOM {
} }
@Entity @Entity
open class Product :BaseTenantModel() { open class Product :BaseTenantModel() {
var id: Int? = null
var name :String = "" var name :String = ""
var description :String = "" var description :String = ""
var hsnCode :String = "" var hsnCode :String = ""
@ -324,8 +323,8 @@ open class ReqForQuote :BaseTenantModel() {
var potentialVendors :List<Long>? = null var potentialVendors :List<Long>? = null
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
var status :RFQStatus? = null var status :RFQStatus? = null
// @DbArray @DbArray
// var docs :List<Document>? = null var docs :List<Document>? = null
@DbJsonB @DbJsonB
var products :List<POProducts>? = null var products :List<POProducts>? = null
var reqForQuoteNum: String? = null var reqForQuoteNum: String? = null