checkout backoffice
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
actor "git.k6n.net/go-cart-actor/pkg/actor"
|
||||
"git.k6n.net/go-cart-actor/pkg/cart"
|
||||
"git.k6n.net/go-cart-actor/pkg/checkout"
|
||||
"github.com/matst80/go-redis-inventory/pkg/inventory"
|
||||
"github.com/matst80/slask-finder/pkg/messaging"
|
||||
amqp "github.com/rabbitmq/amqp091-go"
|
||||
@@ -24,6 +25,13 @@ type CartFileInfo struct {
|
||||
Modified time.Time `json:"modified"`
|
||||
}
|
||||
|
||||
type CheckoutFileInfo struct {
|
||||
ID string `json:"id"`
|
||||
CheckoutId checkout.CheckoutId `json:"checkoutId"`
|
||||
Size int64 `json:"size"`
|
||||
Modified time.Time `json:"modified"`
|
||||
}
|
||||
|
||||
func envOrDefault(key, def string) string {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
return v
|
||||
@@ -97,7 +105,13 @@ func main() {
|
||||
reg := cart.NewCartMultationRegistry(cart.NewCartMutationContext(nil))
|
||||
diskStorage := actor.NewDiskStorage[cart.CartGrain](dataDir, reg)
|
||||
|
||||
fs := NewFileServer(dataDir, diskStorage)
|
||||
checkoutDataDir := envOrDefault("CHECKOUT_DATA_DIR", "checkout-data")
|
||||
_ = os.MkdirAll(checkoutDataDir, 0755)
|
||||
|
||||
regCheckout := checkout.NewCheckoutMutationRegistry(checkout.NewCheckoutMutationContext())
|
||||
diskStorageCheckout := actor.NewDiskStorage[checkout.CheckoutGrain](checkoutDataDir, regCheckout)
|
||||
|
||||
fs := NewFileServer(dataDir, checkoutDataDir, diskStorage, diskStorageCheckout)
|
||||
|
||||
hub := NewHub()
|
||||
go hub.Run()
|
||||
@@ -105,6 +119,8 @@ func main() {
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("GET /carts", fs.CartsHandler)
|
||||
mux.HandleFunc("GET /cart/{id}", fs.CartHandler)
|
||||
mux.HandleFunc("GET /checkouts", fs.CheckoutsHandler)
|
||||
mux.HandleFunc("GET /checkout/{id}", fs.CheckoutHandler)
|
||||
mux.HandleFunc("PUT /inventory/{locationId}/{sku}", func(w http.ResponseWriter, r *http.Request) {
|
||||
inventoryLocationId := inventory.LocationID(r.PathValue("locationId"))
|
||||
inventorySku := inventory.SKU(r.PathValue("sku"))
|
||||
|
||||
Reference in New Issue
Block a user