[hw-3] loms service

This commit is contained in:
Никита Шубин
2025-06-20 10:11:59 +00:00
parent c8e056bc99
commit b88dfe6db5
73 changed files with 8837 additions and 52 deletions

View File

@@ -0,0 +1,18 @@
@startuml
actor User as u
collections Cart as c
database CartStorage as cs
collections Order as o
u -> c : POST /checkout/<user_id>
activate c
c -> cs : cart.GetItemsByUserID
c -> o : gRPC Loms.OrderCreate\n\t- user\n\t- []item
c -> cs : cart.DeleteItemsByUserID
c -> u : Response: 200 OK
deactivate c
@enduml

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

@@ -0,0 +1,32 @@
@startuml
actor User as u
collections Cart as c
database CartStorage as cs
collections ProductService as p
collections Order as o
u -> c : POST /user/<user_id>/cart/<sku_id>\n\t- count
activate c
loop for each item in request
c -> p : /get_product\n\t- sku\n\t- token
activate p
p -> c : \nResponse:\n\t- name\n\t- price
deactivate p
c -> c : validate product exists
c -> o : gRPC Loms.StocksInfo\n\t- sku
activate o
o -> c : Response:\n\t- count
deactivate o
c -> c : validate stocks
alt stocks enough
c -> cs : cart.AddItem()
c -> u : 200 OK
else
c -> u : 412 Failed Precondition (insufficient stocks)
end
end
deactivate c
@enduml

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

View File

@@ -0,0 +1,18 @@
@startuml
actor User as u
collections LOMS as l
database OrdersStorage as os
database StocksStorage as ss
u -> l : gRPC Loms.OrderCancel\n\t- orderID
activate l
l -> os : order.GetByOrderID()
l -> ss : stocks.ReserveCancel()
l -> os : order.SetStatus(cancelled)
deactivate l
l -> u : Response: OK (code_id=0)
@enduml

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

@@ -0,0 +1,22 @@
@startuml
actor User as u
collections LOMS as l
database OrdersStorage as os
database StocksStorage as ss
u -> l : gRPC Loms.OrderCreate\n\t- user\n\t- items: []item{\n\t\t- sku\n\t\t- count\n\t }
activate l
l -> os : order.Create()\n\tstatus=new
l -> ss : stocks.Reserve()
alt Reserve success
l -> os : order.SetStatus(awaiting payment)
l -> u : Response: OK (code_id=0)\n\t- orderID
else
l -> os : order.SetStatus(failed)
l -> u : Failed Precondition (code_id 9)
end
deactivate l
@enduml

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@@ -0,0 +1,19 @@
@startuml
actor User as u
collections LOMS as l
database OrdersStorage as os
u -> l : gRPC Loms.OrderInfo\n\t- orderID int64
activate l
l -> os : order.GetByID()
alt order exists
l -> u : Response: OK (code_id=0)\n\t- status\n\t- user\n\t- []items{}
else
l -> u : Response: Not Found (code_id=5)
end
deactivate l
@enduml

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@@ -0,0 +1,17 @@
@startuml
actor User as u
collections LOMS as l
database OrdersStorage as os
database StocksStorage as ss
u -> l : gRPC Loms.OrderPay\n\t- orderID
activate l
l -> ss : stocks.ReserveRemove()
l -> os : order.SetStatus(payed)
l -> u : Response: OK (code_id=0)
deactivate l
@enduml

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@@ -0,0 +1,15 @@
@startuml
actor User as u
collections LOMS as l
database StocksStorage as ss
u -> l : gRPC Loms.StocksInfo\n\t- sku
activate l
l -> ss : stocks.GetBySKU()
l -> u : Response: OK (code_id=0)\n- count
deactivate l
@enduml

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB