feat(collection): generate id for product and organization

This commit is contained in:
2026-03-02 14:06:55 +03:00
parent 1161bbaedc
commit ca5a6536cd

View File

@@ -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
} }
} }