Documentation
¶
Index ¶
- type Inventory
- type Module
- func (m *Module) CreateShipment(ctx context.Context, input any) (any, error)
- func (m *Module) CreateShipmentStep(sCtx mdk.StepContext) mdk.StepResult
- func (m *Module) FieldResolvers() map[string]any
- func (m *Module) GetInventory(ctx context.Context, productID string) (*Inventory, error)
- func (m *Module) GetShipment(ctx context.Context, id string) (*Shipment, error)
- func (m *Module) GetShipmentByOrder(ctx context.Context, orderID string) (*Shipment, error)
- func (m *Module) ID() string
- func (m *Module) Init(ctx context.Context, rt mdk.Runtime) error
- func (m *Module) Models() []any
- func (m *Module) Mutations() map[string]any
- func (m *Module) Queries() map[string]any
- func (m *Module) ReleaseInventory(ctx context.Context, input any) (any, error)
- func (m *Module) ReleaseInventoryStep(sCtx mdk.StepContext) mdk.StepResult
- func (m *Module) Repo() *Repository
- func (m *Module) ReserveInventory(ctx context.Context, input any) (any, error)
- func (m *Module) ReserveInventoryStep(sCtx mdk.StepContext) mdk.StepResult
- func (m *Module) Routes() []mdk.Route
- func (m *Module) ShipOrder(ctx context.Context, input any) (any, error)
- func (m *Module) ShipOrderStep(sCtx mdk.StepContext) mdk.StepResult
- func (m *Module) Shutdown(ctx context.Context) error
- func (m *Module) UpdateShipmentStatus(ctx context.Context, shipmentID string, trackingNumber *string, ...) (*Shipment, error)
- type Repository
- func (r *Repository) GetInventoryByProductID(ctx context.Context, productID string) (*Inventory, error)
- func (r *Repository) GetShipment(ctx context.Context, id string) (*Shipment, error)
- func (r *Repository) GetShipmentByOrderID(ctx context.Context, orderID string) (*Shipment, error)
- func (r *Repository) SaveInventory(ctx context.Context, inv *Inventory) error
- func (r *Repository) SaveShipment(ctx context.Context, s *Shipment) error
- type Shipment
- type ShipmentStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Inventory ¶
type Inventory struct {
ID string `gorm:"primaryKey" json:"id"`
ProductID string `gorm:"uniqueIndex;not null" json:"product_id"`
AvailableQuantity int `gorm:"not null" json:"available_quantity"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
Inventory represents the available stock for a product.
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module implements the mdk.Module interface for Fulfillment.
func (*Module) CreateShipment ¶
func (*Module) CreateShipmentStep ¶
func (m *Module) CreateShipmentStep(sCtx mdk.StepContext) mdk.StepResult
CreateShipmentStep wraps CreateShipment to mdk.StepHandler.
func (*Module) FieldResolvers ¶
func (*Module) GetInventory ¶
func (*Module) GetShipment ¶
func (*Module) GetShipmentByOrder ¶
func (*Module) ReleaseInventory ¶
func (*Module) ReleaseInventoryStep ¶
func (m *Module) ReleaseInventoryStep(sCtx mdk.StepContext) mdk.StepResult
ReleaseInventoryStep wraps ReleaseInventory to mdk.StepHandler.
func (*Module) Repo ¶
func (m *Module) Repo() *Repository
func (*Module) ReserveInventory ¶
func (*Module) ReserveInventoryStep ¶
func (m *Module) ReserveInventoryStep(sCtx mdk.StepContext) mdk.StepResult
ReserveInventoryStep wraps ReserveInventory to mdk.StepHandler.
func (*Module) ShipOrder ¶
ShipOrder simulates shipping the order (updates status to SHIPPED and adds tracking number).
func (*Module) ShipOrderStep ¶
func (m *Module) ShipOrderStep(sCtx mdk.StepContext) mdk.StepResult
ShipOrderStep wraps ShipOrder to mdk.StepHandler.
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
func NewRepository ¶
func NewRepository(database *gorm.DB) *Repository
func (*Repository) GetInventoryByProductID ¶
func (r *Repository) GetInventoryByProductID(ctx context.Context, productID string) (*Inventory, error)
GetInventoryByProductID retrieves inventory for a product.
func (*Repository) GetShipment ¶
GetShipment retrieves a shipment by ID.
func (*Repository) GetShipmentByOrderID ¶
GetShipmentByOrderID retrieves a shipment by its order ID.
func (*Repository) SaveInventory ¶
func (r *Repository) SaveInventory(ctx context.Context, inv *Inventory) error
SaveInventory saves an inventory record.
func (*Repository) SaveShipment ¶
func (r *Repository) SaveShipment(ctx context.Context, s *Shipment) error
SaveShipment saves a shipment record.
type Shipment ¶
type Shipment struct {
ID string `gorm:"primaryKey" json:"id"`
OrderID string `gorm:"uniqueIndex;not null" json:"order_id"`
Status ShipmentStatus `gorm:"not null" json:"status"`
TrackingNumber string `json:"tracking_number"`
Carrier string `json:"carrier"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
Shipment represents the logistics fulfillment of an order.
type ShipmentStatus ¶
type ShipmentStatus string
const ( ShipmentPending ShipmentStatus = "PENDING" ShipmentShipped ShipmentStatus = "SHIPPED" ShipmentDelivered ShipmentStatus = "DELIVERED" ShipmentCancelled ShipmentStatus = "CANCELLED" )