handle prefixes
This commit is contained in:
parent
fb4f1a0995
commit
f2b05b229d
@ -128,9 +128,16 @@ fun main(args: Array<String>) {
|
|||||||
get("/plants", IncomingInventoryCtrl::plantsForUser,
|
get("/plants", IncomingInventoryCtrl::plantsForUser,
|
||||||
Roles(
|
Roles(
|
||||||
Role.Explicit("ROLE_INVENTORY_CREATE"),
|
Role.Explicit("ROLE_INVENTORY_CREATE"),
|
||||||
|
Role.Explicit("ROLE_VENDOR_VIEW"),
|
||||||
|
Role.Explicit("ROLE_VENDOR_CREATE"),
|
||||||
Role.Explicit("ROLE_INVENTORY_VIEW")
|
Role.Explicit("ROLE_INVENTORY_VIEW")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
put("/plants/{id}", IncomingInventoryCtrl::updatePlant,
|
||||||
|
Roles(
|
||||||
|
Role.Explicit("ROLE_INVENTORY_CREATE"),
|
||||||
|
Role.Explicit("ROLE_VENDOR_CREATE")
|
||||||
|
))
|
||||||
post("", IncomingInventoryCtrl::create, Roles(Role.Explicit("ROLE_INVENTORY_CREATE")))
|
post("", IncomingInventoryCtrl::create, Roles(Role.Explicit("ROLE_INVENTORY_CREATE")))
|
||||||
get("/next", IncomingInventoryCtrl::getNextNum, Roles(Role.Explicit("ROLE_INVENTORY_CREATE")))
|
get("/next", IncomingInventoryCtrl::getNextNum, Roles(Role.Explicit("ROLE_INVENTORY_CREATE")))
|
||||||
get(
|
get(
|
||||||
|
|||||||
@ -810,6 +810,14 @@ object IncomingInventoryCtrl {
|
|||||||
Session.currentUserPlants()
|
Session.currentUserPlants()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
fun updatePlant(ctx: Context) {
|
||||||
|
val p = ctx.bodyAsClass<Plant>()
|
||||||
|
val plant = database.find(Plant::class.java, ctx.pathParam("id"))
|
||||||
|
plant.patch(p)
|
||||||
|
ctx.json(
|
||||||
|
Session.currentUserPlants()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fun create(ctx: Context) {
|
fun create(ctx: Context) {
|
||||||
val ticket = ctx.bodyAsClass<IncomingInventory>()
|
val ticket = ctx.bodyAsClass<IncomingInventory>()
|
||||||
|
|||||||
@ -30,7 +30,6 @@ import java.security.spec.PKCS8EncodedKeySpec
|
|||||||
import java.security.spec.X509EncodedKeySpec
|
import java.security.spec.X509EncodedKeySpec
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.collections.HashMap
|
|
||||||
import kotlin.jvm.optionals.getOrDefault
|
import kotlin.jvm.optionals.getOrDefault
|
||||||
|
|
||||||
|
|
||||||
@ -138,14 +137,15 @@ object Session {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
fun a(){
|
|
||||||
val a = HashMap<String,String>()
|
fun a() {
|
||||||
|
val a = HashMap<String, String>()
|
||||||
a.put("a", "b");
|
a.put("a", "b");
|
||||||
a.put("a", "b");
|
a.put("a", "b");
|
||||||
a.put("a", "b");
|
a.put("a", "b");
|
||||||
a.put("a", "b");
|
a.put("a", "b");
|
||||||
|
|
||||||
val b = HashMap<String,String>().apply {
|
val b = HashMap<String, String>().apply {
|
||||||
put("a", "b");
|
put("a", "b");
|
||||||
put("a", "b");
|
put("a", "b");
|
||||||
put("a", "b");
|
put("a", "b");
|
||||||
@ -159,6 +159,7 @@ object Session {
|
|||||||
//will work only when c is not null
|
//will work only when c is not null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val sc = DatabaseConfig().apply {
|
private val sc = DatabaseConfig().apply {
|
||||||
loadFromProperties(Properties().apply {
|
loadFromProperties(Properties().apply {
|
||||||
setProperty("datasource.db.username", appConfig.dbUser())
|
setProperty("datasource.db.username", appConfig.dbUser())
|
||||||
@ -187,6 +188,11 @@ object Session {
|
|||||||
.where()
|
.where()
|
||||||
.eq("plantId", it)
|
.eq("plantId", it)
|
||||||
.findOne()
|
.findOne()
|
||||||
|
?.apply {
|
||||||
|
if (this.prefixes == null || this.prefixes.isNullOrEmpty()) {
|
||||||
|
this.prefixes = mutableMapOf("INBOUND" to "MRN/")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun jwk(): MutableMap<String, Any> = keypair.toParams(JsonWebKey.OutputControlLevel.PUBLIC_ONLY)
|
fun jwk(): MutableMap<String, Any> = keypair.toParams(JsonWebKey.OutputControlLevel.PUBLIC_ONLY)
|
||||||
|
|||||||
@ -254,10 +254,14 @@ class SafeStringDeserializer : JsonDeserializer<String>() {
|
|||||||
enum class AddressType {
|
enum class AddressType {
|
||||||
BILLING, SHIPPING
|
BILLING, SHIPPING
|
||||||
}
|
}
|
||||||
|
|
||||||
data class ContactPerson(val name: String = "", val email: String = "", val mobile: String = "")
|
data class ContactPerson(val name: String = "", val email: String = "", val mobile: String = "")
|
||||||
data class Address(val type: AddressType = AddressType.BILLING,
|
data class Address(
|
||||||
val address: String = "",
|
val type: AddressType = AddressType.BILLING,
|
||||||
val pincode: String = "")
|
val address: String = "",
|
||||||
|
val pincode: String = ""
|
||||||
|
)
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
open class Vendor : BaseTenantModel() {
|
open class Vendor : BaseTenantModel() {
|
||||||
fun patchValues(updatedVendor: Vendor) {
|
fun patchValues(updatedVendor: Vendor) {
|
||||||
@ -282,6 +286,7 @@ open class Vendor : BaseTenantModel() {
|
|||||||
|
|
||||||
@DbJsonB
|
@DbJsonB
|
||||||
var addressList: List<Address>? = mutableListOf()
|
var addressList: List<Address>? = mutableListOf()
|
||||||
|
|
||||||
@DbJsonB
|
@DbJsonB
|
||||||
var contacts: List<ContactPerson> = mutableListOf()
|
var contacts: List<ContactPerson> = mutableListOf()
|
||||||
|
|
||||||
@ -659,8 +664,18 @@ open class ReminderLog : BaseTenantModel() {
|
|||||||
@Entity
|
@Entity
|
||||||
@Index(name = "plantid_idx", columnNames = ["plant_id"], unique = true)
|
@Index(name = "plantid_idx", columnNames = ["plant_id"], unique = true)
|
||||||
open class Plant : BaseModel() {
|
open class Plant : BaseModel() {
|
||||||
|
fun patch(p: Plant) {
|
||||||
|
this.plantName = p.plantName
|
||||||
|
this.prefixes?.apply {
|
||||||
|
this.clear()
|
||||||
|
this.putAll(p.prefixes ?: emptyMap())
|
||||||
|
}
|
||||||
|
this.save()
|
||||||
|
}
|
||||||
|
|
||||||
var plantId: String = ""
|
var plantId: String = ""
|
||||||
var plantName: String = ""
|
var plantName: String = ""
|
||||||
|
|
||||||
@DbJsonB
|
@DbJsonB
|
||||||
var prefixes: Map<String,String>? = emptyMap()
|
var prefixes: MutableMap<String, String>? = mutableMapOf()
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user