feat(collection): generate id for product and organization
This commit is contained in:
@@ -9,15 +9,19 @@ class CollectionManager(
|
|||||||
) {
|
) {
|
||||||
private val list = LinkedList<Product>()
|
private val list = LinkedList<Product>()
|
||||||
private var currProductId = 1L
|
private var currProductId = 1L
|
||||||
|
private var currOrgId = 1L
|
||||||
|
|
||||||
fun addProduct(product: Product) {
|
fun addProduct(product: Product) {
|
||||||
list.add(generateProductId(product))
|
list.add(generateId(product))
|
||||||
io.println(list.toString())
|
io.println(list.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun generateProductId(product: Product): Product {
|
fun generateId(product: Product): Product {
|
||||||
val productId = product.copy(id = currProductId)
|
val res =
|
||||||
currProductId++
|
product.copy(
|
||||||
return productId
|
id = currProductId++,
|
||||||
|
organization = product.organization.copy(id = currOrgId++),
|
||||||
|
)
|
||||||
|
return res
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user